Loading base/include/android-base/unique_fd.h +12 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <fcntl.h> #if !defined(_WIN32) #include <dirent.h> #include <sys/socket.h> #endif Loading Loading @@ -211,6 +212,17 @@ inline FILE* Fdopen(unique_fd&& ufd, const char* mode) { return file; } // Using fdopendir with unique_fd correctly is more annoying than it should be, // because fdopen doesn't close the file descriptor received upon failure. inline DIR* Fdopendir(unique_fd&& ufd) { int fd = ufd.release(); DIR* dir = fdopendir(fd); if (dir == nullptr) { close(fd); } return dir; } #endif // !defined(_WIN32) } // namespace base Loading Loading
base/include/android-base/unique_fd.h +12 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <fcntl.h> #if !defined(_WIN32) #include <dirent.h> #include <sys/socket.h> #endif Loading Loading @@ -211,6 +212,17 @@ inline FILE* Fdopen(unique_fd&& ufd, const char* mode) { return file; } // Using fdopendir with unique_fd correctly is more annoying than it should be, // because fdopen doesn't close the file descriptor received upon failure. inline DIR* Fdopendir(unique_fd&& ufd) { int fd = ufd.release(); DIR* dir = fdopendir(fd); if (dir == nullptr) { close(fd); } return dir; } #endif // !defined(_WIN32) } // namespace base Loading