5. Bigloo -- Standard Library 5.7 System programming

Browsing

Home: | Bigloo A ``practical Scheme compiler'' User manual for version 2.6b December 2003
Previous chapter: | Core Language
Next chapter: | Pattern Matching

Standard Library

5.1 | Scheme Library
| 5.1.1 | Booleans
| 5.1.2 | Equivalence predicates
| 5.1.3 | Pairs and lists
| 5.1.4 | Symbols
| 5.1.5 | Keywords
| 5.1.6 | Numbers
| 5.1.7 | Characters
| 5.1.8 | UCS-2 Characters
| 5.1.9 | Strings
| 5.1.10 | Unicode (UCS-2) Strings
| 5.1.11 | Vectors
| 5.1.12 | Control features
5.2 | Input and output
5.3 | Structures and Records
| 5.3.1 | Structures
| 5.3.2 | Records (SRFI-9)
5.4 | Serialization
5.5 | Bit manipulation
5.6 | Hash Tables
| 5.6.1 | Hash tables
| 5.6.2 | Deprecated Hash tables
5.7 | System programming
| 5.7.1 | Operating System interface
| 5.7.2 | Files
5.8 | Process support
5.9 | Socket support
5.10 | Date
5.11 | Posix Regular Expressions
| 5.11.1 | Regular Expressions Procedures
| 5.11.2 | Regular Expressions Pattern Language
| 5.11.3 | An Extended Example

Chapters

| Acknowledgements
1. | Table of contents
2. | Overview of Bigloo
3. | Modules
4. | Core Language
5. | Standard Library
6. | Pattern Matching
7. | Object System
8. | Threads
9. | Regular parsing
10. | Lalr(1) parsing
11. | Errors and Assertions
12. | Eval and code interpretation
13. | Macro expansion
14. | Command Line Parsing
15. | Explicit typing
16. | The C interface
17. | The Java interface
18. | Bigloo Libraries
19. | Extending the Runtime System
20. | SRFIs
21. | DSSSL support
22. | Compiler description
23. | User Extensions
24. | Bigloo Development Environment
25. | Global Index
26. | Library Index
| Bibliography

### 5.7.1 Operating System interface

register-exit-function! proc | bigloo procedure

Register `proc` as an exit functions. `Proc` is a procedure accepting of one argument. This argument is the numerical value which is the status of the exit call. The registered functions are called when the execution ends.

exit int | bigloo procedure

Apply all the registered exit functions then stops an execution, returning the integer `int`.

signal n proc | bigloo procedure

Provides a signal handler for the operating system dependent signal `n`. `proc` is a procedure of one argument.

get-signal-handler n | bigloo procedure

Returns the current handler associated with signal `n` or `#f` if no handler is installed.

system . strings | bigloo procedure

Append all the arguments `strings` and invoke the native host `system` command on that new string which returns an integer.

system->string . strings | bigloo procedure

Append all the arguments `strings` and invoke the native host `system` command on that new string. If the command completes, `system->string` returns a string made of the output of the command.

getenv string | bigloo procedure

Returns the string value of the Unix shell's `string` variable. If no such variable is bound, `getenv` returns `#f`.

putenv string val | bigloo procedure

Adds or modifies the global environment variable `string` so that it is bound to `val` after the call. This facility is not supported by all back-end. In particular, the JVM back-end does not support it.

date | bigloo procedure

Returns the current date in a `string`. See also Date.

sleep ms | bigloo procedure

Sleeps for a delay during at least `ms` microseconds.

command-line | bigloo procedure

Returns a list of strings which are the Unix command line arguments.

executable-name | bigloo procedure

Returns the name of the running executable.

os-class | bigloo procedure

Gives the OS class (e.g. `unix`).

os-name | bigloo procedure

Gives the OS name (e.g. `Linux`).

os-arch | bigloo procedure

Gives the host architecture (e.g. `i386`).

os-version | bigloo procedure

Gives the operating system version (e.g. `RedHat 2.0.27`).

os-tmp | bigloo procedure

Gives the regular temporary directory (e.g. `/tmp`).

file-separator | bigloo procedure

Gives the operating system file separator (e.g. `#\/`).

path-separator | bigloo procedure

Gives the operating system file path separator (e.g.`#\:`).

For additional functions (such as `directory->list`) see Input and Output.

unix-path->list | bigloo procedure

Converts a Unix path to a Bigloo list of strings.

    (unix-path->list ".")           => (".")
    (unix-path->list ".:/usr/bin")  => ("." "/usr/bin")

hostname | bigloo procedure

Returns the fully qualified name of the current host.

### 5.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.

basename string | bigloo procedure

Returns a copy of `string` where the longest prefix ending in `/` is deleted if any existed.

prefix string | bigloo procedure

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 of `string`. For instance:

    (prefix "foo.scm")
       => "foo"
    (prefix "./foo.scm")
       => "./foo"
    (prefix "foo.tar.gz")
       => "foo.tar"

suffix string | bigloo procedure

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"

dirname string | bigloo procedure

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")
       => "/"

pwd | bigloo procedure

Returns the current working directory.

chdir dir-name | bigloo procedure

Changes the current directory to `dir-name`. On success, `chdir` returns `#t`. On failure it returns `#f`.

make-file-name dir-name name | bigloo procedure

Make an absolute file-name from a directory name `dir-name` and a relative name `name`.

make-file-path dir-name name . names | bigloo procedure

Make an absolute file-name from a directory name `dir-name` and a relative name `name`s.

find-file/path name path | bigloo procedure

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

make-static-library-name name | bigloo procedure

Make a static library name from `name` by adding the static library regular suffix.

make-shared-library-name name | bigloo procedure

Make a shared library name from `name` by adding the shared library regular suffix.

file-exists? string | bigloo procedure

This procedure returns `#t` if the file `string` exists. Otherwise it returns `#f`.

delete-file string | bigloo procedure

Deletes the file named `string`. The result of this procedure is `#f` is the operation succeeded. The result is `#t` otherwise.

rename-file string1 string2 | bigloo procedure

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`.

directory? string | bigloo procedure

This procedure returns `#t` if the file `string` exists and is a directory. Otherwise it returns `#f`.

make-directory string | bigloo procedure

Creates a new directory named `string`. It returns `#t` if the directory was created. It returns `#f` otherwise.

make-directories string | bigloo procedure

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.

delete-directory string | bigloo procedure

Deletes the directory named `string`. The directory must be empty in order to be deleted. The result of this procedure is unspecified.

directory->list string | bigloo procedure

If file `string` exists and is a directory, this function returns the list of files in `string`.

file-modification-time string | bigloo procedure

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).

file-size string | bigloo procedure

Returns the size (in bytes) for file `string`.

chmod string [option] | bigloo procedure

Change the access mode of the file named `string`. The `option` must be either a list of the following symbols `read`, `write` and `execute` or an integer. If the operation succeeds, `chmod` returns `#t`. It returns `#f` otherwise.
Example:

    (chmod (make-file-name (getenv "HOME") ".bigloorc") 'read 'write)
    (chmod (make-file-name (getenv "HOME") ".bigloorc") #o777)

This Scribe page has been generated by `scribeinfo`.
Last update Tue Dec 16 13:46:41 2003