Chromium Code Reviews| 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 /** | 5 /** |
| 6 * Type of a root directory. | 6 * Type of a root directory. |
| 7 * @enum | 7 * @enum |
| 8 */ | 8 */ |
| 9 var RootType = { | 9 var RootType = { |
| 10 DOWNLOADS: 'downloads', | 10 DOWNLOADS: 'downloads', |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 * @param {string} path Path starting with '/'. | 30 * @param {string} path Path starting with '/'. |
| 31 * @return {string} Root directory (starting with '/'). | 31 * @return {string} Root directory (starting with '/'). |
| 32 */ | 32 */ |
| 33 PathUtil.getRootDirectory = function(path) { | 33 PathUtil.getRootDirectory = function(path) { |
| 34 var i = path.indexOf('/', 1); | 34 var i = path.indexOf('/', 1); |
| 35 return i === -1 ? path.substring(0) : path.substring(0, i); | 35 return i === -1 ? path.substring(0) : path.substring(0, i); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * @param {string} path Any unix-style path (may start or not start from root). | 39 * @param {string} path Any unix-style path (may start or not start from root). |
| 40 * @return {Array.<string>} path components | 40 * @return {Array.<string>} path components. |
|
mtomasz
2013/02/12 06:39:23
First letter upper case?
yoshiki
2013/02/12 06:42:45
Good catch! Done.
On 2013/02/12 06:39:23, mtomasz
| |
| 41 */ | 41 */ |
| 42 PathUtil.split = function(path) { | 42 PathUtil.split = function(path) { |
| 43 var fromRoot = false; | 43 var fromRoot = false; |
| 44 if (path[0] === '/') { | 44 if (path[0] === '/') { |
| 45 fromRoot = true; | 45 fromRoot = true; |
| 46 path = path.substring(1); | 46 path = path.substring(1); |
| 47 } | 47 } |
| 48 | 48 |
| 49 var components = path.split('/'); | 49 var components = path.split('/'); |
| 50 if (fromRoot) | 50 if (fromRoot) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 if (path === RootDirectory.REMOVABLE) | 167 if (path === RootDirectory.REMOVABLE) |
| 168 return str('REMOVABLE_DIRECTORY_LABEL'); | 168 return str('REMOVABLE_DIRECTORY_LABEL'); |
| 169 if (PathUtil.isParentPath(RootDirectory.REMOVABLE, path)) | 169 if (PathUtil.isParentPath(RootDirectory.REMOVABLE, path)) |
| 170 return path.substring(RootDirectory.REMOVABLE.length + 1); | 170 return path.substring(RootDirectory.REMOVABLE.length + 1); |
| 171 | 171 |
| 172 if (path === RootDirectory.DRIVE) | 172 if (path === RootDirectory.DRIVE) |
| 173 return str('DRIVE_DIRECTORY_LABEL'); | 173 return str('DRIVE_DIRECTORY_LABEL'); |
| 174 | 174 |
| 175 return path; | 175 return path; |
| 176 }; | 176 }; |
| OLD | NEW |