Loading adb/adb_utils.h +43 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <string> #include <android-base/macros.h> void close_stdin(); bool getcwd(std::string* cwd); Loading @@ -39,4 +41,45 @@ std::string perror_str(const char* msg); bool set_file_block_mode(int fd, bool block); extern int adb_close(int fd); // Helper to automatically close an FD when it goes out of scope. class ScopedFd { public: ScopedFd() { } ~ScopedFd() { Reset(); } void Reset(int fd = -1) { if (fd != fd_) { if (valid()) { adb_close(fd_); } fd_ = fd; } } int Release() { int temp = fd_; fd_ = -1; return temp; } bool valid() const { return fd_ >= 0; } int fd() const { return fd_; } private: int fd_ = -1; DISALLOW_COPY_AND_ASSIGN(ScopedFd); }; #endif adb/shell_service.cpp +0 −31 Original line number Diff line number Diff line Loading @@ -135,37 +135,6 @@ std::string ReadAll(int fd) { return received; } // Helper to automatically close an FD when it goes out of scope. class ScopedFd { public: ScopedFd() {} ~ScopedFd() { Reset(); } void Reset(int fd=-1) { if (fd != fd_) { if (valid()) { adb_close(fd_); } fd_ = fd; } } int Release() { int temp = fd_; fd_ = -1; return temp; } bool valid() const { return fd_ >= 0; } int fd() const { return fd_; } private: int fd_ = -1; DISALLOW_COPY_AND_ASSIGN(ScopedFd); }; // Creates a socketpair and saves the endpoints to |fd1| and |fd2|. bool CreateSocketpair(ScopedFd* fd1, ScopedFd* fd2) { int sockets[2]; Loading adb/sysdeps.h +1 −2 Original line number Diff line number Diff line Loading @@ -576,8 +576,7 @@ static __inline__ int adb_shutdown(int fd, int direction) // Closes a file descriptor that came from adb_open() or adb_open_mode(), but // not designed to take a file descriptor from unix_open(). See the comments // for adb_open() for more info. static __inline__ int adb_close(int fd) { __inline__ int adb_close(int fd) { return close(fd); } #undef close Loading Loading
adb/adb_utils.h +43 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <string> #include <android-base/macros.h> void close_stdin(); bool getcwd(std::string* cwd); Loading @@ -39,4 +41,45 @@ std::string perror_str(const char* msg); bool set_file_block_mode(int fd, bool block); extern int adb_close(int fd); // Helper to automatically close an FD when it goes out of scope. class ScopedFd { public: ScopedFd() { } ~ScopedFd() { Reset(); } void Reset(int fd = -1) { if (fd != fd_) { if (valid()) { adb_close(fd_); } fd_ = fd; } } int Release() { int temp = fd_; fd_ = -1; return temp; } bool valid() const { return fd_ >= 0; } int fd() const { return fd_; } private: int fd_ = -1; DISALLOW_COPY_AND_ASSIGN(ScopedFd); }; #endif
adb/shell_service.cpp +0 −31 Original line number Diff line number Diff line Loading @@ -135,37 +135,6 @@ std::string ReadAll(int fd) { return received; } // Helper to automatically close an FD when it goes out of scope. class ScopedFd { public: ScopedFd() {} ~ScopedFd() { Reset(); } void Reset(int fd=-1) { if (fd != fd_) { if (valid()) { adb_close(fd_); } fd_ = fd; } } int Release() { int temp = fd_; fd_ = -1; return temp; } bool valid() const { return fd_ >= 0; } int fd() const { return fd_; } private: int fd_ = -1; DISALLOW_COPY_AND_ASSIGN(ScopedFd); }; // Creates a socketpair and saves the endpoints to |fd1| and |fd2|. bool CreateSocketpair(ScopedFd* fd1, ScopedFd* fd2) { int sockets[2]; Loading
adb/sysdeps.h +1 −2 Original line number Diff line number Diff line Loading @@ -576,8 +576,7 @@ static __inline__ int adb_shutdown(int fd, int direction) // Closes a file descriptor that came from adb_open() or adb_open_mode(), but // not designed to take a file descriptor from unix_open(). See the comments // for adb_open() for more info. static __inline__ int adb_close(int fd) { __inline__ int adb_close(int fd) { return close(fd); } #undef close Loading