| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 file_system_type = kFileSystemTypeLocal; | 81 file_system_type = kFileSystemTypeLocal; |
| 82 path = path.substr(strlen(kLocalDir)); | 82 path = path.substr(strlen(kLocalDir)); |
| 83 } else { | 83 } else { |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Ensure the path is relative. | 87 // Ensure the path is relative. |
| 88 while (!path.empty() && path[0] == '/') | 88 while (!path.empty() && path[0] == '/') |
| 89 path.erase(0, 1); | 89 path.erase(0, 1); |
| 90 | 90 |
| 91 #if defined(OS_WIN) | |
| 92 const FilePath::StringType sys_path = base::SysUTF8ToWide(path); | |
| 93 #elif defined(OS_POSIX) | |
| 94 const FilePath::StringType sys_path = path; | |
| 95 #endif | |
| 96 if (origin_url) | 91 if (origin_url) |
| 97 *origin_url = origin; | 92 *origin_url = origin; |
| 98 if (type) | 93 if (type) |
| 99 *type = file_system_type; | 94 *type = file_system_type; |
| 100 if (file_path) | 95 if (file_path) |
| 101 *file_path = FilePath(sys_path); | 96 #if defined(OS_WIN) |
| 97 *file_path = FilePath(base::SysUTF8ToWide(path)). |
| 98 NormalizeWindowsPathSeparators(); |
| 99 #elif defined(OS_POSIX) |
| 100 *file_path = FilePath(path); |
| 101 #endif |
| 102 | 102 |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 GURL GetFileSystemRootURI( | 106 GURL GetFileSystemRootURI( |
| 107 const GURL& origin_url, fileapi::FileSystemType type) { | 107 const GURL& origin_url, fileapi::FileSystemType type) { |
| 108 std::string path("filesystem:"); | 108 std::string path("filesystem:"); |
| 109 path += origin_url.spec(); | 109 path += origin_url.spec(); |
| 110 switch (type) { | 110 switch (type) { |
| 111 case kFileSystemTypeTemporary: | 111 case kFileSystemTypeTemporary: |
| 112 path += (kTemporaryDir + 1); // We don't want the leading slash. | 112 path += (kTemporaryDir + 1); // We don't want the leading slash. |
| 113 break; | 113 break; |
| 114 case kFileSystemTypePersistent: | 114 case kFileSystemTypePersistent: |
| 115 path += (kPersistentDir + 1); // We don't want the leading slash. | 115 path += (kPersistentDir + 1); // We don't want the leading slash. |
| 116 break; | 116 break; |
| 117 case kFileSystemTypeLocal: | 117 case kFileSystemTypeLocal: |
| 118 path += (kLocalDir + 1); // We don't want the leading slash. | 118 path += (kLocalDir + 1); // We don't want the leading slash. |
| 119 break; | 119 break; |
| 120 default: | 120 default: |
| 121 NOTREACHED(); | 121 NOTREACHED(); |
| 122 return GURL(); | 122 return GURL(); |
| 123 } | 123 } |
| 124 return GURL(path); | 124 return GURL(path); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace fileapi | 127 } // namespace fileapi |
| OLD | NEW |