| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 | 55 |
| 56 #if defined(GOOGLE_CHROME_BUILD) | 56 #if defined(GOOGLE_CHROME_BUILD) |
| 57 static const char* kTempFileName = "com.google.chrome.XXXXXX"; | 57 static const char* kTempFileName = "com.google.chrome.XXXXXX"; |
| 58 #else | 58 #else |
| 59 static const char* kTempFileName = "org.chromium.XXXXXX"; | 59 static const char* kTempFileName = "org.chromium.XXXXXX"; |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 std::wstring GetDirectoryFromPath(const std::wstring& path) { | 62 std::wstring GetDirectoryFromPath(const std::wstring& path) { |
| 63 if (EndsWithSeparator(path)) { | 63 if (EndsWithSeparator(path)) { |
| 64 std::wstring dir = path; | 64 return FilePath::FromWStringHack(path) |
| 65 TrimTrailingSeparator(&dir); | 65 .StripTrailingSeparators() |
| 66 return dir; | 66 .ToWStringHack(); |
| 67 } else { | 67 } else { |
| 68 char full_path[PATH_MAX]; | 68 char full_path[PATH_MAX]; |
| 69 base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path)); | 69 base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path)); |
| 70 return UTF8ToWide(dirname(full_path)); | 70 return UTF8ToWide(dirname(full_path)); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool AbsolutePath(FilePath* path) { | 74 bool AbsolutePath(FilePath* path) { |
| 75 char full_path[PATH_MAX]; | 75 char full_path[PATH_MAX]; |
| 76 if (realpath(path->value().c_str(), full_path) == NULL) | 76 if (realpath(path->value().c_str(), full_path) == NULL) |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 munmap(data_, length_); | 683 munmap(data_, length_); |
| 684 if (file_ != -1) | 684 if (file_ != -1) |
| 685 close(file_); | 685 close(file_); |
| 686 | 686 |
| 687 data_ = NULL; | 687 data_ = NULL; |
| 688 length_ = 0; | 688 length_ = 0; |
| 689 file_ = -1; | 689 file_ = -1; |
| 690 } | 690 } |
| 691 | 691 |
| 692 } // namespace file_util | 692 } // namespace file_util |
| OLD | NEW |