JanetDocsPlaygroundI'm feeling luckyGitHub sign in


    src/core/os.c on line 1848, column 1

    (os/stat path &opt tab|key)

    Gets information about a file or directory. Returns a table if the 
    second argument is a keyword, returns only that information from 
    stat. If the file or directory does not exist, returns nil. The 
    keys are:

    * :dev - the device that the file is on

    * :mode - the type of file, one of :file, :directory, :block, 
      :character, :fifo, :socket, :link, or :other

    * :int-permissions - A Unix permission integer like 8r744

    * :permissions - A Unix permission string like "rwxr--r--"

    * :uid - File uid

    * :gid - File gid

    * :nlink - number of links to file

    * :rdev - Real device of file. 0 on windows.

    * :size - size of file in bytes

    * :blocks - number of blocks in file. 0 on windows

    * :blocksize - size of blocks in file. 0 on windows

    * :accessed - timestamp when file last accessed

    * :changed - timestamp when file last changed (permissions changed)

    * :modified - timestamp when file last modified (content changed)

3 examplesSign in to add an example
(defn recent-mods
  "List the files in the current directory which have changed within the last hour."
    (fn [fname]
        (- (os/time) 3600)
        (os/stat fname :modified)))
    (os/dir ".")))
(defn ls-sockets
  "List the sockets in the current directory."
    (fn [fname] (= :socket (os/stat fname :mode)))
    (os/dir ".")))
(os/shell "touch foo")
(os/stat "foo" :modified)  # => 1593836002
(os/touch "foo")
(os/stat "foo" :modified)  # => 1593836013