srfi.170
- POSIX API ¶このモジュールは、ファイルシステムインタフェースを中心としたPOSIX APIの一部を ポータブルなインタフェースとして提供します。
GaucheではこのモジュールはGaucheのネイティブシステムインタフェース (システムインタフェース)の薄いラッパーになっています。 ポータブルなコードを書く場合にこのモジュールは便利でしょう。
[SRFI-170]{srfi.170
}
objがPOSIXレイヤから投げられたコンディションである場合に#t
を返します。
Gaucheeでは、POSIXレイヤのコンディションは<system-error>
の
インスタンスです (コンディション参照)。
[SRFI-170]{srfi.170
}
引数はPOSIX層のコンディション、つまりposix-error?
を満たすオブジェクトで
なければなりません。Gaucheではそれは<system-error>
オブジェクトです。
与えられたコンディションのPOSIXエラー名をシンボルで返します
(例: ENOENT
)。
sys-errno->symbol
も参照してください
(システムへの問い合わせ)。
[SRFI-170]{srfi.170
}
引数はPOSIX層のコンディション、つまりposix-error?
を満たすオブジェクトで
なければなりません。Gaucheではそれは<system-error>
オブジェクトです。
与えられたコンディションのPOSIXエラーメッセージを文字列で返します
(例: "No such file or directory"
)。
sys-strerror
も参照してください
(システムへの問い合わせ)。
[SRFI-170]{srfi.170
}
Opens a file named by fname and returns a port to read or write
the file. You have finer control than
open-input-file
/open-output-file
.
The port-type
argument must be either one of the value
of the constant binary-input
, textual-input
,
binary-output
, textual-output
and
binary-input/output
. The direction of the returned port
is determined by this argument.
Gauche doesn’t distinguish textual ports and binary ports.
The flags argument is a bitwise ior of
zero or more of the following bitmasks:
open/append
, open/create
, open/exclusive
,
open/nofollow
and open/truncate
. These corresponds
to the POSIX flags O_APPEND
, O_CREAT
, O_EXCL
,
O_NOFOLLOW
and O_TRUNC
. Gauche exposes the POSIX flags
in gauche.fcntl
(see gauche.fcntl
- 低レベルファイル操作).
Note: POSIX open(2)
also requires one of the bitmasks
O_RDONLY
, O_WRONLY
and O_RDWR
. These flags
are deduced from the port-type argument.
The optional permission is an integer permission bits
to be used when a new file is created. The actual permission bits
are also affected by the current umask
.
The optional buffer-mode is a value of either one of the followings:
buffer-none
, buffer-block
, and buffer-line
.
[SRFI-170]{srfi.170
}
Creates a Scheme port wrapping an integer file descriptor fd.
The descriptor shouldn’t be used by other Scheme ports. After calling
this procedure, no I/O should be done via fd directly; the descriptor
is “owned” by the port, and will be closed once the port is closed.
The port-type
argument must be either one of the value
of the constant binary-input
, textual-input
,
binary-output
, textual-output
and
binary-input/output
. The direction must match how fd was
opened.
The optional buffer-mode is a value of either one of the followings:
buffer-none
, buffer-block
, and buffer-line
.
[SRFI-170]{srfi.170
}
Constants to be used as port-type argument of
open-file
and fd->port
.
[SRFI-170]{srfi.170
}
Constants to be used as buffer-mode argument of
open-file
and fd->port
.
[SRFI-170]{srfi.170
}
Bitmask constants to be used as flags argument of
open-file
.
[SRFI-170]{srfi.170
}
Corresponds to Gauche’s built-in sys-mkdir
, sys-mkfifo
,
sys-link
and sys-symlink
.
The default value of permission is #o775
for
create-directory
, and #o664
for create-fifo
(It’s not optoinal for Gauche’s built-in).
On Windows, create-fifo
and create-symlink
are
not supported. Procedures exist, but raise an error when called.
[SRFI-170]{srfi.170
}
Gauche’s sys-readlink
.
[SRFI-170]{srfi.170
}
Gauche’s sys-rename
.
[SRFI-170]{srfi.170
}
Gauche’s sys-rmdir
. The directory must be empty.
To remove directory that may not be empty,
you can use delete-directory*
in file.util
(see ディレクトリユーティリティ).
[SRFI-170]{srfi.170
}
Gauche’s sys-chown
. The uid and gid arguments
should be an integer uid/gid, or the value of the constant
owner/unchanged
and group/unchanged
, respectively,
to indicate to keep the original value.
[SRFI-170]{srfi.170
}
Constants to be passed as uid and gid arguments
of set-file-owner
, respectively.
[SRFI-170]{srfi.170
}
Gauche’s sys-utime
. The atime and mtime
arguments must be a <time>
object (see 時間), or
either one of the values of constants time/now
or
time/unchanged
. The constant time/now
indicates the time when the procedure is called,
and the constant time/unchanged
indicates the
corresponding timestamp remains the same.
[SRFI-170]{srfi.170
}
Constants that can be passed to atime and mtime
arguments of set-file-times
.
[SRFI-170]{srfi.170
}
The first argument can be a string filename or a open port associated
to a file. If it is a filename, sys-truncate
is called,
and if it is a port, sys-ftruncate
is called.
[SRFI-170]{srfi.170
}
Gauche’s sys-stat
, sys-lstat
or sys-fstat
.
The first argument can be a string filename or a open port associated
to a file. If it is a filename, sys-stat
or sys-lstat
is called depending on whether follow? is #t
or #f
.
If it is a port, sys-fstat
is called.
Returns a file-info object, which is a <sys-stat>
instance
in Gauche (see ファイルの状態).
[SRFI-170]{srfi.170
}
Returns #t
iff obj is a file-info object, which is
a <sys-stat>
instance in Gauche (see ファイルの状態).
[SRFI-170]{srfi.170
}
Accessorso of file-info object (<sys-stat>
) (see ファイルの状態).
Access its dev
, ino
, mode
, nlink
,
uid
, gid
, rdev
, size
,
blksize
, blocks
, atim
, mtim
, ctim
slots, respectively.
Note: <sys-stat>
’s atime
, mtime
and ctime
contains integer for the backward compatibility, while
file-info:atime
, file-info:mtime
and file-info:ctime
returns <time>
object.
[SRFI-170]{srfi.170
}
Returns true iff the file-info object (<sys-stat>
is of the
respective type. (file-info-device?
returns true if
the file is either block or character device).
It corresponds to the type
slot of <sys-stat>
.
[SRFI-170]{srfi.170
}
Gauche’s sys-chmod
.
[SRFI-170]{srfi.170
}
Returns a list of filenames in the directory named dir.
Similar to directory-list
in file.util
(see ディレクトリユーティリティ), but (1) it never includes
.
and ..
(as true value is given to :children?
argument of directory-list
), and (2) it doesn’t include
files beginning with .
by default, unless dotfiles?
is true.
[SRFI-170]{srfi.170
}
Returns a generator (see gauche.generator
- ジェネレータ) that generates file names
in the directory named dir. The names never include
.
and ..
, and the filenames beginning with .
is
omitted unless dotfiles? is true.
[SRFI-170]{srfi.170
}
This is a directory scanner API more close to POSIX opendir
,
readdir
and closedir
. A directory object is opened
with open-directory
, and its entries (filenames) can be read
one by one using read-directory
. If the file names are exausted,
read-directory
returns an EOF object. A directory object
must be closed with close-directory
.
The filenames to be retrieved are the same as directory-files
; that is,
.
and ..
are never included, and names beginning with .
is exluded unless dotfiles? is true.
[SRFI-170]{srfi.170
}
Gauche’s sys-realpath
.
[SRFI-170]{srfi.170
}
Returns the free space of a file system where a file specified by
path-or-port resides, in number of bytes.
[SRFI-170]{srfi.170
}
A parameter holding a path prefix to be used by create-temp-file
and call-with-temporary-filename
. In Gauche,
the default value is set to
(build-path (temporary-directory) (x->string (sys-getpid)))
.
See 一時ファイルとディレクトリ, for the description of
temporary-directory
.
[SRFI-170]{srfi.170
}
[SRFI-170]{srfi.170
}
Note: For SRFI-170’s current-directory
, we reuse
file.util
’s one. See ディレクトリユーティリティ, for the description.
[SRFI-170]{srfi.170
}
Returns the current umask value.
Gauche’s sys-umask
without argument.
[SRFI-170]{srfi.170
}
Sets mask, which must be a nonnegative exact integer,
as the current umask.
Gauche’s sys-umask
, except that it returns unspecified value.
[SRFI-170]{srfi.170
}
Sets the process’s current working directory to dir.
Gauche’s sys-chdir
.
It can also be done with current-working-directory
in file.util
(see ディレクトリユーティリティ).
[SRFI-170]{srfi.170
}
Returns the current process id. Gauche’s sys-getpid
.
[SRFI-170]{srfi.170
}
Increments the current process’s nice value by delta, which must
be an exact integer. The lower the nice value is, the more chance
the process gets run. If omitted, delta is assumed to be 1.
Gauche’s sys-nice
.
[SRFI-170]{srfi.170
}
Gauche’s sys-getuid
, sys-getgid
, sys-geteuid
,
sys-getegid
, and sys-getgroups
, respectievly.
[SRFI-170]{srfi.170
}
Returns a user-info object, which is a <sys-passwd>
instance
in Gauche, of a user specified by uid-or-name, which must be
an exact integer uid or a string username.
If it is an uid, sys-getpwuid is called, and if it is a username
sys-getpwnam
is called.
[SRFI-170]{srfi.170
}
Returns #t
iff obj is a user-info object (<sys-passwd>
).
[SRFI-170]{srfi.170
}
Returns the value of name, uid
, gid
, dir
,
shell
and gecos slots of a user-info object (<sys-passwd
)
uinfo.
[SRFI-170]{srfi.170
}
[SRFI-170]{srfi.170
}
Returns a group-info object, which is a <sys-group>
instance
in Gauche, of a group specified by gid-or-name, which must be
an exact integer gid or a string groupname.
If it is an gid, sys-getgrgid is called, and if it is a groupname
sys-getgrnam
is called.
[SRFI-170]{srfi.170
}
Returns #t
iff obj is a group-info object (<sys-group
).
[SRFI-170]{srfi.170
}
Returns the value of name
and gid
slot of a group info
(<sys-group>
).
[SRFI-170]{srfi.170
}
Same as current-time
(see 時間). Return value is a <time>
instance of time-utc
.
[SRFI-170]{srfi.170
}
Returns a <time>
instance of time-monotonic
, representing
a elapsed time since an unspecified epoch. It is guaranteed to monotonically
increasing during the lifetime of the process, even if the system clock
is modified.
See srfi.98
- 環境変数へのアクセス, for getting environment variables.
This srfi defines the means to modify them.
[SRFI-170]{srfi.170
}
Gauche’s sys-setenv
with the third argument being #t
(overwrite the existing value).
[SRFI-170]{srfi.170
}
Gauche’s sys-unsetenv
.
[SRFI-170]{srfi.170
}
Gauche’s sys-isatty
.