Liking cljdoc? Tell your friends :D

cljs-node-io.file

Global Functions

  • File(^str path) -> File

  • File(^Uri path) -> File

  • File(^str parent ^str child) -> File

  • File(^File parent ^str child) -> File

  • createTempFile(^String prefix) -> File

  • createTempFile(^String prefix, ^String suffix) -> File

  • createTempFile(^String prefix, ^String suffix, ^File directory) -> File

    • Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. If directory is specified, reates a new empty file in the specified directory.
    • suffix defaults to ".tmp". use "" to create tempdirs
    • nothing is written to disk yet, same as regular files
    • Returns a file object for the temp file

File Methods

  • [x] createNewFile() -> boolean

    • [x] Test
    • Atomically creates a new, empty file named by this abstract pathname iff a file with this name does not yet exist.
    • Returns true if the named file does not exist and was successfully created; false if the named file already exists
    • synchronous
  • [x] delete() -> boolean

    • [x] tested for files
    • [x] tested for directories
    • Deletes the file or directory denoted by this abstract pathname.
    • If this pathname denotes a directory, then the directory must be empty in order to be deleted.
    • synchronous
  • [x] deleteOnExit() -> void

    • Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
  • [x] equals(Object obj) -> boolean

    • Tests this abstract pathname for equality with the given object.
  • [x] exists() -> boolean

    • Tests whether the file or directory denoted by this abstract pathname exists.
  • [x] getAbsoluteFile() -> :File

    • Returns the absolute form of this abstract pathname.
  • [x] getAbsolutePath() -> String

    • Returns the absolute pathname string of this abstract pathname.
  • [x] getCanonicalFile() -> :File

    • Returns the canonical form of this abstract pathname.
  • [x] getCanonicalPath() -> String

    • Returns the canonical pathname string of this abstract pathname.
  • [x] getName() -> string

    • Returns the name of the file or directory denoted by this abstract pathname.
  • [x] getParent() -> string

    • Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
  • [x] getParentFile() -> :File

    • Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
  • [x] getPath() -> String

    • Converts this abstract pathname into a pathname string.
  • [x] hashCode() -> int

    • just uses cljs's hash function on the path string
    • Computes a hash code for this abstract pathname.
  • [x] isAbsolute() -> boolean

    • Tests whether this abstract pathname is absolute.
  • [x] isDirectory() -> boolean

    • Tests whether the file denoted by this abstract pathname is a directory.
  • [x] isFile() -> boolean

    • Tests whether the file denoted by this abstract pathname is a normal file.
  • [x] lastModified() -> ~~long~~ Int

    • Returns the time that the file denoted by this abstract pathname was last modified.
    • A value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0 if the file does not exist or if an I/O error occurs
  • [x] length() -> ~~long~~ Int | nil

    • If this pathname denotes a directory -> nil
    • The length, in bytes, of the file denoted by this abstract pathname, or 0 if the file does not exist.
  • [x] list() -> ~~String[]~~ Vector | nil

    • [x] tested
    • If this abstract pathname does not denote a directory, or if an I/O error occurs. -> nil
    • Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
    • The array will be empty if the directory is empty.
  • [x] list( filenameFilterFn ) -> ~~String[]~~ Vector | nil

    • [x] tested
    • Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
    • filterfn(^File dir ^string name) -> boolean, true for files/dirs you wish to keep
  • [x] listFiles() -> ~~File[]~~ Vector

    • [x] tested
    • Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
    • sugar for (.list f (fn [d name] (file? name)))
  • [x] listFiles( filenameFilterFn ) -> ~~File[]~~ Vector

    • [x] tested
    • Returns an array of abstract pathnames denoting the Files in the directory denoted by this abstract pathname that satisfy the specified filter.
    • filterfn(^File dir ^string filename) -> boolean, true for files you wish to keep
    • use (as-file name-str) to get file-filtering behavior
  • [x] mkdir() -> boolean

    • [x] tested
    • Creates the directory named by this abstract pathname.
    • true if and only if the directory was created; false otherwise
  • [x] mkdirs() -> boolean

    • [x] tested
    • Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Inclusively creates the last path destination too... consider core/make-parents if this was not your intent.
    • true iff the directory was created, along with all necessary parent directories; false otherwise
    • Note: if fails, it may have succeeded in creating some of the necessary parent directories.
  • [x] renameTo(^string dest) -> boolean

    • Renames the file denoted by this abstract pathname.
    • true if and only if the renaming succeeded; false otherwise
  • [x] toString() -> String

    • Returns the pathname string of this abstract pathname.
  • [x] toURI() -> Uri

    • Constructs a file: URI that represents this abstract pathname.
  • [x] canExecute() -> boolean

    • [ ] test
    • Return: true iff file specified by this abstract pathname exists and the application is allowed to execute the file
    • Tests whether the application can execute the file denoted by this abstract pathname.
    • has no effect on Windows
    • synchronous
  • [x] canRead() -> boolean

    • [ ] test
    • Tests whether the application can read the file denoted by this abstract pathname.
    • Return: true iff file specified by this abstract pathname exists and can be read by the application; false otherwise
    • synchronous
  • [x] canWrite() -> boolean

    • [ ] Test
    • Tests whether the application can modify the file denoted by this abstract pathname.
    • Return: true iff file specified by this abstract pathname exists and the application is allowed to execute the file
    • synchronous
  • [x] setReadable(boolean readable) -> boolean

    • A convenience method to set the owner's read permission for this abstract pathname.
  • [x] setReadable(boolean readable, boolean ownerOnly) -> boolean

    • Sets the owner's or everybody's read permission for this abstract pathname.
  • [x] setWritable(boolean writable) -> boolean

    • A convenience method to set the owner's write permission for this abstract pathname.
  • [x] setWritable(boolean writable, boolean ownerOnly) -> boolean

    • Sets the owner's or everybody's write permission for this abstract pathname.
  • [x] setExecutable(boolean executable) -> boolean

    • A convenience method to set the owner's execute permission for this abstract pathname.
  • [x] setExecutable(boolean executable, boolean ownerOnly) -> boolean

    • Sets the owner's or everybody's execute permission for this abstract pathname.
  • [x] setReadOnly() -> boolean

    • Marks the file or directory named by this abstract pathname so that only read operations are allowed.
  • [x] setLastModified(long time) -> boolean

    • Sets the last-modified time of the file or directory named by this abstract pathname.
  • [x] isHidden() -> boolean

    • Tests whether the file named by this abstract pathname is a hidden file.

not implemented :

  • compareTo
  • listFiles(FileFilter filterfn)
  • toPath
  • getFreeSpace
  • getTotalSpace
  • getUsableSpace

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close