Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: trunk/src/base/file_util_posix.cc

Issue 105823009: Revert 239280 "Move more file_util functions to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/base/file_util.cc ('k') | trunk/src/base/file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/base/file_util_posix.cc
===================================================================
--- trunk/src/base/file_util_posix.cc (revision 239399)
+++ trunk/src/base/file_util_posix.cc (working copy)
@@ -689,27 +689,6 @@
return true;
}
-FILE* OpenFile(const FilePath& filename, const char* mode) {
- ThreadRestrictions::AssertIOAllowed();
- FILE* result = NULL;
- do {
- result = fopen(filename.value().c_str(), mode);
- } while (!result && errno == EINTR);
- return result;
-}
-
-int ReadFile(const FilePath& filename, char* data, int size) {
- ThreadRestrictions::AssertIOAllowed();
- int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY));
- if (fd < 0)
- return -1;
-
- ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size));
- if (int ret = IGNORE_EINTR(close(fd)) < 0)
- return ret;
- return bytes_read;
-}
-
} // namespace base
// -----------------------------------------------------------------------------
@@ -744,10 +723,42 @@
return base::FilePath();
}
+bool GetInode(const FilePath& path, ino_t* inode) {
+ base::ThreadRestrictions::AssertIOAllowed(); // For call to stat().
+ struct stat buffer;
+ int result = stat(path.value().c_str(), &buffer);
+ if (result < 0)
+ return false;
+
+ *inode = buffer.st_ino;
+ return true;
+}
+
FILE* OpenFile(const std::string& filename, const char* mode) {
return OpenFile(FilePath(filename), mode);
}
+FILE* OpenFile(const FilePath& filename, const char* mode) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ FILE* result = NULL;
+ do {
+ result = fopen(filename.value().c_str(), mode);
+ } while (!result && errno == EINTR);
+ return result;
+}
+
+int ReadFile(const FilePath& filename, char* data, int size) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY));
+ if (fd < 0)
+ return -1;
+
+ ssize_t bytes_read = HANDLE_EINTR(read(fd, data, size));
+ if (int ret = IGNORE_EINTR(close(fd)) < 0)
+ return ret;
+ return bytes_read;
+}
+
int WriteFile(const FilePath& filename, const char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
int fd = HANDLE_EINTR(creat(filename.value().c_str(), 0666));
« no previous file with comments | « trunk/src/base/file_util.cc ('k') | trunk/src/base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698