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

Side by Side Diff: base/file_util.h

Issue 9316004: Move common file path related methods between chrome & content to file_util. I reduced the 4 meth... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 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 | « no previous file | base/file_util.cc » ('j') | base/file_util.cc » ('J')
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 #pragma once 10 #pragma once
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 BASE_EXPORT bool EnsureEndsWithSeparator(FilePath* path); 55 BASE_EXPORT bool EnsureEndsWithSeparator(FilePath* path);
56 56
57 // Convert provided relative path into an absolute path. Returns false on 57 // Convert provided relative path into an absolute path. Returns false on
58 // error. On POSIX, this function fails if the path does not exist. 58 // error. On POSIX, this function fails if the path does not exist.
59 BASE_EXPORT bool AbsolutePath(FilePath* path); 59 BASE_EXPORT bool AbsolutePath(FilePath* path);
60 60
61 // Returns true if |parent| contains |child|. Both paths are converted to 61 // Returns true if |parent| contains |child|. Both paths are converted to
62 // absolute paths before doing the comparison. 62 // absolute paths before doing the comparison.
63 BASE_EXPORT bool ContainsPath(const FilePath& parent, const FilePath& child); 63 BASE_EXPORT bool ContainsPath(const FilePath& parent, const FilePath& child);
64 64
65 // Appends the passed-in |number| between parenthesis to the |path| before
66 // the file extension.
67 BASE_EXPORT void AppendNumberToPath(FilePath* path, int number);
68
69 // Appends the passed-in |suffix| to the |path|.
70 BASE_EXPORT FilePath AppendSuffixToPath(const FilePath& path,
71 const FilePath::StringType& suffix);
Evan Martin 2012/01/31 21:23:44 Why does one of these take a FilePath* and the oth
72
65 //----------------------------------------------------------------------------- 73 //-----------------------------------------------------------------------------
66 // Functions that involve filesystem access or modification: 74 // Functions that involve filesystem access or modification:
67 75
68 // Returns the number of files matching the current path that were 76 // Returns the number of files matching the current path that were
69 // created on or after the given |file_time|. Doesn't count ".." or ".". 77 // created on or after the given |file_time|. Doesn't count ".." or ".".
70 // 78 //
71 // Note for POSIX environments: a file created before |file_time| 79 // Note for POSIX environments: a file created before |file_time|
72 // can be mis-detected as a newer file due to low precision of 80 // can be mis-detected as a newer file due to low precision of
73 // timestmap of file creation time. If you need to avoid such 81 // timestmap of file creation time. If you need to avoid such
74 // mis-detection perfectly, you should wait one second before 82 // mis-detection perfectly, you should wait one second before
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Append the data to |fd|. Does not close |fd| when done. 389 // Append the data to |fd|. Does not close |fd| when done.
382 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); 390 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size);
383 #endif 391 #endif
384 392
385 // Gets the current working directory for the process. 393 // Gets the current working directory for the process.
386 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); 394 BASE_EXPORT bool GetCurrentDirectory(FilePath* path);
387 395
388 // Sets the current working directory for the process. 396 // Sets the current working directory for the process.
389 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); 397 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path);
390 398
399 // Attempts to find a number that can be appended to the |path| to make it
400 // unique. If |path| does not exist, 0 is returned. If it fails to find such
401 // a number, -1 is returned. If |suffix| is not empty, also checks the
402 // existence of it with the given suffix.
403 BASE_EXPORT int GetUniquePathNumber(const FilePath& path,
404 const FilePath::StringType& suffix);
405
391 #if defined(OS_POSIX) 406 #if defined(OS_POSIX)
392 // Test that |path| can only be changed by a given user and members of 407 // Test that |path| can only be changed by a given user and members of
393 // a given set of groups. 408 // a given set of groups.
394 // Specifically, test that all parts of |path| under (and including) |base|: 409 // Specifically, test that all parts of |path| under (and including) |base|:
395 // * Exist. 410 // * Exist.
396 // * Are owned by a specific user. 411 // * Are owned by a specific user.
397 // * Are not writable by all users. 412 // * Are not writable by all users.
398 // * Are owned by a memeber of a given set of groups, or are not writable by 413 // * Are owned by a memeber of a given set of groups, or are not writable by
399 // their group. 414 // their group.
400 // * Are not symbolic links. 415 // * Are not symbolic links.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); 653 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
639 #endif 654 #endif
640 655
641 } // namespace file_util 656 } // namespace file_util
642 657
643 // Deprecated functions have been moved to this separate header file, 658 // Deprecated functions have been moved to this separate header file,
644 // which must be included last after all the above definitions. 659 // which must be included last after all the above definitions.
645 #include "base/file_util_deprecated.h" 660 #include "base/file_util_deprecated.h"
646 661
647 #endif // BASE_FILE_UTIL_H_ 662 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util.cc » ('j') | base/file_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698