robertbira

Italian Translation Report: Node.js [Part 49 - 1320 words]

Nov 15th, 2018
231
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. The module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.
  2. To use this module:
  3. All file system operations have synchronous and asynchronous forms.
  4. The asynchronous form always takes a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be or
  5. Exceptions that occur using synchronous operations are thrown immediately and may be handled using, or may be allowed to bubble up.
  6. handle the error
  7. Note that there is no guaranteed ordering when using asynchronous methods. So the following is prone to error because the operation may complete before the operation
  8. To correctly order the operations, move the call into the callback of the operation:
  9. In busy processes, the programmer is strongly encouraged to use the asynchronous versions of these calls. The synchronous versions will block the entire process until they complete — halting all connections.
  10. While it is not recommended, most fs functions allow the callback argument to be omitted, in which case a default callback is used that rethrows errors. To get a trace to the original call site, set the environment variable:
  11. Omitting the callback function on asynchronous fs functions is deprecated and may result in an error being thrown in the future.
  12. File paths
  13. Most operations accept filepaths that may be specified in the form of a string, a, or a object using the protocol.
  14. String form paths are interpreted as UTF-8 character sequences identifying the absolute or relative filename.
  15. Relative paths will be resolved relative to the current working directory as specified by
  16. Example using an absolute path on POSIX:
  17. Example using a relative path on POSIX (relative to
  18. Paths specified using a are useful primarily on certain POSIX operating systems that treat file paths as opaque byte sequences.
  19. On such systems, it is possible for a single file path to contain sub-sequences that use multiple character encodings.
  20. As with string paths, paths may be relative or absolute:
  21. Note: On Windows Node.js follows the concept of per-drive working directory. This behavior can be observed when using a drive path without a backslash.
  22. For example can potentially return a different result than
  23. For more information, see this MSDN page.
  24. URL object support
  25. For most module functions, the or argument may be passed as a object.
  26. Only objects using the protocol are supported.
  27. URLs are always absolute paths.
  28. Using objects might introduce platform-specific behaviors.
  29. On Windows, URLs with a hostname convert to UNC paths, while URLs with drive letters convert to local absolute paths.
  30. URLs without a hostname nor a drive letter will result in a throw:
  31. On Windows
  32. with hostname convert to UNC path
  33. with drive letters convert to absolute path
  34. without hostname must have a drive letters
  35. File URL path must be absolute
  36. URLs with drive letters must use as a separator just after the drive letter.
  37. Using another separator will result in a throw.
  38. On all other platforms, URLs with a hostname are unsupported and will result in a throw:
  39. On other platforms:
  40. with hostname are unsupported
  41. must be absolute
  42. convert to absolute path
  43. A URL having encoded slash characters will result in a throw on all platforms:
  44. File URL path must not include encoded or characters
  45. On POSIX
  46. On Windows, URLs having encoded backslash will result in a throw:
  47. File Descriptors
  48. On POSIX systems, for every process, the kernel maintains a table of currently open files and resources. Each open file is assigned a simple numeric identifier called a file descriptor. At the system-level, all file system operations use these file descriptors to identify and track each specific file. Windows systems use a different but conceptually similar mechanism for tracking resources. To simplify things for users, Node.js abstracts away the specific differences between operating systems and assigns all open files a numeric file descriptor.
  49. The method is used to allocate a new file descriptor.
  50. Once allocated, the file descriptor may be used to read data from, write data to, or request information about the file.
  51. use stat always close the file descriptor!
  52. Most operating systems limit the number of file descriptors that may be open at any given time so it is critical to close the descriptor when operations are completed. Failure to do so will result in a memory leak that will eventually cause an application to crash.
  53. Threadpool Usage
  54. Note that all file system APIs except and those that are explicitly synchronous use libuv's threadpool, which can have surprising and negative performance implications for some applications, see the documentation for more information.
  55. A successful call to method will return a new object.
  56. All objects are that will emit a event whenever a specific watched file is modified.
  57. The type of change event that has occurred
  58. The filename that changed (if relevant/available)
  59. Emitted when something changes in a watched directory or file.
  60. See more details in
  61. The argument may not be provided depending on operating system support.
  62. If is provided, it will be provided as a if is called with its option set to, otherwise will be a UTF-8 string.
  63. Example when handled through listener
  64. Emitted when the watcher stops watching for changes.
  65. Emitted when an error occurs while watching the file.
  66. Stop watching for changes on the given
  67. Once stopped, the object is no longer usable.
  68. All objects are
  69. Emitted when the underlying file descriptor has been closed.
  70. Integer file descriptor used by the
  71. Emitted when the file descriptor has been opened.
  72. Emitted when the is ready to be used.
  73. Fires immediately after
  74. The number of bytes that have been read so far.
  75. The path to the file the stream is reading from as specified in the first argument to
  76. If is passed as a string, then will be a string.
  77. If is passed as a, then will be a
  78. A object provides information about a file.
  79. Objects returned from and their synchronous counterparts are of this type.
  80. Returns
  81. Returns if the object describes a block device.
  82. a character device.
  83. a file system directory.
  84. a first-in-first-out (FIFO) pipe.
  85. a regular file.
  86. a socket.
  87. a symbolic link.
  88. This method is only valid when using
  89. The numeric identifier of the device containing the file.
  90. The file system specific "Inode" number for the file.
  91. A bit-field describing the file type and mode.
  92. The number of hard-links that exist for the file.
  93. The numeric user identifier of the user that owns the file (POSIX).
  94. The numeric group identifier of the group that owns the file (POSIX).
  95. A numeric device identifier if the file is considered "special".
  96. The size of the file in bytes.
  97. The file system block size for i/o operations.
  98. The number of blocks allocated for this file.
  99. The timestamp indicating the last time this file was accessed expressed in milliseconds since the POSIX Epoch.
  100. The timestamp indicating the last time this file was accessed.
  101. Stat Time Values
  102. The properties are numbers that hold the corresponding times in milliseconds.
  103. Their precision is platform specific.
  104. and are object alternate representations of the various times.
  105. The and number values are not connected.
  106. Assigning a new number value, or mutating the value, will not be reflected in the corresponding alternate representation.
  107. The times in the stat object have the following semantics:
  108. "Access Time" - Time when file data last accessed.
  109. Changed by the and system calls.
  110. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the
  111. Note that this value may be greater than or in this case.
  112. On Darwin and other FreeBSD variants, also set if the is explicitly set to an earlier value than the current using the system call.
  113. Prior to Node.js v0.12, the held the on Windows systems.
  114. Note that as of v0.12, is not "creation time", and on Unix systems, it never was.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×