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

Side by Side Diff: base/file_util_posix.cc

Issue 2662005: Changing temporary files on posix to have a . in front so they are hidden on ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 #else 68 #else
69 typedef struct stat64 stat_wrapper_t; 69 typedef struct stat64 stat_wrapper_t;
70 static int CallStat(const char *path, stat_wrapper_t *sb) { 70 static int CallStat(const char *path, stat_wrapper_t *sb) {
71 return stat64(path, sb); 71 return stat64(path, sb);
72 } 72 }
73 #endif 73 #endif
74 74
75 75
76 #if defined(GOOGLE_CHROME_BUILD) 76 #if defined(GOOGLE_CHROME_BUILD)
77 static const char* kTempFileName = "com.google.chrome.XXXXXX"; 77 static const char* kTempFileName = ".com.google.chrome.XXXXXX";
78 #else 78 #else
79 static const char* kTempFileName = "org.chromium.XXXXXX"; 79 static const char* kTempFileName = ".org.chromium.XXXXXX";
80 #endif 80 #endif
81 81
82 bool AbsolutePath(FilePath* path) { 82 bool AbsolutePath(FilePath* path) {
83 char full_path[PATH_MAX]; 83 char full_path[PATH_MAX];
84 if (realpath(path->value().c_str(), full_path) == NULL) 84 if (realpath(path->value().c_str(), full_path) == NULL)
85 return false; 85 return false;
86 *path = FilePath(full_path); 86 *path = FilePath(full_path);
87 return true; 87 return true;
88 } 88 }
89 89
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 directories.push(current.value()); 167 directories.push(current.value());
168 else 168 else
169 success = (unlink(current.value().c_str()) == 0); 169 success = (unlink(current.value().c_str()) == 0);
170 } 170 }
171 171
172 while (success && !directories.empty()) { 172 while (success && !directories.empty()) {
173 FilePath dir = FilePath(directories.top()); 173 FilePath dir = FilePath(directories.top());
174 directories.pop(); 174 directories.pop();
175 success = (rmdir(dir.value().c_str()) == 0); 175 success = (rmdir(dir.value().c_str()) == 0);
176 } 176 }
177
178 return success; 177 return success;
179 } 178 }
180 179
181 bool Move(const FilePath& from_path, const FilePath& to_path) { 180 bool Move(const FilePath& from_path, const FilePath& to_path) {
182 // Windows compatibility: if to_path exists, from_path and to_path 181 // Windows compatibility: if to_path exists, from_path and to_path
183 // must be the same type, either both files, or both directories. 182 // must be the same type, either both files, or both directories.
184 stat_wrapper_t to_file_info; 183 stat_wrapper_t to_file_info;
185 if (CallStat(to_path.value().c_str(), &to_file_info) == 0) { 184 if (CallStat(to_path.value().c_str(), &to_file_info) == 0) {
186 stat_wrapper_t from_file_info; 185 stat_wrapper_t from_file_info;
187 if (CallStat(from_path.value().c_str(), &from_file_info) == 0) { 186 if (CallStat(from_path.value().c_str(), &from_file_info) == 0) {
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 if (HANDLE_EINTR(close(infile)) < 0) 828 if (HANDLE_EINTR(close(infile)) < 0)
830 result = false; 829 result = false;
831 if (HANDLE_EINTR(close(outfile)) < 0) 830 if (HANDLE_EINTR(close(outfile)) < 0)
832 result = false; 831 result = false;
833 832
834 return result; 833 return result;
835 } 834 }
836 #endif // defined(OS_MACOSX) 835 #endif // defined(OS_MACOSX)
837 836
838 } // namespace file_util 837 } // namespace file_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698