Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
| 6 // filesystem. | 6 // filesystem. |
| 7 | 7 |
| 8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
| 9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 public: | 431 public: |
| 432 inline void operator()(FILE* x) const { | 432 inline void operator()(FILE* x) const { |
| 433 if (x) { | 433 if (x) { |
| 434 fclose(x); | 434 fclose(x); |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 }; | 437 }; |
| 438 | 438 |
| 439 typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE; | 439 typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE; |
| 440 | 440 |
| 441 // A class to handle auto-deleting a directory. | |
|
Mark Mentovai
2012/02/07 19:36:42
Would ScopedTempDir (base/scoped_temp_dir.h) work
jeremy
2012/02/09 10:52:51
Done.
| |
| 442 class ScopedDirectoryDelete { | |
| 443 public: | |
| 444 inline void operator()(FilePath* x) const { | |
| 445 if (x) { | |
| 446 file_util::Delete(*x, true); | |
| 447 } | |
| 448 } | |
| 449 }; | |
| 450 | |
| 451 typedef scoped_ptr_malloc<FilePath, ScopedDirectoryDelete> ScopedDirectory; | |
| 452 | |
| 441 #if defined(OS_POSIX) | 453 #if defined(OS_POSIX) |
| 442 // A class to handle auto-closing of FDs. | 454 // A class to handle auto-closing of FDs. |
| 443 class ScopedFDClose { | 455 class ScopedFDClose { |
| 444 public: | 456 public: |
| 445 inline void operator()(int* x) const { | 457 inline void operator()(int* x) const { |
| 446 if (x && *x >= 0) { | 458 if (x && *x >= 0) { |
| 447 if (HANDLE_EINTR(close(*x)) < 0) | 459 if (HANDLE_EINTR(close(*x)) < 0) |
| 448 DPLOG(ERROR) << "close"; | 460 DPLOG(ERROR) << "close"; |
| 449 } | 461 } |
| 450 } | 462 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 659 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
| 648 #endif | 660 #endif |
| 649 | 661 |
| 650 } // namespace file_util | 662 } // namespace file_util |
| 651 | 663 |
| 652 // Deprecated functions have been moved to this separate header file, | 664 // Deprecated functions have been moved to this separate header file, |
| 653 // which must be included last after all the above definitions. | 665 // which must be included last after all the above definitions. |
| 654 #include "base/file_util_deprecated.h" | 666 #include "base/file_util_deprecated.h" |
| 655 | 667 |
| 656 #endif // BASE_FILE_UTIL_H_ | 668 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |