| OLD | NEW |
| 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 // 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 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "base/basictypes.h" | 28 #include "base/basictypes.h" |
| 29 #include "base/file_path.h" | 29 #include "base/file_path.h" |
| 30 #include "base/platform_file.h" | 30 #include "base/platform_file.h" |
| 31 #include "base/scoped_ptr.h" | 31 #include "base/scoped_ptr.h" |
| 32 #include "base/string16.h" | 32 #include "base/string16.h" |
| 33 #include "base/time.h" | 33 #include "base/time.h" |
| 34 | 34 |
| 35 #if defined(OS_POSIX) | 35 #if defined(OS_POSIX) |
| 36 #include "base/eintr_wrapper.h" | 36 #include "base/eintr_wrapper.h" |
| 37 #include "base/file_descriptor_posix.h" | 37 #include "base/file_descriptor_posix.h" |
| 38 #include "base/logging.h" | |
| 39 #endif | 38 #endif |
| 40 | 39 |
| 41 namespace base { | 40 namespace base { |
| 42 class Time; | 41 class Time; |
| 43 } | 42 } |
| 44 | 43 |
| 45 namespace file_util { | 44 namespace file_util { |
| 46 | 45 |
| 47 //----------------------------------------------------------------------------- | 46 //----------------------------------------------------------------------------- |
| 48 // Functions that operate purely on a path string w/o touching the filesystem: | 47 // Functions that operate purely on a path string w/o touching the filesystem: |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 }; | 370 }; |
| 372 | 371 |
| 373 typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE; | 372 typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE; |
| 374 | 373 |
| 375 #if defined(OS_POSIX) | 374 #if defined(OS_POSIX) |
| 376 // A class to handle auto-closing of FDs. | 375 // A class to handle auto-closing of FDs. |
| 377 class ScopedFDClose { | 376 class ScopedFDClose { |
| 378 public: | 377 public: |
| 379 inline void operator()(int* x) const { | 378 inline void operator()(int* x) const { |
| 380 if (x && *x >= 0) { | 379 if (x && *x >= 0) { |
| 381 if (HANDLE_EINTR(close(*x)) < 0) | 380 HANDLE_EINTR(close(*x)); |
| 382 PLOG(ERROR) << "close"; | |
| 383 } | 381 } |
| 384 } | 382 } |
| 385 }; | 383 }; |
| 386 | 384 |
| 387 typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD; | 385 typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD; |
| 388 #endif // OS_POSIX | 386 #endif // OS_POSIX |
| 389 | 387 |
| 390 // A class for enumerating the files in a provided path. The order of the | 388 // A class for enumerating the files in a provided path. The order of the |
| 391 // results is not guaranteed. | 389 // results is not guaranteed. |
| 392 // | 390 // |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 596 |
| 599 #endif // UNIT_TEST | 597 #endif // UNIT_TEST |
| 600 | 598 |
| 601 } // namespace file_util | 599 } // namespace file_util |
| 602 | 600 |
| 603 // Deprecated functions have been moved to this separate header file, | 601 // Deprecated functions have been moved to this separate header file, |
| 604 // which must be included last after all the above definitions. | 602 // which must be included last after all the above definitions. |
| 605 #include "base/file_util_deprecated.h" | 603 #include "base/file_util_deprecated.h" |
| 606 | 604 |
| 607 #endif // BASE_FILE_UTIL_H_ | 605 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |