Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
7 interface File;
9 /*
10 * All functions on Directory that accept DOMString arguments for file or
11 * directory names only allow relative path to current directory itself. The
12 * path should be a descendent path like "path/to/file.txt" and not contain a
13 * segment of ".." or ".". So the paths aren't allowed to walk up the directory
14 * tree. For example, paths like "../foo", "..", "/foo/bar" or "foo/../bar" are
15 * not allowed.
16 */
17 [NoInterfaceObject]
18 interface Directory {
19 /*
20 * The leaf name of the directory.
21 */
22 readonly attribute DOMString name;
24 /*
25 * Creates a new file or replaces an existing file with given data. The file
26 * should be a descendent of current directory.
27 *
28 * @param path The relative path of the new file to current directory.
29 * @param options It has two optional properties, 'ifExists' and 'data'.
30 * If 'ifExists' is 'fail' and the path already exists, createFile must fail;
31 * If 'ifExists' is 'replace', the path already exists, and is a file, create
32 * a new file to replace the existing one;
33 * If 'ifExists' is 'replace', the path already exists, but is a directory,
34 * createFile must fail.
35 * Otherwise, if no other error occurs, createFile will create a new file.
36 * The 'data' property contains the new file's content.
37 * @return If succeeds, the promise is resolved with the new created
38 * File object. Otherwise, rejected with a DOM error.
39 */
40 [NewObject]
41 // Promise<File>
42 Promise createFile(DOMString path, optional CreateFileOptions options);
44 /*
45 * Creates a descendent directory. This method will create any intermediate
46 * directories specified by the path segments.
47 *
48 * @param path The relative path of the new directory to current directory.
49 * If path exists, createDirectory must fail.
50 * @return If succeeds, the promise is resolved with the new created
51 * Directory object. Otherwise, rejected with a DOM error.
52 */
53 [NewObject]
54 // Promise<Directory>
55 Promise createDirectory(DOMString path);
57 /*
58 * Gets a descendent file or directory with the given path.
59 *
60 * @param path The descendent entry's relative path to current directory.
61 * @return If the path exists and no error occurs, the promise is resolved
62 * with a File or Directory object, depending on the entry's type. Otherwise,
63 * rejected with a DOM error.
64 */
65 [NewObject]
66 // Promise<(File or Directory)>
67 Promise get(DOMString path);
69 /*
70 * Deletes a file or an empty directory. The target must be a descendent of
71 * current directory.
72 * @param path If a DOM string is passed, it is the relative path of the
73 * target. Otherwise, the File or Directory object of the target should be
74 * passed.
75 * @return If the target is a non-empty directory, or if deleting the target
76 * fails, the promise is rejected with a DOM error. If the target did not
77 * exist, the promise is resolved with boolean false. If the target did exist
78 * and was successfully deleted, the promise is resolved with boolean true.
79 */
80 [NewObject]
81 // Promise<boolean>
82 Promise remove((DOMString or File or Directory) path);
84 /*
85 * Deletes a file or a directory recursively. The target should be a
86 * descendent of current directory.
87 * @param path If a DOM string is passed, it is the relative path of the
88 * target. Otherwise, the File or Directory object of the target should be
89 * passed.
90 * @return If the target exists, but deleting the target fails, the promise is
91 * rejected with a DOM error. If the target did not exist, the promise is
92 * resolved with boolean false. If the target did exist and was successfully
93 * deleted, the promise is resolved with boolean true.
94 */
95 [NewObject]
96 // Promise<boolean>
97 Promise removeDeep((DOMString or File or Directory) path);
98 };
100 enum CreateIfExistsMode { "replace", "fail" };
102 dictionary CreateFileOptions {
103 CreateIfExistsMode ifExists = "fail";
104 (DOMString or Blob or ArrayBuffer or ArrayBufferView) data;
105 };