Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: chrome/browser/resources/file_manager/common/js/path_util.js

Issue 247123002: Move Files.app files to ui/file_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the test failure on non-chromeos Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /**
8 * Type of a root directory.
9 * @enum {string}
10 * @const
11 */
12 var RootType = Object.freeze({
13 // Root of local directory.
14 DOWNLOADS: 'downloads',
15
16 // Root of mounted archive file.
17 ARCHIVE: 'archive',
18
19 // Root of removal volume.
20 REMOVABLE: 'removable',
21
22 // Root of drive directory.
23 DRIVE: 'drive',
24
25 // Root for privet storage volume.
26 CLOUD_DEVICE: 'cloud_device',
27
28 // Root for MTP device.
29 MTP: 'mtp',
30
31 // Root for entries that is not located under RootType.DRIVE. e.g. shared
32 // files.
33 DRIVE_OTHER: 'drive_other',
34
35 // Fake root for offline available files on the drive.
36 DRIVE_OFFLINE: 'drive_offline',
37
38 // Fake root for shared files on the drive.
39 DRIVE_SHARED_WITH_ME: 'drive_shared_with_me',
40
41 // Fake root for recent files on the drive.
42 DRIVE_RECENT: 'drive_recent'
43 });
44
45 var PathUtil = {};
46
47 /**
48 * Extracts the extension of the path.
49 *
50 * Examples:
51 * PathUtil.splitExtension('abc.ext') -> ['abc', '.ext']
52 * PathUtil.splitExtension('a/b/abc.ext') -> ['a/b/abc', '.ext']
53 * PathUtil.splitExtension('a/b') -> ['a/b', '']
54 * PathUtil.splitExtension('.cshrc') -> ['', '.cshrc']
55 * PathUtil.splitExtension('a/b.backup/hoge') -> ['a/b.backup/hoge', '']
56 *
57 * @param {string} path Path to be extracted.
58 * @return {Array.<string>} Filename and extension of the given path.
59 */
60 PathUtil.splitExtension = function(path) {
61 var dotPosition = path.lastIndexOf('.');
62 if (dotPosition <= path.lastIndexOf('/'))
63 dotPosition = -1;
64
65 var filename = dotPosition != -1 ? path.substr(0, dotPosition) : path;
66 var extension = dotPosition != -1 ? path.substr(dotPosition) : '';
67 return [filename, extension];
68 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698