openEventsPlatformApp/plugins/cordova-plugin-file/www/FileSystem.js
plugins/cordova-plugin-file/www/FileSystem.jsRaw
1/*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22var DirectoryEntry = require('./DirectoryEntry');
23
24/**
25 * An interface representing a file system
26 *
27 * @constructor
28 * {DOMString} name the unique name of the file system (readonly)
29 * {DirectoryEntry} root directory of the file system (readonly)
30 */
31var FileSystem = function(name, root) {
32 this.name = name;
33 if (root) {
34 this.root = new DirectoryEntry(root.name, root.fullPath, this, root.nativeURL);
35 } else {
36 this.root = new DirectoryEntry(this.name, '/', this);
37 }
38};
39
40FileSystem.prototype.__format__ = function(fullPath, nativeUrl) {
41 return fullPath;
42};
43
44FileSystem.prototype.toJSON = function() {
45 return "<FileSystem: " + this.name + ">";
46};
47
48// Use instead of encodeURI() when encoding just the path part of a URI rather than an entire URI.
49FileSystem.encodeURIPath = function(path) {
50 // Because # is a valid filename character, it must be encoded to prevent part of the
51 // path from being parsed as a URI fragment.
52 return encodeURI(path).replace(/#/g, '%23');
53};
54
55module.exports = FileSystem;