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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_path.h" | |
9 #include "webkit/fileapi/file_system_types.h" | 10 #include "webkit/fileapi/file_system_types.h" |
10 #include "webkit/quota/quota_types.h" | 11 #include "webkit/quota/quota_types.h" |
11 | 12 |
12 class FilePath; | |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace fileapi { | 15 namespace fileapi { |
16 | 16 |
17 extern const char kPersistentDir[]; | 17 extern const char kPersistentDir[]; |
18 extern const char kTemporaryDir[]; | 18 extern const char kTemporaryDir[]; |
19 extern const char kExternalDir[]; | 19 extern const char kExternalDir[]; |
20 extern const char kPersistentName[]; | 20 extern const char kPersistentName[]; |
21 extern const char kTemporaryName[]; | 21 extern const char kTemporaryName[]; |
22 extern const char kExternalName[]; | 22 extern const char kExternalName[]; |
23 | 23 |
24 // Cracks the given filesystem |url| and populates |origin_url|, |type| | 24 // Cracks the given filesystem |url| and populates |origin_url|, |type| |
25 // and |file_path|. Returns true if the given |url| is a valid filesystem | 25 // and |file_path|. Returns true if the given |url| is a valid filesystem |
26 // url and the routine could successfully crack it, returns false otherwise. | 26 // url and the routine could successfully crack it, returns false otherwise. |
27 // The file_path this returns will be using '/' as a path separator, no matter | 27 // The file_path this returns will be using '/' as a path separator, no matter |
28 // what platform you're on. | 28 // what platform you're on. |
kinuko
2012/02/28 19:28:02
Let's add TODO here to explicitly note that file_p
ericu
2012/02/29 21:31:34
Done.
| |
29 bool CrackFileSystemURL(const GURL& url, | 29 bool CrackFileSystemURL(const GURL& url, |
30 GURL* origin_url, | 30 GURL* origin_url, |
31 FileSystemType* type, | 31 FileSystemType* type, |
32 FilePath* file_path); | 32 FilePath* file_path); |
33 | 33 |
34 // Use this instead of FilePath::BaseName when operating on virtual paths. | |
35 // FilePath::BaseName will get confused by ':' on Windows when it looks like a | |
36 // drive letter separator; this will treat it as just another character. | |
37 FilePath GetVirtualBaseName(const FilePath& virtual_path); | |
kinuko
2012/02/28 19:28:02
Could we group these methods into a static-methods
ericu
2012/02/29 21:31:34
OK. We might even expand on this if+when we switc
| |
38 | |
39 // Likewise, use this instead of FilePath::GetComponents when operating on | |
40 // virtual paths. | |
41 // Note that this assumes very clean input, with no leading slash, and it will | |
42 // not evaluate '.' or '..' components. | |
43 void GetVirtualComponents(const FilePath& path, | |
44 std::vector<FilePath::StringType>* components); | |
45 | |
34 // Returns the root URI of the filesystem that can be specified by a pair of | 46 // Returns the root URI of the filesystem that can be specified by a pair of |
35 // |origin_url| and |type|. The returned URI can be used as a root path | 47 // |origin_url| and |type|. The returned URI can be used as a root path |
36 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose | 48 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose |
37 // a path pointing to the entry "/relative/path" in the filesystem). | 49 // a path pointing to the entry "/relative/path" in the filesystem). |
38 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type); | 50 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type); |
39 | 51 |
40 // Returns the name for the filesystem that is specified by a pair of | 52 // Returns the name for the filesystem that is specified by a pair of |
41 // |origin_url| and |type|. | 53 // |origin_url| and |type|. |
42 // (The name itself is neither really significant nor a formal identifier | 54 // (The name itself is neither really significant nor a formal identifier |
43 // but can be read as the .name field of the returned FileSystem object | 55 // but can be read as the .name field of the returned FileSystem object |
(...skipping 23 matching lines...) Expand all Loading... | |
67 std::string GetOriginIdentifierFromURL(const GURL& url); | 79 std::string GetOriginIdentifierFromURL(const GURL& url); |
68 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier); | 80 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier); |
69 | 81 |
70 // Returns the string representation of the given filesystem |type|. | 82 // Returns the string representation of the given filesystem |type|. |
71 // Returns an empty string if the |type| is invalid. | 83 // Returns an empty string if the |type| is invalid. |
72 std::string GetFileSystemTypeString(FileSystemType type); | 84 std::string GetFileSystemTypeString(FileSystemType type); |
73 | 85 |
74 } // namespace fileapi | 86 } // namespace fileapi |
75 | 87 |
76 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ | 88 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |