Node: File Primitives, Next: , Previous: System Procedures, Up: System Procedures



File Primitives

temporary-file-name STKLOS Procedure
Generates a unique temporary file name. The value returned by temporary-file-name is the newly generated name of #f if a unique name cannot be generated.

rename-file string1 string2 STKLOS Procedure
Renames the file whose path-name is string1 to a file whose path-name is string2. The result of rename-file is void.

remove-file string STKLOS Procedure
Removes the file whose path name is given in string. The result of remove-file is void.

copy-file string1 string2 STKLOS Procedure
Copies the file whose path-name is string1 to a file whose path-name is string2. If the file string2 already exists, its content prior the call to copy-file is lost. The result of copy-file is void.

file-is-directory? string STKLOS Procedure
file-is-regular? string STKLOS Procedure
file-is-readable? string STKLOS Procedure
file-is-writable? string STKLOS Procedure
file-is-executable? string STKLOS Procedure
file-exists? string STKLOS Procedure
Returns #t if the predicate is true for the path name given in string; returns #f otherwise (or if string denotes a file which does not exist).

getcwd STKLOS Procedure
Returns a string containing the current working directory.

chdir dir STKLOS Procedure
Changes the current directory to the directory given in string dir.

expand-file-name path STKLOS Procedure
Expand-file-name expands the filename given in path to an absolute path.
            ;; Current directory is ~eg/STklos (i.e. /users/eg/STklos)
            (expand-file-name "..")            => "/users/eg"
            (expand-file-name "~eg/../eg/bin") => "/users/eg/bin"
            (expand-file-name "~/STklos)"      => "/users/eg/STk"
          

canonical-file-name path STKLOS Procedure
Expands all symbolic links in path and returns its canonicalized absolute path name. The resulting path does not have symbolic links. If path doesn't designate a valid path name, canonical-file-name returns #f.

decompose-file-name string STKLOS Procedure
Returns an "exploded" list of the path name components given in string. The first element in the list denotes if the given string is an absolute path or a relative one, being "/" or "." respectively. Each component of this list is a string.
          (decompose-file-name "/a/b/c.stk") => ("/" "a" "b" "c.stk")
          (decompose-file-name "a/b/c.stk")  => ("." "a" "b" "c.stk")
          

basename str STKLOS Procedure
Returns a string containing the last component of the path name given in str.
          (basename "/a/b/c.stk") => "c.stk"
          

dirname str STKLOS Procedure
Returns a string containing all but the last component of the path name given in str.
          (dirname "/a/b/c.stk") => "/a/b"
          

file-separator STKLOS Procedure
Retuns the operating system file file separator as a character.

make-path dirname name STKLOS Procedure
Builds a file name from the directory dirname and name.

glob pattern ... STKLOS Procedure
Glob performs file name "globbing" in a fashion similar to the csh shell. Glob returns a list of the filenames that match at least one of pattern arguments. The pattern arguments may contain the following special characters:
  • ? Matches any single character.
  • * Matches any sequence of zero or more characters.
  • [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match.
  • \\ Matches the character x.
  • {a,b,...} Matches any of the strings a, b, etc.

As with csh, a '.' at the beginning of a file's name or just after a '/ must be matched explicitly or with a {} construct. In addition, all '/' characters must be matched explicitly.

If the first character in a pattern is '~' then it refers to the home directory of the user whose name follows the '~'. If the '~' is followed immediately by `/' then the value of the environment variable HOME is used.

Glob differs from csh globbing in two ways. First, it does not sort its result list (use the sort procedure if you want the list sorted). Second, glob only returns the names of files that actually exist; in csh no check for existence is made unless a pattern contains a ?, *, or {} construct.