X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FFile.cpp;h=be44ce572925cb614a26d54c2b86fe86f5566e4a;hb=37ce60726a249bb67c885236a45d50cdb781694e;hp=253d005472a0a80f52c5bb67452071d0b9538c69;hpb=dc5b343342101953499fe887c24935e9688cf4cf;p=folly.git diff --git a/folly/File.cpp b/folly/File.cpp index 253d0054..be44ce57 100644 --- a/folly/File.cpp +++ b/folly/File.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,14 @@ #include -#include -#include -#include #include #include #include #include +#include +#include +#include #include @@ -31,14 +31,9 @@ namespace folly { -File::File() - : fd_(-1) - , ownsFd_(false) -{} +File::File() noexcept : fd_(-1), ownsFd_(false) {} -File::File(int fd, bool ownsFd) - : fd_(fd) - , ownsFd_(ownsFd) { +File::File(int fd, bool ownsFd) noexcept : fd_(fd), ownsFd_(ownsFd) { CHECK_GE(fd, -1) << "fd must be -1 or non-negative"; CHECK(fd != -1 || !ownsFd) << "cannot own -1"; } @@ -53,6 +48,12 @@ File::File(const char* name, int flags, mode_t mode) ownsFd_ = true; } +File::File(const std::string& name, int flags, mode_t mode) + : File(name.c_str(), flags, mode) {} + +File::File(StringPiece name, int flags, mode_t mode) + : File(name.str(), flags, mode) {} + File::File(File&& other) noexcept : fd_(other.fd_) , ownsFd_(other.ownsFd_) {