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

Side by Side Diff: base/file_util.cc

Issue 16241: file_util minor cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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_posix.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) 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <fstream> 9 #include <fstream>
10 10
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return ContentsEqual(FilePath::FromWStringHack(filename1), 328 return ContentsEqual(FilePath::FromWStringHack(filename1),
329 FilePath::FromWStringHack(filename2)); 329 FilePath::FromWStringHack(filename2));
330 } 330 }
331 bool CopyFile(const std::wstring& from_path, const std::wstring& to_path) { 331 bool CopyFile(const std::wstring& from_path, const std::wstring& to_path) {
332 return CopyFile(FilePath::FromWStringHack(from_path), 332 return CopyFile(FilePath::FromWStringHack(from_path),
333 FilePath::FromWStringHack(to_path)); 333 FilePath::FromWStringHack(to_path));
334 } 334 }
335 bool CreateDirectory(const std::wstring& full_path) { 335 bool CreateDirectory(const std::wstring& full_path) {
336 return CreateDirectory(FilePath::FromWStringHack(full_path)); 336 return CreateDirectory(FilePath::FromWStringHack(full_path));
337 } 337 }
338 bool CreateNewTempDirectory(const std::wstring& prefix,
339 std::wstring* new_temp_path) {
340 #if defined(OS_WIN)
341 FilePath::StringType dir_prefix(prefix);
342 #elif defined(OS_POSIX)
343 FilePath::StringType dir_prefix = WideToUTF8(prefix);
344 #endif
345 FilePath temp_path;
346 if (!CreateNewTempDirectory(dir_prefix, &temp_path))
347 return false;
348 *new_temp_path = temp_path.ToWStringHack();
349 return true;
350 }
338 bool CreateTemporaryFileName(std::wstring* temp_file) { 351 bool CreateTemporaryFileName(std::wstring* temp_file) {
339 FilePath temp_file_path; 352 FilePath temp_file_path;
340 if (!CreateTemporaryFileName(&temp_file_path)) 353 if (!CreateTemporaryFileName(&temp_file_path))
341 return false; 354 return false;
342 *temp_file = temp_file_path.ToWStringHack(); 355 *temp_file = temp_file_path.ToWStringHack();
343 return true; 356 return true;
344 } 357 }
345 bool Delete(const std::wstring& path, bool recursive) { 358 bool Delete(const std::wstring& path, bool recursive) {
346 return Delete(FilePath::FromWStringHack(path), recursive); 359 return Delete(FilePath::FromWStringHack(path), recursive);
347 } 360 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 bool Move(const std::wstring& from_path, const std::wstring& to_path) { 396 bool Move(const std::wstring& from_path, const std::wstring& to_path) {
384 return Move(FilePath::FromWStringHack(from_path), 397 return Move(FilePath::FromWStringHack(from_path),
385 FilePath::FromWStringHack(to_path)); 398 FilePath::FromWStringHack(to_path));
386 } 399 }
387 FILE* OpenFile(const std::wstring& filename, const char* mode) { 400 FILE* OpenFile(const std::wstring& filename, const char* mode) {
388 return OpenFile(FilePath::FromWStringHack(filename), mode); 401 return OpenFile(FilePath::FromWStringHack(filename), mode);
389 } 402 }
390 bool PathExists(const std::wstring& path) { 403 bool PathExists(const std::wstring& path) {
391 return PathExists(FilePath::FromWStringHack(path)); 404 return PathExists(FilePath::FromWStringHack(path));
392 } 405 }
406 bool PathIsWritable(const std::wstring& path) {
407 return PathIsWritable(FilePath::FromWStringHack(path));
408 }
393 bool SetCurrentDirectory(const std::wstring& directory) { 409 bool SetCurrentDirectory(const std::wstring& directory) {
394 return SetCurrentDirectory(FilePath::FromWStringHack(directory)); 410 return SetCurrentDirectory(FilePath::FromWStringHack(directory));
395 } 411 }
396 void TrimFilename(std::wstring* path) { 412 void TrimFilename(std::wstring* path) {
397 if (EndsWithSeparator(path)) { 413 if (EndsWithSeparator(path)) {
398 TrimTrailingSeparator(path); 414 TrimTrailingSeparator(path);
399 } else { 415 } else {
400 *path = FilePath::FromWStringHack(*path).DirName().ToWStringHack(); 416 *path = FilePath::FromWStringHack(*path).DirName().ToWStringHack();
401 } 417 }
402 } 418 }
(...skipping 10 matching lines...) Expand all
413 FilePath directory = path.DirName(); 429 FilePath directory = path.DirName();
414 // If there is no separator, we will get back kCurrentDirectory. 430 // If there is no separator, we will get back kCurrentDirectory.
415 // In this case, clear dir. 431 // In this case, clear dir.
416 if (directory == path || directory.value() == FilePath::kCurrentDirectory) 432 if (directory == path || directory.value() == FilePath::kCurrentDirectory)
417 dir->clear(); 433 dir->clear();
418 else 434 else
419 *dir = directory.ToWStringHack(); 435 *dir = directory.ToWStringHack();
420 } 436 }
421 } // namespace 437 } // namespace
422 438
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698