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

Side by Side Diff: base/file_util.cc

Issue 93263002: Move some more file utils to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « base/file_util.h ('k') | base/file_util_android.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <io.h> 8 #include <io.h>
9 #endif 9 #endif
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 size_t len; 138 size_t len;
139 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { 139 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) {
140 if (contents) 140 if (contents)
141 contents->append(buf, len); 141 contents->append(buf, len);
142 } 142 }
143 file_util::CloseFile(file); 143 file_util::CloseFile(file);
144 144
145 return true; 145 return true;
146 } 146 }
147 147
148 bool IsDirectoryEmpty(const FilePath& dir_path) {
149 FileEnumerator files(dir_path, false,
150 FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
151 if (files.Next().empty())
152 return true;
153 return false;
154 }
155
148 } // namespace base 156 } // namespace base
149 157
150 // ----------------------------------------------------------------------------- 158 // -----------------------------------------------------------------------------
151 159
152 namespace file_util { 160 namespace file_util {
153 161
154 using base::FileEnumerator; 162 using base::FileEnumerator;
155 using base::FilePath; 163 using base::FilePath;
156 using base::kMaxUniqueFiles; 164 using base::kMaxUniqueFiles;
157 165
158 bool IsDirectoryEmpty(const FilePath& dir_path) {
159 FileEnumerator files(dir_path, false,
160 FileEnumerator::FILES | FileEnumerator::DIRECTORIES);
161 if (files.Next().empty())
162 return true;
163 return false;
164 }
165
166 FILE* CreateAndOpenTemporaryFile(FilePath* path) { 166 FILE* CreateAndOpenTemporaryFile(FilePath* path) {
167 FilePath directory; 167 FilePath directory;
168 if (!GetTempDir(&directory)) 168 if (!GetTempDir(&directory))
169 return NULL; 169 return NULL;
170 170
171 return CreateAndOpenTemporaryFileInDir(directory, path); 171 return CreateAndOpenTemporaryFileInDir(directory, path);
172 } 172 }
173 173
174 bool CreateDirectory(const base::FilePath& full_path) { 174 bool CreateDirectory(const base::FilePath& full_path) {
175 return CreateDirectoryAndGetError(full_path, NULL); 175 return CreateDirectoryAndGetError(full_path, NULL);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!PathExists(new_path) && 250 if (!PathExists(new_path) &&
251 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { 251 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) {
252 return count; 252 return count;
253 } 253 }
254 } 254 }
255 255
256 return -1; 256 return -1;
257 } 257 }
258 258
259 } // namespace file_util 259 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698