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 #include "webkit/fileapi/file_system_util.h" | 5 #include "webkit/fileapi/file_system_util.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // Ensure the path is relative. | 80 // Ensure the path is relative. |
81 while (!path.empty() && path[0] == '/') | 81 while (!path.empty() && path[0] == '/') |
82 path.erase(0, 1); | 82 path.erase(0, 1); |
83 | 83 |
84 if (origin_url) | 84 if (origin_url) |
85 *origin_url = origin; | 85 *origin_url = origin; |
86 if (type) | 86 if (type) |
87 *type = file_system_type; | 87 *type = file_system_type; |
88 if (file_path) | 88 if (file_path) |
89 #if defined(OS_WIN) | 89 *file_path = FilePath::FromUTF8Unsafe(path). |
90 *file_path = FilePath(base::SysUTF8ToWide(path)). | 90 NormalizePathSeparators().StripTrailingSeparators(); |
91 NormalizeWindowsPathSeparators().StripTrailingSeparators(); | |
92 #elif defined(OS_POSIX) | |
93 *file_path = FilePath(path).StripTrailingSeparators(); | |
94 #endif | |
95 | 91 |
96 return true; | 92 return true; |
97 } | 93 } |
98 | 94 |
99 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) { | 95 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) { |
100 std::string path("filesystem:"); | 96 std::string path("filesystem:"); |
101 path += origin_url.spec(); | 97 path += origin_url.spec(); |
102 switch (type) { | 98 switch (type) { |
103 case kFileSystemTypeTemporary: | 99 case kFileSystemTypeTemporary: |
104 path += (kTemporaryDir + 1); // We don't want the leading slash. | 100 path += (kTemporaryDir + 1); // We don't want the leading slash. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return fileapi::kPersistentName; | 172 return fileapi::kPersistentName; |
177 case kFileSystemTypeExternal: | 173 case kFileSystemTypeExternal: |
178 return fileapi::kExternalName; | 174 return fileapi::kExternalName; |
179 case kFileSystemTypeUnknown: | 175 case kFileSystemTypeUnknown: |
180 default: | 176 default: |
181 return std::string(); | 177 return std::string(); |
182 } | 178 } |
183 } | 179 } |
184 | 180 |
185 } // namespace fileapi | 181 } // namespace fileapi |
OLD | NEW |