Move AppendFile and *CurrentDirectory to the base namespace.
This moves AppendFile, GetCurrentDirectory, and SetCurrentDirectory to the base namespace.
TBR=jam
Review URL: https://codereview.chromium.org/177923007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256309 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 37b3c199da23208121a946491ce749bafeb573c2
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 53c64da..db84c3f 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -739,6 +739,39 @@
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 @@
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,