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

Side by Side Diff: base/file_util.h

Issue 168643002: Convert scoped_ptr_malloc -> scoped_ptr, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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/debug/stack_trace_posix.cc ('k') | base/file_version_info_win.h » ('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 // 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // the filesystem, are owned by the superuser, controlled by the group 384 // the filesystem, are owned by the superuser, controlled by the group
385 // "admin", are not writable by all users, and contain no symbolic links. 385 // "admin", are not writable by all users, and contain no symbolic links.
386 // Will return false if |path| does not exist. 386 // Will return false if |path| does not exist.
387 BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); 387 BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path);
388 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 388 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
389 389
390 // Returns the maximum length of path component on the volume containing 390 // Returns the maximum length of path component on the volume containing
391 // the directory |path|, in the number of FilePath::CharType, or -1 on failure. 391 // the directory |path|, in the number of FilePath::CharType, or -1 on failure.
392 BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path); 392 BASE_EXPORT int GetMaximumPathComponentLength(const base::FilePath& path);
393 393
394 // A class to handle auto-closing of FILE*'s. 394 // Functor for |ScopedFILE| (below).
395 class ScopedFILEClose { 395 struct ScopedFILEClose {
396 public:
397 inline void operator()(FILE* x) const { 396 inline void operator()(FILE* x) const {
398 if (x) { 397 if (x)
399 fclose(x); 398 fclose(x);
400 }
401 } 399 }
402 }; 400 };
403 401
404 typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE; 402 // Automatically closes |FILE*|s.
403 typedef scoped_ptr<FILE, ScopedFILEClose> ScopedFILE;
405 404
406 #if defined(OS_POSIX) 405 #if defined(OS_POSIX)
407 // A class to handle auto-closing of FDs. 406 // Functor for |ScopedFD| (below).
408 class ScopedFDClose { 407 struct ScopedFDClose {
409 public:
410 inline void operator()(int* x) const { 408 inline void operator()(int* x) const {
411 if (x && *x >= 0) { 409 if (x && *x >= 0) {
412 if (IGNORE_EINTR(close(*x)) < 0) 410 if (IGNORE_EINTR(close(*x)) < 0)
413 DPLOG(ERROR) << "close"; 411 DPLOG(ERROR) << "close";
414 } 412 }
415 } 413 }
416 }; 414 };
417 415
418 typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD; 416 // Automatically closes FDs (note: doesn't store the FD).
417 // TODO(viettrungluu): This is a very odd API, since (unlike |FILE*|s, you'll
418 // need to store the FD separately and keep its memory alive). This should
419 // probably be called |ScopedFDCloser| or something like that.
420 typedef scoped_ptr<int, ScopedFDClose> ScopedFD;
419 #endif // OS_POSIX 421 #endif // OS_POSIX
420 422
421 #if defined(OS_LINUX) 423 #if defined(OS_LINUX)
422 // Broad categories of file systems as returned by statfs() on Linux. 424 // Broad categories of file systems as returned by statfs() on Linux.
423 enum FileSystemType { 425 enum FileSystemType {
424 FILE_SYSTEM_UNKNOWN, // statfs failed. 426 FILE_SYSTEM_UNKNOWN, // statfs failed.
425 FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS. 427 FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS.
426 FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2 428 FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2
427 FILE_SYSTEM_NFS, 429 FILE_SYSTEM_NFS,
428 FILE_SYSTEM_SMB, 430 FILE_SYSTEM_SMB,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // This function simulates Move(), but unlike Move() it works across volumes. 464 // This function simulates Move(), but unlike Move() it works across volumes.
463 // This function is not transactional. 465 // This function is not transactional.
464 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, 466 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
465 const FilePath& to_path); 467 const FilePath& to_path);
466 #endif // defined(OS_WIN) 468 #endif // defined(OS_WIN)
467 469
468 } // namespace internal 470 } // namespace internal
469 } // namespace base 471 } // namespace base
470 472
471 #endif // BASE_FILE_UTIL_H_ 473 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/debug/stack_trace_posix.cc ('k') | base/file_version_info_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698