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 CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "chrome/browser/chromeos/drive/drive_file_error.h" | 12 #include "chrome/browser/chromeos/drive/drive_file_error.h" |
13 #include "chrome/browser/google_apis/gdata_errorcode.h" | 13 #include "chrome/browser/google_apis/gdata_errorcode.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class FilePath; | 19 class FilePath; |
20 } | 20 } |
21 | 21 |
| 22 namespace fileapi { |
| 23 class FileSystemURL; |
| 24 } |
| 25 |
22 namespace drive { | 26 namespace drive { |
23 | 27 |
24 class PlatformFileInfoProto; | 28 class PlatformFileInfoProto; |
25 | 29 |
26 namespace util { | 30 namespace util { |
27 | 31 |
28 // Path constants. | 32 // Path constants. |
29 | 33 |
30 // The extension for dirty files. The file names look like | 34 // The extension for dirty files. The file names look like |
31 // "<resource-id>.local". | 35 // "<resource-id>.local". |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // migrated to the new namespace. http://crbug.com/174233. | 109 // migrated to the new namespace. http://crbug.com/174233. |
106 bool NeedsNamespaceMigration(const base::FilePath& path); | 110 bool NeedsNamespaceMigration(const base::FilePath& path); |
107 | 111 |
108 // Returns new FilePath with a namespace "root" inserted at the 3rd component. | 112 // Returns new FilePath with a namespace "root" inserted at the 3rd component. |
109 // e.g. "/special/drive/root/dir" for "/special/drive/dir". | 113 // e.g. "/special/drive/root/dir" for "/special/drive/dir". |
110 // NeedsNamespaceMigration(path) should be true (after the TODOs are resolved). | 114 // NeedsNamespaceMigration(path) should be true (after the TODOs are resolved). |
111 base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path); | 115 base::FilePath ConvertToMyDriveNamespace(const base::FilePath& path); |
112 | 116 |
113 // Extracts the Drive path from the given path located under the Drive mount | 117 // Extracts the Drive path from the given path located under the Drive mount |
114 // point. Returns an empty path if |path| is not under the Drive mount point. | 118 // point. Returns an empty path if |path| is not under the Drive mount point. |
115 // Examples: ExtractGDatPath("/special/drive/foo.txt") => "drive/foo.txt" | 119 // Examples: ExtractDrivePath("/special/drive/foo.txt") => "drive/foo.txt" |
116 base::FilePath ExtractDrivePath(const base::FilePath& path); | 120 base::FilePath ExtractDrivePath(const base::FilePath& path); |
117 | 121 |
| 122 // Extracts the Drive path (e.g., "drive/foo.txt") from the filesystem URL. |
| 123 // Returns an empty path if |url| does not point under Drive mount point. |
| 124 base::FilePath ExtractDrivePathFromFileSystemUrl( |
| 125 const fileapi::FileSystemURL& url); |
| 126 |
118 // Escapes a file name in Drive cache. | 127 // Escapes a file name in Drive cache. |
119 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) | 128 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) |
120 std::string EscapeCacheFileName(const std::string& filename); | 129 std::string EscapeCacheFileName(const std::string& filename); |
121 | 130 |
122 // Unescapes a file path in Drive cache. | 131 // Unescapes a file path in Drive cache. |
123 // This is the inverse of EscapeCacheFileName. | 132 // This is the inverse of EscapeCacheFileName. |
124 std::string UnescapeCacheFileName(const std::string& filename); | 133 std::string UnescapeCacheFileName(const std::string& filename); |
125 | 134 |
126 // Escapes forward slashes from file names with magic unicode character | 135 // Escapes forward slashes from file names with magic unicode character |
127 // \u2215 pretty much looks the same in UI. | 136 // \u2215 pretty much looks the same in UI. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void operator()(T* object) const { | 204 void operator()(T* object) const { |
196 if (object) | 205 if (object) |
197 object->Destroy(); | 206 object->Destroy(); |
198 } | 207 } |
199 }; | 208 }; |
200 | 209 |
201 } // namespace util | 210 } // namespace util |
202 } // namespace drive | 211 } // namespace drive |
203 | 212 |
204 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ | 213 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_FILE_SYSTEM_UTIL_H_ |
OLD | NEW |