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