[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.7.2 Files
See Input and output for file and directory handling. This section only deals with name handling. Four procedures exist to manipulate Unix filenames.
- bigloo procedure: basename string
Returns a copy of string where the longest prefix ending in ‘/’ is deleted if any existed.
- bigloo procedure: prefix string
Returns a copy of string where the suffix starting by the char ‘#\.’ is deleted. If no prefix is found, the result of
prefix
is a copy ofstring
. For instance:(prefix "foo.scm") ⇒ "foo" (prefix "./foo.scm") ⇒ "./foo" (prefix "foo.tar.gz") ⇒ "foo.tar"
- bigloo procedure: suffix string
Returns a new string which is the suffix of string. If no suffix is found, this function returns an empty string. For instance,
(suffix "foo.scm") ⇒ "scm" (suffix "./foo.scm") ⇒ "scm" (suffix "foo.tar.gz") ⇒ "gz"
- bigloo procedure: dirname string
Returns a new string which is the directory component of string. For instance:
(dirname "abc/def/ghi") ⇒ "abc/def" (dirname "abc") ⇒ "." (dirname "abc/") ⇒ "abc" (dirname "/abc") ⇒ "/"
- bigloo procedure: chdir dir-name
Changes the current directory to dir-name. On success,
chdir
returns#t
. On failure it returns#f
.
- bigloo procedure: make-file-name dir-name name
Make an absolute file-name from a directory name dir-name and a relative name name.
- bigloo procedure: make-file-path dir-name name . names
Make an absolute file-name from a directory name dir-name and a relative name names.
- bigloo procedure: file-name->list name
Explodes a file name into a list.
(file-name->list "/etc/passwd") ⇒ '("" "etc" "passwd") (file-name->list "etc/passwd") ⇒ '("etc" "passwd")
- bigloo procedure: file-name-canonicalize name
- bigloo procedure: file-name-canonicalize! name
- bigloo procedure: file-name-unix-canonicalize name
- bigloo procedure: file-name-unix-canonicalize! name
-
Canonicalizes a file name. If the file name is malformed this function raises an
&io-malformed-url-error
exception.The function
file-name-canonicalize!
may returns its argument if no changes in the string is needed. Otherwise, asfile-name-canonicalize
is returns a new string.In addition to handling
..
directory name, the functionfile-name-unix-canonicalize
also handles the~
character.(file-name-canonicalize "/etc/passwd") ⇒ "/etc/passwd" (file-name-canonicalize "/etc/../tmp/passwd") ⇒ "/tmp/passwd" (file-name-canonicalize "~/passwd") ⇒ "~/passwd" (file-name-unix-canonicalize "~/passwd") ⇒ "/home/a-user/passwd" (file-name-unix-canonicalize "~foo/passwd") ⇒ "/home/foo/passwd"
- bigloo procedure: relative-file-name name base
Builds a file name relative to base.
(relative-file-name "/etc/passwd" "/etc" ⇒ "passwd"
- bigloo procedure: find-file/path name path
Search, in sequence, in the directory list path for the file name. If name is an absolute name, then path is not used to find the file. If name is a relative name, the function
make-file-name
is used to build absolute name from name and the directories in path. The current path is not included automatically in the list of path. In consequence, to check the current directory one may add"."
to the path list. On success, the absolute file name is returned. On failure,#f
is returned. Example:(find-file/path "/etc/passwd" '("/toto" "/titi")) ⇒ "/etc/passwd" (find-file/path "passwd" '("/toto" "/etc")) ⇒ "/etc/passwd" (find-file/path "pass-wd" '("." "/etc")) ⇒ #f
- bigloo procedure: make-static-library-name name
Make a static library name from name by adding the static library regular suffix.
- bigloo procedure: make-shared-library-name name
Make a shared library name from name by adding the shared library regular suffix.
- bigloo procedure: file-exists? string
This procedure returns
#t
if the file (respectively directory, and link) string exists. Otherwise it returns#f
.
- bigloo procedure: file-gzip? string
This procedure returns
#t
if and only if the file string exists and can be unzip by Bigloo. Otherwise it returns#f
.
- bigloo procedure: delete-file string
Deletes the file named string. The result of this procedure is
#t
is the operation succeeded. The result is#f
otherwise.
- bigloo procedure: rename-file string1 string2
Renames the file string1 as string2. The two files have to be located on the same file system. If the renaming succeeds, the result is
#t
, otherwise it is#f
.
- bigloo procedure: copy-file string1 string2
Copies the file string1 into string2. If the copy succeeds, the result is
#t
, otherwise it is#f
.
- bigloo procedure: directory? string
This procedure returns
#t
if the file string exists and is a directory. Otherwise it returns#f
.
- bigloo procedure: make-directory string
Creates a new directory named string. It returns
#t
if the directory was created. It returns#f
otherwise.
- bigloo procedure: make-directories string
Creates a new directory named string, including any necessary but nonexistent parent directories. It returns
#t
if the directory was created. It returns#f
otherwise. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
- bigloo procedure: delete-directory string
Deletes the directory named string. The directory must be empty in order to be deleted. The result of this procedure is unspecified.
- bigloo procedure: directory->list string
- bigloo procedure: directory->path-list string
If file string exists and is a directory, the function
directory->list
returns the list of files in string. The functiondirectory->path-list
returns a list of files whose dirname is string.
- bigloo procedure: file-modification-time string
The date (in second) of the last modification for file string. The number of seconds is represented by a value that may be converted into a date by the means of
seconds->date
(see Date).
- bigloo procedure: file-size string
Returns the size (in bytes) for file string. The return type is
long
. If an full-sized integer is needed, one may write:(let ((sz::llong (file-size <PATH>))) ...) On error,
-1
is returned.
- bigloo procedure: file-uid string
- bigloo procedure: file-gid string
The functions return the user id (an integer) and group id (an integer) for file string. On error,
-1
is returned.
- bigloo procedure: file-mode string
Returns the file access mode (an integer). On error
-1
is returned.
- bigloo procedure: file-type string
Returns the file type (a symbol). The possible returned values are:
-
regular
-
directory
-
link
-
block
-
fifo
-
character
-
socket
-
resource
-
unknown
-
does-not-exist
-
- bigloo procedure: chmod string [option]
Change the access mode of the file named string. The option must be either a list of the following symbols
read
,write
andexecute
or an integer. If the operation succeeds,chmod
returns#t
. It returns#f
otherwise. The argument option can also be an integer that represents the native file permission. Example:(chmod (make-file-name (getenv "HOME") ".bigloorc") 'read 'write) (chmod (make-file-name (getenv "HOME") ".bigloorc") #o777)
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.