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 <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <fnmatch.h> | 9 #include <fnmatch.h> |
10 #include <fts.h> | 10 #include <fts.h> |
11 #include <libgen.h> | 11 #include <libgen.h> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #include <sys/errno.h> | 14 #include <sys/errno.h> |
15 #include <sys/mman.h> | 15 #include <sys/mman.h> |
16 #include <sys/stat.h> | 16 #include <sys/stat.h> |
17 #include <time.h> | 17 #include <time.h> |
18 | 18 |
19 #include <fstream> | 19 #include <fstream> |
20 | 20 |
21 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
22 #include "base/file_path.h" | 22 #include "base/file_path.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 | 25 |
26 namespace file_util { | 26 namespace file_util { |
27 | 27 |
| 28 #if defined(GOOGLE_CHROME_BUILD) |
28 static const char* kTempFileName = "com.google.chrome.XXXXXX"; | 29 static const char* kTempFileName = "com.google.chrome.XXXXXX"; |
| 30 #else |
| 31 static const char* kTempFileName = "org.chromium.XXXXXX"; |
| 32 #endif |
29 | 33 |
30 std::wstring GetDirectoryFromPath(const std::wstring& path) { | 34 std::wstring GetDirectoryFromPath(const std::wstring& path) { |
31 if (EndsWithSeparator(path)) { | 35 if (EndsWithSeparator(path)) { |
32 std::wstring dir = path; | 36 std::wstring dir = path; |
33 TrimTrailingSeparator(&dir); | 37 TrimTrailingSeparator(&dir); |
34 return dir; | 38 return dir; |
35 } else { | 39 } else { |
36 char full_path[PATH_MAX]; | 40 char full_path[PATH_MAX]; |
37 base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path)); | 41 base::strlcpy(full_path, WideToUTF8(path).c_str(), arraysize(full_path)); |
38 return UTF8ToWide(dirname(full_path)); | 42 return UTF8ToWide(dirname(full_path)); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 munmap(data_, length_); | 584 munmap(data_, length_); |
581 if (file_ != -1) | 585 if (file_ != -1) |
582 close(file_); | 586 close(file_); |
583 | 587 |
584 data_ = NULL; | 588 data_ = NULL; |
585 length_ = 0; | 589 length_ = 0; |
586 file_ = -1; | 590 file_ = -1; |
587 } | 591 } |
588 | 592 |
589 } // namespace file_util | 593 } // namespace file_util |
OLD | NEW |