summaryrefslogtreecommitdiffstats
path: root/base/file_util_posix.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-17 21:01:19 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-17 21:01:19 +0000
commita9cd2a6531ed01e92ee81b136754ba00165c58cd (patch)
tree8bb8dc02ff53d9219cf8c879aaa397ac9d2709fc /base/file_util_posix.cc
parent9ebffa3ea23c296d83863231eb0d58e01a56d439 (diff)
downloadchromium_src-a9cd2a6531ed01e92ee81b136754ba00165c58cd.zip
chromium_src-a9cd2a6531ed01e92ee81b136754ba00165c58cd.tar.gz
chromium_src-a9cd2a6531ed01e92ee81b136754ba00165c58cd.tar.bz2
Implement some missing file util functions.
Review URL: http://codereview.chromium.org/11208 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r--base/file_util_posix.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index a0c6cb6..1afb573 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -322,18 +322,18 @@ bool GetFileInfo(const FilePath& file_path, FileInfo* results) {
}
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 @@ int WriteFile(const std::wstring& filename, const char* data, int size) {
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 @@ bool GetCurrentDirectory(FilePath* dir) {
}
// 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 @@ FileEnumerator::FileEnumerator(const std::wstring& root_path,
AppendToPath(&pattern_, pattern);
pending_paths_.push(root_path);
}
-
+
FileEnumerator::~FileEnumerator() {
if (fts_)
fts_close(fts_);