Index: base/file_util_posix.cc |
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc |
index 39b29b3e26bf7dcdb1aae8c389c0d437e41a2f5a..3d4c545aec5ac85b8aab0416d8c26651482c544f 100644 |
--- a/base/file_util_posix.cc |
+++ b/base/file_util_posix.cc |
@@ -739,6 +739,39 @@ int WriteFileDescriptor(const int fd, const char* data, int size) { |
return bytes_written_total; |
} |
+int AppendToFile(const FilePath& filename, const char* data, int size) { |
+ ThreadRestrictions::AssertIOAllowed(); |
+ int fd = HANDLE_EINTR(open(filename.value().c_str(), O_WRONLY | O_APPEND)); |
+ if (fd < 0) |
+ return -1; |
+ |
+ int bytes_written = WriteFileDescriptor(fd, data, size); |
+ if (int ret = IGNORE_EINTR(close(fd)) < 0) |
+ return ret; |
+ return bytes_written; |
+} |
+ |
+// Gets the current working directory for the process. |
+bool GetCurrentDirectory(FilePath* dir) { |
+ // getcwd can return ENOENT, which implies it checks against the disk. |
+ ThreadRestrictions::AssertIOAllowed(); |
+ |
+ char system_buffer[PATH_MAX] = ""; |
+ if (!getcwd(system_buffer, sizeof(system_buffer))) { |
+ NOTREACHED(); |
+ return false; |
+ } |
+ *dir = FilePath(system_buffer); |
+ return true; |
+} |
+ |
+// Sets the current working directory for the process. |
+bool SetCurrentDirectory(const FilePath& path) { |
+ ThreadRestrictions::AssertIOAllowed(); |
+ int ret = chdir(path.value().c_str()); |
+ return !ret; |
+} |
+ |
} // namespace base |
// ----------------------------------------------------------------------------- |
@@ -777,39 +810,6 @@ FILE* OpenFile(const std::string& filename, const char* mode) { |
return OpenFile(FilePath(filename), mode); |
} |
-int AppendToFile(const FilePath& filename, const char* data, int size) { |
- base::ThreadRestrictions::AssertIOAllowed(); |
- int fd = HANDLE_EINTR(open(filename.value().c_str(), O_WRONLY | O_APPEND)); |
- if (fd < 0) |
- return -1; |
- |
- int bytes_written = base::WriteFileDescriptor(fd, data, size); |
- if (int ret = IGNORE_EINTR(close(fd)) < 0) |
- return ret; |
- return bytes_written; |
-} |
- |
-// Gets the current working directory for the process. |
-bool GetCurrentDirectory(FilePath* dir) { |
- // getcwd can return ENOENT, which implies it checks against the disk. |
- base::ThreadRestrictions::AssertIOAllowed(); |
- |
- char system_buffer[PATH_MAX] = ""; |
- if (!getcwd(system_buffer, sizeof(system_buffer))) { |
- NOTREACHED(); |
- return false; |
- } |
- *dir = FilePath(system_buffer); |
- return true; |
-} |
- |
-// Sets the current working directory for the process. |
-bool SetCurrentDirectory(const FilePath& path) { |
- base::ThreadRestrictions::AssertIOAllowed(); |
- int ret = chdir(path.value().c_str()); |
- return !ret; |
-} |
- |
bool VerifyPathControlledByUser(const FilePath& base, |
const FilePath& path, |
uid_t owner_uid, |