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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 /** | 125 /** |
126 * @param {string} path A path. | 126 * @param {string} path A path. |
127 * @return {boolean} True if it is a path to the root. | 127 * @return {boolean} True if it is a path to the root. |
128 */ | 128 */ |
129 PathUtil.isRootPath = function(path) { | 129 PathUtil.isRootPath = function(path) { |
130 return PathUtil.getRootPath(path) === path; | 130 return PathUtil.getRootPath(path) === path; |
131 }; | 131 }; |
132 | 132 |
133 /** | 133 /** |
| 134 * @param {string} path A root path. |
| 135 * @return {boolean} True if the given path is root and user can unmount it. |
| 136 */ |
| 137 PathUtil.isUnmountableByUser = function(path) { |
| 138 if (!PathUtil.isRootPath(path)) |
| 139 return false; |
| 140 |
| 141 var type = PathUtil.getRootType(path); |
| 142 return (type == RootType.ARCHIVE || type == RootType.REMOVABLE); |
| 143 }; |
| 144 |
| 145 /** |
134 * @param {string} parent_path The parent path. | 146 * @param {string} parent_path The parent path. |
135 * @param {string} child_path The child path. | 147 * @param {string} child_path The child path. |
136 * @return {boolean} True if |parent_path| is parent file path of |child_path|. | 148 * @return {boolean} True if |parent_path| is parent file path of |child_path|. |
137 */ | 149 */ |
138 PathUtil.isParentPath = function(parent_path, child_path) { | 150 PathUtil.isParentPath = function(parent_path, child_path) { |
139 if (!parent_path || parent_path.length == 0 || | 151 if (!parent_path || parent_path.length == 0 || |
140 !child_path || child_path.length == 0) | 152 !child_path || child_path.length == 0) |
141 return false; | 153 return false; |
142 | 154 |
143 if (parent_path[parent_path.length - 1] != '/') | 155 if (parent_path[parent_path.length - 1] != '/') |
(...skipping 29 matching lines...) Expand all Loading... |
173 return path.substring(RootDirectory.REMOVABLE.length + 1); | 185 return path.substring(RootDirectory.REMOVABLE.length + 1); |
174 | 186 |
175 if (path === RootDirectory.DRIVE) | 187 if (path === RootDirectory.DRIVE) |
176 return str('DRIVE_DIRECTORY_LABEL'); | 188 return str('DRIVE_DIRECTORY_LABEL'); |
177 | 189 |
178 if (path === RootDirectory.DRIVE_OFFLINE) | 190 if (path === RootDirectory.DRIVE_OFFLINE) |
179 return str('DRIVE_OFFLINE_COLLECTION_LABEL'); | 191 return str('DRIVE_OFFLINE_COLLECTION_LABEL'); |
180 | 192 |
181 return path; | 193 return path; |
182 }; | 194 }; |
OLD | NEW |