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

Side by Side Diff: webkit/fileapi/file_system_util.h

Issue 9370045: Fixed bug: we can now handle "a:b" as a file name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Created 8 years, 9 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 | « webkit/fileapi/file_system_quota_unittest.cc ('k') | webkit/fileapi/file_system_util.cc » ('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 #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.
29 // TODO(ericu): Look into making file_path [and all FileSystem API virtual
30 // paths] just an std::string, to prevent platform-specific FilePath behavior
31 // from getting invoked by accident. Currently the FilePath returned here needs
32 // special treatment, as it may contain paths that are illegal on the current
33 // platform. To avoid problems, use VirtualPath::BaseName and
34 // VirtualPath::GetComponents instead of the FilePath methods.
29 bool CrackFileSystemURL(const GURL& url, 35 bool CrackFileSystemURL(const GURL& url,
30 GURL* origin_url, 36 GURL* origin_url,
31 FileSystemType* type, 37 FileSystemType* type,
32 FilePath* file_path); 38 FilePath* file_path);
33 39
40 class VirtualPath {
41 public:
42 // Use this instead of FilePath::BaseName when operating on virtual paths.
43 // FilePath::BaseName will get confused by ':' on Windows when it looks like a
44 // drive letter separator; this will treat it as just another character.
45 static FilePath BaseName(const FilePath& virtual_path);
46
47 // Likewise, use this instead of FilePath::GetComponents when operating on
48 // virtual paths.
49 // Note that this assumes very clean input, with no leading slash, and it will
50 // not evaluate '.' or '..' components.
51 static void GetComponents(const FilePath& path,
52 std::vector<FilePath::StringType>* components);
53 };
54
34 // 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
35 // |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
36 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose 57 // of the filesystem (e.g. <returned_URI> + "/relative/path" will compose
37 // a path pointing to the entry "/relative/path" in the filesystem). 58 // a path pointing to the entry "/relative/path" in the filesystem).
38 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type); 59 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type);
39 60
40 // Returns the name for the filesystem that is specified by a pair of 61 // Returns the name for the filesystem that is specified by a pair of
41 // |origin_url| and |type|. 62 // |origin_url| and |type|.
42 // (The name itself is neither really significant nor a formal identifier 63 // (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 64 // but can be read as the .name field of the returned FileSystem object
(...skipping 23 matching lines...) Expand all
67 std::string GetOriginIdentifierFromURL(const GURL& url); 88 std::string GetOriginIdentifierFromURL(const GURL& url);
68 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier); 89 GURL GetOriginURLFromIdentifier(const std::string& origin_identifier);
69 90
70 // Returns the string representation of the given filesystem |type|. 91 // Returns the string representation of the given filesystem |type|.
71 // Returns an empty string if the |type| is invalid. 92 // Returns an empty string if the |type| is invalid.
72 std::string GetFileSystemTypeString(FileSystemType type); 93 std::string GetFileSystemTypeString(FileSystemType type);
73 94
74 } // namespace fileapi 95 } // namespace fileapi
75 96
76 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_ 97 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_UTIL_H_
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_quota_unittest.cc ('k') | webkit/fileapi/file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698