tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IOUtils.webidl (25996B)


      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 */
      6 
      7 interface nsIFile;
      8 
      9 /**
     10 * IOUtils is a simple, efficient interface for performing file I/O from a
     11 * privileged chrome-only context. All asynchronous I/O tasks are run on
     12 * a background thread.
     13 *
     14 * Pending I/O tasks will block shutdown at the |profileBeforeChange| phase.
     15 * During this shutdown phase, no additional I/O tasks will be accepted --
     16 * method calls to this interface will reject once shutdown has entered this
     17 * phase.
     18 *
     19 * IOUtils methods may reject for any number of reasons. Reasonable attempts
     20 * have been made to map each common operating system error to a |DOMException|.
     21 * Most often, a caller only needs to check if a given file wasn't found by
     22 * catching the rejected error and checking if |ex.name === 'NotFoundError'|.
     23 * In other cases, it is likely sufficient to allow the error to be caught and
     24 * reported elsewhere.
     25 */
     26 [ChromeOnly, Exposed=(Window, Worker)]
     27 namespace IOUtils {
     28 /**
     29   * Reads up to |opts.maxBytes| of the file at |path| according to |opts|.
     30   *
     31   * NB: The maximum file size that can be read is UINT32_MAX.
     32   *
     33   * @param path An absolute file path.
     34   *
     35   * @return Resolves with an array of unsigned byte values read from disk,
     36   *         otherwise rejects with a DOMException.
     37   */
     38  [NewObject]
     39  Promise<Uint8Array> read(DOMString path, optional ReadOptions opts = {});
     40  /**
     41   * Reads the UTF-8 text file located at |path| and returns the decoded
     42   * contents as a |DOMString|. If a UTF-8 byte order marker (BOM) is
     43   * present, it will be stripped from the returned string.
     44   *
     45   * NB: The maximum file size that can be read is UINT32_MAX.
     46   *
     47   * @param path An absolute file path.
     48   *
     49   * @return Resolves with the file contents encoded as a string, otherwise
     50   *         rejects with a DOMException.
     51   */
     52  [NewObject]
     53  Promise<UTF8String> readUTF8(DOMString path, optional ReadUTF8Options opts = {});
     54  /**
     55   * Read the UTF-8 text file located at |path| and return the contents
     56   * parsed as JSON into a JS value.
     57   *
     58   * NB: The maximum file size that can be read is UINT32_MAX.
     59   *
     60   * @param path An absolute path.
     61   *
     62   * @return Resolves with the contents of the file parsed as JSON.
     63   */
     64  [NewObject]
     65  Promise<any> readJSON(DOMString path, optional ReadUTF8Options opts = {});
     66  /**
     67   * Attempts to safely write |data| to a file at |path|.
     68   *
     69   * This operation can be made atomic by specifying the |tmpPath| option. If
     70   * specified, then this method ensures that the destination file is not
     71   * modified until the data is entirely written to the temporary file, after
     72   * which point the |tmpPath| is moved to the specified |path|.
     73   *
     74   * The target file can also be backed up to a |backupFile| before any writes
     75   * are performed to prevent data loss in case of corruption.
     76   *
     77   * @param path    An absolute file path.
     78   * @param data    Data to write to the file at path.
     79   *
     80   * @return Resolves with the number of bytes successfully written to the file,
     81   *         otherwise rejects with a DOMException.
     82   */
     83  [NewObject]
     84  Promise<unsigned long long> write(DOMString path, Uint8Array data, optional WriteOptions options = {});
     85  /**
     86   * Attempts to encode |string| to UTF-8, then safely write the result to a
     87   * file at |path|. Works exactly like |write|.
     88   *
     89   * @param path      An absolute file path.
     90   * @param string    A string to write to the file at path.
     91   * @param options   Options for writing the file.
     92   *
     93   * @return Resolves with the number of bytes successfully written to the file,
     94   *         otherwise rejects with a DOMException.
     95   */
     96  [NewObject]
     97  Promise<unsigned long long> writeUTF8(DOMString path, UTF8String string, optional WriteOptions options = {});
     98  /**
     99   * Attempts to serialize |value| into a JSON string and encode it as into a
    100   * UTF-8 string, then safely write the result to a file at |path|. Works
    101   * exactly like |write|.
    102   *
    103   * @param path      An absolute file path
    104   * @param value     The value to be serialized.
    105   * @param options   Options for writing the file. The "append" mode is not supported.
    106   *
    107   * @return Resolves with the number of bytes successfully written to the file,
    108   *         otherwise rejects with a DOMException.
    109   */
    110  [NewObject]
    111  Promise<unsigned long long> writeJSON(DOMString path, any value, optional WriteOptions options = {});
    112  /**
    113   * Moves the file from |sourcePath| to |destPath|, creating necessary parents.
    114   * If |destPath| is a directory, then the source file will be moved into the
    115   * destination directory.
    116   *
    117   * @param sourcePath An absolute file path identifying the file or directory
    118   *                   to move.
    119   * @param destPath   An absolute file path identifying the destination
    120   *                   directory and/or file name.
    121   *
    122   * @return Resolves if the file is moved successfully, otherwise rejects with
    123   *         a DOMException.
    124   */
    125  [NewObject]
    126  Promise<undefined> move(DOMString sourcePath, DOMString destPath, optional MoveOptions options = {});
    127  /**
    128   * Removes a file or directory at |path| according to |options|.
    129   *
    130   * @param path An absolute file path identifying the file or directory to
    131   *             remove.
    132   *
    133   * @return Resolves if the file is removed successfully, otherwise rejects
    134   *         with a DOMException.
    135   */
    136  [NewObject]
    137  Promise<undefined> remove(DOMString path, optional RemoveOptions options = {});
    138  /**
    139   * Creates a new directory at |path| according to |options|.
    140   *
    141   * @param path An absolute file path identifying the directory to create.
    142   *
    143   * @return Resolves if the directory is created successfully, otherwise
    144   *         rejects with a DOMException.
    145   */
    146  [NewObject]
    147  Promise<undefined> makeDirectory(DOMString path, optional MakeDirectoryOptions options = {});
    148  /**
    149   * Obtains information about a file, such as size, modification dates, etc.
    150   *
    151   * @param path An absolute file path identifying the file or directory to
    152   *             inspect.
    153   *
    154   * @return Resolves with a |FileInfo| object for the file at path, otherwise
    155   *         rejects with a DOMException.
    156   *
    157   * @see FileInfo
    158   */
    159  [NewObject]
    160  Promise<FileInfo> stat(DOMString path);
    161  /**
    162   * Copies a file or directory from |sourcePath| to |destPath| according to
    163   * |options|.
    164   *
    165   * @param sourcePath An absolute file path identifying the source file to be
    166   *                   copied.
    167   * @param destPath   An absolute file path identifying the location for the
    168   *                   copy.
    169   *
    170   * @return Resolves if the file was copied successfully, otherwise rejects
    171   *         with a DOMException.
    172   */
    173  [NewObject]
    174  Promise<undefined> copy(DOMString sourcePath, DOMString destPath, optional CopyOptions options = {});
    175  /**
    176   * Updates the access time for the file at |path|.
    177   *
    178   * @param path         An absolute file path identifying the file whose
    179   *                     modification time is to be set. This file must exist
    180   *                     and will not be created.
    181   * @param modification An optional access time for the file expressed in
    182   *                     milliseconds since the Unix epoch
    183   *                     (1970-01-01T00:00:00Z). The current system time is used
    184   *                     if this parameter is not provided.
    185   *
    186   * @return Resolves with the updated access time time expressed in
    187   *         milliseconds since the Unix epoch, otherwise rejects with a
    188   *         DOMException.
    189   */
    190  [NewObject]
    191  Promise<long long> setAccessTime(DOMString path, optional long long access);
    192  /**
    193   * Updates the modification time for the file at |path|.
    194   *
    195   * @param path         An absolute file path identifying the file whose
    196   *                     modification time is to be set. This file must exist
    197   *                     and will not be created.
    198   * @param modification An optional modification time for the file expressed in
    199   *                     milliseconds since the Unix epoch
    200   *                     (1970-01-01T00:00:00Z). The current system time is used
    201   *                     if this parameter is not provided.
    202   *
    203   * @return Resolves with the updated modification time expressed in
    204   *         milliseconds since the Unix epoch, otherwise rejects with a
    205   *         DOMException.
    206   */
    207  [NewObject]
    208  Promise<long long> setModificationTime(DOMString path, optional long long modification);
    209  /**
    210   * Checks whether the directory at |path| has any immediate children.
    211   *
    212   * @param path An absolute file path.
    213   *
    214   * @return Resolves with a boolean indicating whether the directory at |path|
    215   *         has any immediate children, otherwise rejects with a DOMException.
    216   */
    217  [NewObject]
    218  Promise<boolean> hasChildren(DOMString path, optional HasChildrenOptions options = {});
    219  /**
    220   * Retrieves a (possibly empty) list of immediate children of the directory at
    221   * |path|.
    222   *
    223   * @param path An absolute file path.
    224   *
    225   * @return Resolves with a sequence of absolute file paths representing the
    226   *         children of the directory at |path|, otherwise rejects with a
    227   *         DOMException.
    228   */
    229  [NewObject]
    230  Promise<sequence<DOMString>> getChildren(DOMString path, optional GetChildrenOptions options = {});
    231  /**
    232   * Set the permissions of the file at |path|.
    233   *
    234   * Windows does not make a distinction between user, group, and other
    235   * permissions like UNICES do. If a permission flag is set for any of user,
    236   * group, or other has a permission, then all users will have that
    237   * permission. Additionally, Windows does not support setting the
    238   * "executable" permission.
    239   *
    240   * @param path        An absolute file path
    241   * @param permissions The UNIX file mode representing the permissions.
    242   * @param honorUmask  If omitted or true, any UNIX file mode value is
    243   *                    modified by the process umask. If false, the exact value
    244   *                    of UNIX file mode will be applied. This value has no effect
    245   *                    on Windows.
    246   *
    247   * @return Resolves if the permissions were set successfully, otherwise
    248   *         rejects with a DOMException.
    249   */
    250  [NewObject]
    251  Promise<undefined> setPermissions(DOMString path, unsigned long permissions, optional boolean honorUmask = true);
    252  /**
    253   * Return whether or not the file exists at the given path.
    254   *
    255   * @param path An absolute file path.
    256   *
    257   * @return A promise that resolves to whether or not the given file exists.
    258   */
    259  [NewObject]
    260  Promise<boolean> exists(DOMString path);
    261 
    262  /**
    263   * Create a file with a unique name and return its path.
    264   *
    265   * @param parent An absolute path to the directory where the file is to be
    266   *               created.
    267   * @param prefix A prefix for the filename.
    268   *
    269   * @return A promise that resolves to a unique filename.
    270   */
    271  [NewObject]
    272  Promise<DOMString> createUniqueFile(DOMString parent, DOMString prefix, optional unsigned long permissions = 0644);
    273 
    274  /**
    275   * Create a directory with a unique name and return its path.
    276   *
    277   * @param parent An absolute path to the directory where the file is to be
    278   *               created.
    279   * @param prefix A prefix for the directory name.
    280   *
    281   * @return A promise that resolves to a unique directory name.
    282   */
    283  [NewObject]
    284  Promise<DOMString> createUniqueDirectory(DOMString parent, DOMString prefix, optional unsigned long permissions = 0755);
    285 
    286  /**
    287   * Compute the hash of a file as a hex digest.
    288   *
    289   * @param path   The absolute path of the file to hash.
    290   * @param method The hashing method to use.
    291   *
    292   * @return A promise that resolves to the hex digest of the file's hash in lowercase.
    293   */
    294  [NewObject]
    295  Promise<UTF8String> computeHexDigest(DOMString path, HashAlgorithm method);
    296 
    297 #if defined(XP_WIN)
    298  /**
    299   * Return the Windows-specific file attributes of the file at the given path.
    300   *
    301   * @param path An absolute file path.
    302   *
    303   * @return A promise that resolves to the Windows-specific file attributes.
    304   */
    305  [NewObject]
    306  Promise<WindowsFileAttributes> getWindowsAttributes(DOMString path);
    307 
    308  /**
    309   * Set the Windows-specific file attributes of the file at the given path.
    310   *
    311   * @param path An absolute file path.
    312   * @param attrs The attributes to set. Attributes will only be set if they are
    313   *              |true| or |false| (i.e., |undefined| attributes are not
    314   *              changed).
    315   * @param recursive  Whether or not to apply the changes to folder contents
    316   *                   recursively.
    317   *
    318   * @return A promise that resolves is the attributes were set successfully.
    319   */
    320  [NewObject]
    321  Promise<undefined> setWindowsAttributes(DOMString path,
    322      optional WindowsFileAttributes attrs = {},
    323      optional boolean recursive = false);
    324 #elif defined(XP_MACOSX)
    325  /**
    326   * Return whether or not the file has a specific extended attribute.
    327   *
    328   * @param path An absolute path.
    329   * @param attr The attribute to check for.
    330   *
    331   * @return A promise that resolves to whether or not the file has an extended
    332   *         attribute, or rejects with an error.
    333   */
    334  [NewObject]
    335  Promise<boolean> hasMacXAttr(DOMString path, UTF8String attr);
    336  /**
    337   * Return the value of an extended attribute for a file.
    338   *
    339   * @param path An absolute path.
    340   * @param attr The attribute to get the value of.
    341   *
    342   * @return A promise that resolves to the value of the extended attribute, or
    343   *         rejects with an error.
    344   */
    345  [NewObject]
    346  Promise<Uint8Array> getMacXAttr(DOMString path, UTF8String attr);
    347  /**
    348   * Set the extended attribute on a file.
    349   *
    350   * @param path  An absolute path.
    351   * @param attr  The attribute to set.
    352   * @param value The value of the attribute to set.
    353   *
    354   * @return A promise that resolves to whether or not the file has an extended
    355   *         attribute, or rejects with an error.
    356   */
    357  [NewObject]
    358  Promise<undefined> setMacXAttr(DOMString path, UTF8String attr, Uint8Array value);
    359  /**
    360   * Delete the extended attribute on a file.
    361   *
    362   * @param path An absolute path.
    363   * @param attr The attribute to delete.
    364   *
    365   * @return A promise that resolves if the attribute was deleted, or rejects
    366   *         with an error.
    367   */
    368  [NewObject]
    369  Promise<undefined> delMacXAttr(DOMString path, UTF8String attr);
    370 #endif
    371 
    372  /**
    373   * Return a nsIFile whose parent directory exists. The parent directory of the
    374   * file will be created off main thread if it does not already exist.
    375   *
    376   * @param components The path components. The first component must be an
    377   *                   absolute path.
    378   *
    379   * @return A promise that resolves to an nsIFile for the requested file.
    380   */
    381  [NewObject]
    382  Promise<nsIFile> getFile(DOMString... components);
    383 
    384  /**
    385   * Return an nsIFile corresponding to a directory. It will be created
    386   * off-main-thread if it does not already exist.
    387   *
    388   * @param components The path components. The first component must be an
    389   *                   absolute path.
    390   *
    391   * @return A promise that resolves to an nsIFile for the requested directory.
    392   */
    393  [NewObject]
    394  Promise<nsIFile> getDirectory(DOMString... components);
    395 };
    396 
    397 [Exposed=Window]
    398 partial namespace IOUtils {
    399  /**
    400   * The async shutdown client for the profile-before-change shutdown phase.
    401   */
    402  [Throws]
    403  readonly attribute any profileBeforeChange;
    404 
    405  /**
    406   * The async shutdown client for the profile-before-change-telemetry shutdown
    407   * phase.
    408   *
    409   * ONLY telemetry should register blockers on this client.
    410   */
    411  [Throws]
    412  readonly attribute any sendTelemetry;
    413 };
    414 
    415 [Exposed=Worker]
    416 partial namespace IOUtils {
    417  /**
    418   * Synchronously opens the file at |path|. This API is only available in workers.
    419   *
    420   * @param path An absolute file path.
    421   *
    422   * @return A |SyncReadFile| object for the file.
    423   */
    424  [Throws]
    425  SyncReadFile openFileForSyncReading(DOMString path);
    426 
    427 #ifdef XP_UNIX
    428  /**
    429   * Launch a child process; uses `base::LaunchApp` from IPC.  (This WebIDL
    430   * binding is currently Unix-only; it could also be supported on Windows
    431   * but it would use u16-based strings, so it would basically be a separate
    432   * copy of the bindings.)
    433   *
    434   * This interface was added for use by `Subprocess.sys.mjs`; other would-be
    435   * callers may want to just use Subprocess instead of calling this directly.
    436   *
    437   * @param argv The command to run and its arguments.
    438   * @param options Various parameters about how the child process is launched
    439   *                and its initial environment.
    440   *
    441   * @return The process ID.  Note that various errors (e.g., the
    442   *         executable to be launched doesn't exist) may not be
    443   *         encountered until after the process is created, so a
    444   *         successful return doesn't necessarily imply a successful
    445   *         launch.
    446   */
    447  [Throws]
    448  unsigned long launchProcess(sequence<UnixString> argv, LaunchOptions options);
    449 #endif
    450 };
    451 
    452 /**
    453 * An object representing an open file, allowing parts of the file contents to be
    454 * read synchronously. Only available in workers.
    455 */
    456 [ChromeOnly, Exposed=Worker]
    457 interface SyncReadFile {
    458  /**
    459   * The file size, in bytes.
    460   */
    461  readonly attribute long long size;
    462 
    463  /**
    464   * Synchronously read |dest.length| bytes at offset |offset| into |dest|.
    465   * Throws if the file has been closed already or if the read would be out-of-bounds.
    466   *
    467   * @param dest   A Uint8Array whose entire contents will be overwritten with
    468   *               bytes read from the file.
    469   * @param offset The file offset at which the read range begins. (The length of the
    470   *               range is given by |dest.length|.)
    471   */
    472  [Throws]
    473  undefined readBytesInto(Uint8Array dest, long long offset);
    474 
    475  /**
    476   * Close the file. Subsequent calls to readBytesInto will throw.
    477   * If the file is not closed manually, it will be closed once this object is GC'ed.
    478   */
    479  undefined close();
    480 };
    481 
    482 /**
    483 * Options to be passed to the |IOUtils.readUTF8| method.
    484 */
    485 dictionary ReadUTF8Options {
    486  /**
    487   * If true, this option indicates that the file to be read is compressed with
    488   * LZ4-encoding, and should be decompressed before the data is returned to
    489   * the caller.
    490   */
    491  boolean decompress = false;
    492 };
    493 
    494 /**
    495 * Options to be passed to the |IOUtils.read| method.
    496 */
    497 dictionary ReadOptions : ReadUTF8Options {
    498  /**
    499   * The offset into the file to read from. If unspecified, the file will be read
    500   * from the start.
    501   */
    502  unsigned long long offset = 0;
    503 
    504  /**
    505   * The max bytes to read from the file at path. If unspecified, the entire
    506   * file will be read. This option is incompatible with |decompress|.
    507   */
    508  unsigned long? maxBytes = null;
    509 };
    510 
    511 /**
    512 * Modes for writing to a file.
    513 */
    514 enum WriteMode {
    515  /**
    516   * Overwrite the contents of the file.
    517   *
    518   * The file will be created if it does not exist.
    519   */
    520  "overwrite",
    521  /**
    522   * Append to the end of the file.
    523   *
    524   * This mode will refuse to create the file if it does not exist.
    525   */
    526  "append",
    527  /**
    528   * Append to the end of the file, or create it if it does not exist.
    529   */
    530  "appendOrCreate",
    531  /**
    532   * Create a new file.
    533   *
    534   * This mode will refuse to overwrite an existing file.
    535   */
    536  "create",
    537 };
    538 
    539 /**
    540 * Options to be passed to the |IOUtils.write| and |writeUTF8|
    541 * methods.
    542 */
    543 dictionary WriteOptions {
    544  /**
    545   * If specified, backup the destination file to this path before writing.
    546   */
    547  DOMString backupFile;
    548  /**
    549   * If specified, write the data to a file at |tmpPath| instead of directly to
    550   * the destination. Once the write is complete, the destination will be
    551   * overwritten by a move. Specifying this option will make the write a little
    552   * slower, but also safer.
    553   */
    554  DOMString tmpPath;
    555  /**
    556   * The mode used to write to the file.
    557   */
    558  WriteMode mode = "overwrite";
    559  /**
    560   * If true, force the OS to write its internal buffers to the disk.
    561   * This is considerably slower for the whole system, but safer in case of
    562   * an improper system shutdown (e.g. due to a kernel panic) or device
    563   * disconnection before the buffers are flushed.
    564   */
    565  boolean flush = false;
    566  /**
    567   * If true, compress the data with LZ4-encoding before writing to the file.
    568   */
    569  boolean compress = false;
    570 };
    571 
    572 /**
    573 * Options to be passed to the |IOUtils.move| method.
    574 */
    575 dictionary MoveOptions {
    576  /**
    577   * If true, fail if the destination already exists.
    578   */
    579  boolean noOverwrite = false;
    580 };
    581 
    582 /**
    583 * Options to be passed to the |IOUtils.remove| method.
    584 */
    585 dictionary RemoveOptions {
    586  /**
    587   * If true, no error will be reported if the target file is missing.
    588   */
    589  boolean ignoreAbsent = true;
    590  /**
    591   * If true, and the target is a directory, recursively remove files.
    592   */
    593  boolean recursive = false;
    594 
    595  /**
    596   * If true, a failed delete on a readonly file will be retried by first
    597   * removing the readonly attribute.
    598   *
    599   * Only has an effect on Windows.
    600   */
    601  boolean retryReadonly = false;
    602 };
    603 
    604 /**
    605 * Options to be passed to the |IOUtils.makeDirectory| method.
    606 */
    607 dictionary MakeDirectoryOptions {
    608  /**
    609   * If true, create the directory and all necessary ancestors if they do not
    610   * already exist. If false and any ancestor directories do not exist,
    611   * |makeDirectory| will reject with an error.
    612   */
    613  boolean createAncestors = true;
    614  /**
    615   * If true, succeed even if the directory already exists (default behavior).
    616   * Otherwise, fail if the directory already exists.
    617   */
    618  boolean ignoreExisting = true;
    619  /**
    620   * The file mode to create the directory with.
    621   *
    622   * This is ignored on Windows.
    623   */
    624  unsigned long permissions = 0755;
    625 
    626 };
    627 
    628 /**
    629 * Options to be passed to the |IOUtils.copy| method.
    630 */
    631 dictionary CopyOptions {
    632  /**
    633   * If true, fail if the destination already exists.
    634   */
    635  boolean noOverwrite = false;
    636  /**
    637   * If true, copy the source recursively.
    638   */
    639  boolean recursive = false;
    640 };
    641 
    642 /**
    643 * Options to be passed to the |IOUtils.hasChildren| method.
    644 */
    645 dictionary HasChildrenOptions {
    646  /**
    647   * If true, no error will be reported if the target file is missing.
    648   */
    649  boolean ignoreAbsent = false;
    650 };
    651 
    652 /**
    653 * Options to be passed to the |IOUtils.getChildren| method.
    654 */
    655 dictionary GetChildrenOptions {
    656  /**
    657   * If true, no error will be reported if the target file is missing.
    658   */
    659  boolean ignoreAbsent = false;
    660 };
    661 
    662 /**
    663 * Types of files that are recognized by the |IOUtils.stat| method.
    664 */
    665 enum FileType { "regular", "directory", "other" };
    666 
    667 /**
    668 * Basic metadata about a file.
    669 */
    670 dictionary FileInfo {
    671  /**
    672   * The absolute path to the file on disk, as known when this file info was
    673   * obtained.
    674   */
    675  DOMString path;
    676 
    677  /**
    678   * Identifies if the file at |path| is a regular file, directory, or something
    679   * something else.
    680   */
    681  FileType type;
    682 
    683  /**
    684   * If this represents a regular file, the size of the file in bytes.
    685   * Otherwise, -1.
    686   */
    687  long long size;
    688 
    689  /**
    690   * The timestamp of file creation, represented in milliseconds since Epoch
    691   * (1970-01-01T00:00:00.000Z).
    692   *
    693   * This is only available on MacOS and Windows.
    694   */
    695  long long creationTime;
    696 
    697  /**
    698   * The timestmp of last file accesss, represented in milliseconds since Epoch
    699   * (1970-01-01T00:00:00.000Z).
    700   */
    701  long long lastAccessed;
    702 
    703  /**
    704   * The timestamp of the last file modification, represented in milliseconds
    705   * since Epoch (1970-01-01T00:00:00.000Z).
    706   */
    707  long long lastModified;
    708 
    709  /**
    710   * The permissions of the file, expressed as a UNIX file mode.
    711   *
    712   * NB: Windows does not make a distinction between user, group, and other
    713   * permissions like UNICES do. The user, group, and other parts will always
    714   * be identical on Windows.
    715   */
    716  unsigned long permissions;
    717 };
    718 
    719 /**
    720 * The supported hash algorithms for |IOUtils.hashFile|.
    721 */
    722 enum HashAlgorithm { "sha256", "sha384", "sha512" };
    723 
    724 #ifdef XP_WIN
    725 /**
    726 * Windows-specific file attributes.
    727 */
    728 dictionary WindowsFileAttributes {
    729  /**
    730   * Whether or not the file is read-only.
    731   */
    732  boolean readOnly;
    733  /**
    734   * Whether or not the file is hidden.
    735   */
    736  boolean hidden;
    737  /**
    738   * Whether or not the file is classified as a system file.
    739   */
    740  boolean system;
    741 };
    742 #endif
    743 
    744 #ifdef XP_UNIX
    745 /**
    746 * Used where the POSIX API allows an arbitrary byte string but in
    747 * practice it's usually UTF-8, so JS strings are accepted for
    748 * convenience.
    749 */
    750 typedef (UTF8String or Uint8Array) UnixString;
    751 
    752 /**
    753 * Options for the `launchApp` method.  See also `base::LaunchOptions`
    754 * in C++.
    755 */
    756 dictionary LaunchOptions {
    757  /**
    758   * The environment variables, as a sequence of `NAME=value` strings.
    759   * (The underlying C++ code can also inherit the current environment
    760   * with optional changes; that feature could be added here if needed.)
    761   */
    762  required sequence<UnixString> environment;
    763 
    764  /**
    765   * The initial current working directory.
    766   */
    767  UnixString workdir;
    768 
    769  /**
    770   * File descriptors to pass to the child process.  Any fds not
    771   * mentioned here, other than stdin/out/err, will not be inherited
    772   * even if they aren't marked close-on-exec.
    773   */
    774  sequence<FdMapping> fdMap;
    775 
    776  /**
    777   * On macOS 10.14+, disclaims responsibility for the child process
    778   * with respect to privacy/security permission prompts and
    779   * decisions.  Ignored if not supported by the OS.
    780   */
    781  boolean disclaim = false;
    782 };
    783 
    784 /**
    785 * Describes a file descriptor to give to the child process.
    786 */
    787 dictionary FdMapping {
    788  /**
    789   * The fd in the parent process to pass.  This must remain open during
    790   * the call to `launchApp` but can be closed after it returns (or throws).
    791   */
    792  required unsigned long src;
    793 
    794  /**
    795   * The fd number to map it to in the child process.
    796   */
    797  required unsigned long dst;
    798 };
    799 #endif