NodeFileSystemDirectoryHandle.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { NodeFileSystemHandle } from './NodeFileSystemHandle';
  2. import type { NodeFsaContext, NodeFsaFs } from './types';
  3. import type { GetDirectoryHandleOptions, GetFileHandleOptions, IFileSystemDirectoryHandle, IFileSystemFileHandle, RemoveEntryOptions } from '../fsa/types';
  4. /**
  5. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle
  6. */
  7. export declare class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle implements IFileSystemDirectoryHandle {
  8. protected readonly fs: NodeFsaFs;
  9. protected readonly ctx: Partial<NodeFsaContext>;
  10. /** Directory path with trailing slash. */
  11. readonly __path: string;
  12. constructor(fs: NodeFsaFs, path: string, ctx?: Partial<NodeFsaContext>);
  13. /**
  14. * Returns a new array iterator containing the keys for each item in
  15. * {@link NodeFileSystemDirectoryHandle} object.
  16. *
  17. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/keys
  18. */
  19. keys(): AsyncIterableIterator<string>;
  20. /**
  21. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries
  22. */
  23. entries(): AsyncIterableIterator<[string, NodeFileSystemHandle]>;
  24. /**
  25. * Returns a new array iterator containing the values for each index in the
  26. * {@link FileSystemDirectoryHandle} object.
  27. *
  28. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/values
  29. */
  30. values(): AsyncIterableIterator<NodeFileSystemHandle>;
  31. /**
  32. * Returns a {@link NodeFileSystemDirectoryHandle} for a subdirectory with the specified
  33. * name within the directory handle on which the method is called.
  34. *
  35. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle
  36. * @param name A string representing the {@link NodeFileSystemHandle} name of
  37. * the subdirectory you wish to retrieve.
  38. * @param options An optional object containing options for the retrieved
  39. * subdirectory.
  40. */
  41. getDirectoryHandle(name: string, options?: GetDirectoryHandleOptions): Promise<IFileSystemDirectoryHandle>;
  42. /**
  43. * Returns a {@link FileSystemFileHandle} for a file with the specified name,
  44. * within the directory the method is called.
  45. *
  46. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle
  47. * @param name A string representing the {@link NodeFileSystemHandle} name of
  48. * the file you wish to retrieve.
  49. * @param options An optional object containing options for the retrieved file.
  50. */
  51. getFileHandle(name: string, options?: GetFileHandleOptions): Promise<IFileSystemFileHandle>;
  52. /**
  53. * Attempts to remove an entry if the directory handle contains a file or
  54. * directory called the name specified.
  55. *
  56. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry
  57. * @param name A string representing the {@link FileSystemHandle} name of the
  58. * entry you wish to remove.
  59. * @param options An optional object containing options.
  60. */
  61. removeEntry(name: string, { recursive }?: RemoveEntryOptions): Promise<void>;
  62. /**
  63. * The `resolve()` method of the {@link FileSystemDirectoryHandle} interface
  64. * returns an {@link Array} of directory names from the parent handle to the specified
  65. * child entry, with the name of the child entry as the last array item.
  66. *
  67. * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/resolve
  68. * @param possibleDescendant The {@link NodeFileSystemFileHandle} from which
  69. * to return the relative path.
  70. */
  71. resolve(possibleDescendant: NodeFileSystemHandle): Promise<string[] | null>;
  72. }