FileInfo.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. export declare enum FileType {
  2. Unknown = 0,
  3. File = 1,
  4. Directory = 2,
  5. SymbolicLink = 3
  6. }
  7. export interface UnixPermissions {
  8. readonly user: number;
  9. readonly group: number;
  10. readonly world: number;
  11. }
  12. /**
  13. * Describes a file, directory or symbolic link.
  14. */
  15. export declare class FileInfo {
  16. name: string;
  17. static UnixPermission: {
  18. Read: number;
  19. Write: number;
  20. Execute: number;
  21. };
  22. type: FileType;
  23. size: number;
  24. /**
  25. * Unparsed, raw modification date as a string.
  26. *
  27. * If `modifiedAt` is undefined, the FTP server you're connected to doesn't support the more modern
  28. * MLSD command for machine-readable directory listings. The older command LIST is then used returning
  29. * results that vary a lot between servers as the format hasn't been standardized. Here, directory listings
  30. * and especially modification dates were meant to be human-readable first.
  31. *
  32. * Be careful when still trying to parse this by yourself. Parsing dates from listings using LIST is
  33. * unreliable. This library decides to offer parsed dates only when they're absolutely reliable and safe to
  34. * use e.g. for comparisons.
  35. */
  36. rawModifiedAt: string;
  37. /**
  38. * Parsed modification date.
  39. *
  40. * Available if the FTP server supports the MLSD command. Only MLSD guarantees dates than can be reliably
  41. * parsed with the correct timezone and a resolution down to seconds. See `rawModifiedAt` property for the unparsed
  42. * date that is always available.
  43. */
  44. modifiedAt?: Date;
  45. /**
  46. * Unix permissions if present. If the underlying FTP server is not running on Unix this will be undefined.
  47. * If set, you might be able to edit permissions with the FTP command `SITE CHMOD`.
  48. */
  49. permissions?: UnixPermissions;
  50. /**
  51. * Hard link count if available.
  52. */
  53. hardLinkCount?: number;
  54. /**
  55. * Link name for symbolic links if available.
  56. */
  57. link?: string;
  58. /**
  59. * Unix group if available.
  60. */
  61. group?: string;
  62. /**
  63. * Unix user if available.
  64. */
  65. user?: string;
  66. /**
  67. * Unique ID if available.
  68. */
  69. uniqueID?: string;
  70. constructor(name: string);
  71. get isDirectory(): boolean;
  72. get isSymbolicLink(): boolean;
  73. get isFile(): boolean;
  74. /**
  75. * Deprecated, legacy API. Use `rawModifiedAt` instead.
  76. * @deprecated
  77. */
  78. get date(): string;
  79. set date(rawModifiedAt: string);
  80. }