1 // Copyright 2014 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.
5 var fileSystemNatives
= requireNative('file_system_natives');
10 function computeName(entry
) {
11 return entry
.filesystem
.name
+ ':' + entry
.fullPath
;
14 function computeId(entry
) {
15 var fileSystemId
= fileSystemNatives
.CrackIsolatedFileSystemName(
16 entry
.filesystem
.name
);
19 // Strip the leading '/' from the path.
20 return fileSystemId
+ ':' + $String
.slice(entry
.fullPath
, 1);
23 function registerEntry(id
, entry
) {
24 var name
= computeName(entry
);
26 idsToEntries
[id
] = entry
;
29 function getEntryId(entry
) {
32 name
= computeName(entry
);
36 var id
= nameToIds
[name
];
40 // If an entry has not been registered, compute its id and register it.
41 id
= computeId(entry
);
42 registerEntry(id
, entry
);
46 function getEntryById(id
) {
47 return idsToEntries
[id
];
50 exports
.registerEntry
= registerEntry
;
51 exports
.getEntryId
= getEntryId
;
52 exports
.getEntryById
= getEntryById
;