dom/webidl/Directory.webidl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial