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 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileError.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/quota/quota_types.h" | 15 #include "webkit/quota/quota_types.h" |
16 #include "webkit/storage/webkit_storage_export.h" | 16 #include "webkit/storage/webkit_storage_export.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 | 19 |
20 namespace fileapi { | 20 namespace fileapi { |
21 | 21 |
22 extern const char kPersistentDir[]; | 22 extern const char kPersistentDir[]; |
23 extern const char kTemporaryDir[]; | 23 extern const char kTemporaryDir[]; |
24 extern const char kExternalDir[]; | 24 extern const char kExternalDir[]; |
25 extern const char kIsolatedDir[]; | 25 extern const char kIsolatedDir[]; |
26 extern const char kTestDir[]; | 26 extern const char kTestDir[]; |
27 | 27 |
28 class WEBKIT_STORAGE_EXPORT VirtualPath { | 28 class WEBKIT_STORAGE_EXPORT VirtualPath { |
29 public: | 29 public: |
30 static const FilePath::CharType kRoot[]; | 30 static const base::FilePath::CharType kRoot[]; |
31 static const FilePath::CharType kSeparator; | 31 static const base::FilePath::CharType kSeparator; |
32 | 32 |
33 // Use this instead of base::FilePath::BaseName when operating on virtual | 33 // Use this instead of base::FilePath::BaseName when operating on virtual |
34 // paths. base::FilePath::BaseName will get confused by ':' on Windows when it | 34 // paths. FilePath::BaseName will get confused by ':' on Windows when it |
35 // looks like a drive letter separator; this will treat it as just another | 35 // looks like a drive letter separator; this will treat it as just another |
36 // character. | 36 // character. |
37 static base::FilePath BaseName(const base::FilePath& virtual_path); | 37 static base::FilePath BaseName(const base::FilePath& virtual_path); |
38 | 38 |
39 // Likewise, use this instead of base::FilePath::GetComponents when operating
on | 39 // Likewise, use this instead of base::FilePath::GetComponents when operating
on |
40 // virtual paths. | 40 // virtual paths. |
41 // Note that this assumes very clean input, with no leading slash, and it will | 41 // Note that this assumes very clean input, with no leading slash, and it will |
42 // not evaluate '.' or '..' components. | 42 // not evaluate '.' or '..' components. |
43 static void GetComponents(const base::FilePath& path, | 43 static void GetComponents(const base::FilePath& path, |
44 std::vector<base::FilePath::StringType>* components); | 44 std::vector<base::FilePath::StringType>* components); |
45 | 45 |
46 // Returns a path name ensuring that it begins with kRoot and all path | 46 // Returns a path name ensuring that it begins with kRoot and all path |
47 // separators are forward slashes /. | 47 // separators are forward slashes /. |
48 static FilePath::StringType GetNormalizedFilePath(const FilePath& path); | 48 static base::FilePath::StringType GetNormalizedFilePath( |
| 49 const base::FilePath& path); |
49 | 50 |
50 // Returns true if the given path begins with kRoot. | 51 // Returns true if the given path begins with kRoot. |
51 static bool IsAbsolute(const FilePath::StringType& path); | 52 static bool IsAbsolute(const base::FilePath::StringType& path); |
52 }; | 53 }; |
53 | 54 |
54 // Returns the root URI of the filesystem that can be specified by a pair of | 55 // Returns the root URI of the filesystem that can be specified by a pair of |
55 // |origin_url| and |type|. The returned URI can be used as a root path | 56 // |origin_url| and |type|. The returned URI can be used as a root path |
56 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose | 57 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose |
57 // a path pointing to the entry "/relative/path" in the filesystem). | 58 // a path pointing to the entry "/relative/path" in the filesystem). |
58 // | 59 // |
59 // For Isolated filesystem this returns the 'common' root part, e.g. | 60 // For Isolated filesystem this returns the 'common' root part, e.g. |
60 // returns URL without the filesystem ID. | 61 // returns URL without the filesystem ID. |
61 // | 62 // |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // and |filesystem_id|. If the |optional_root_name| is given the resulting | 145 // and |filesystem_id|. If the |optional_root_name| is given the resulting |
145 // root URI will point to the subfolder within the isolated filesystem. | 146 // root URI will point to the subfolder within the isolated filesystem. |
146 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( | 147 WEBKIT_STORAGE_EXPORT std::string GetIsolatedFileSystemRootURIString( |
147 const GURL& origin_url, | 148 const GURL& origin_url, |
148 const std::string& filesystem_id, | 149 const std::string& filesystem_id, |
149 const std::string& optional_root_name); | 150 const std::string& optional_root_name); |
150 | 151 |
151 } // namespace fileapi | 152 } // namespace fileapi |
152 | 153 |
153 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 154 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |