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

Unified Diff: base/file_util_posix.cc

Issue 11208: Implement some missing file util functions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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 | « base/file_util_linux.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_posix.cc
===================================================================
--- base/file_util_posix.cc (revision 5562)
+++ base/file_util_posix.cc (working copy)
@@ -322,18 +322,18 @@
}
FILE* OpenFile(const std::string& filename, const char* mode) {
- return fopen(filename.c_str(), mode);
+ return OpenFile(FilePath(filename), mode);
}
-FILE* OpenFile(const std::wstring& filename, const char* mode) {
- return fopen(WideToUTF8(filename).c_str(), mode);
+FILE* OpenFile(const FilePath& filename, const char* mode) {
+ return fopen(filename.value().c_str(), mode);
}
int ReadFile(const std::wstring& filename, char* data, int size) {
int fd = open(WideToUTF8(filename).c_str(), O_RDONLY);
if (fd < 0)
return -1;
-
+
int ret_value = read(fd, data, size);
close(fd);
return ret_value;
@@ -352,7 +352,7 @@
size - bytes_written_total);
if (bytes_written_partial < 0) {
close(fd);
- return -1;
+ return -1;
}
bytes_written_total += bytes_written_partial;
} while (bytes_written_total < size);
@@ -373,11 +373,11 @@
}
// Sets the current working directory for the process.
-bool SetCurrentDirectory(const std::wstring& current_directory) {
- int ret = chdir(WideToUTF8(current_directory).c_str());
- return (ret == 0);
+bool SetCurrentDirectory(const FilePath& path) {
+ int ret = chdir(path.value().c_str());
+ return !ret;
}
-
+
FileEnumerator::FileEnumerator(const std::wstring& root_path,
bool recursive,
FileEnumerator::FILE_TYPE file_type)
@@ -403,7 +403,7 @@
AppendToPath(&pattern_, pattern);
pending_paths_.push(root_path);
}
-
+
FileEnumerator::~FileEnumerator() {
if (fts_)
fts_close(fts_);
« no previous file with comments | « base/file_util_linux.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698