Skip to content
Permalink
Browse files

Document file-info and friends. Introduce file:*.

  • Loading branch information...
roderyc committed Jul 26, 2014
1 parent 04ad51b commit c1ac01b06df3b7a90f54303d31a984085d9049e1
Showing with 136 additions and 92 deletions.
  1. +74 −0 doc/system-calls.scribble
  2. +10 −10 scheme/fileinfo.scm
  3. +10 −10 scheme/scsh-interfaces.scm
  4. +1 −11 scheme/scsh-package.scm
  5. +41 −61 test/file-system-tests.scm
@@ -576,3 +576,77 @@ Calling @code{sync-file} causes Unix to update the disk data structures for a gi
@defproc[#:link-target? #f (truncate-file [fname/fd/port (or/c string? integer? fdport?)] [len integer?]) undefined]{
Truncate the specified file to @var{len} bytes in length.
}

@defproc[#:link-target? #f (file-info [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) file-info?]{
Returns a record structure containing everything there is to know about a file. If the @var{chase?}
flag is true (the default), then the procedure chases symlinks and reports on the files to which
they refer. If @var{chase?} is false, then the procedure checks the actual file itself, even if it's
a symlink. The @var{chase?} flag is ignored if the file argument is a file descriptor or port.

The value returned is a @emph{file-info record}, whose accessors are defined in this chapter.
}

@defproc[#:link-target? #f (file-info:type [finfo file-info?])
(or/c 'block-special 'char-special 'directory 'fifo 'regular 'socket 'symlink)]{
Returns a symbol denoting the type of the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:device [finfo file-info?]) integer?]{
Returns an integer denoting the device that the file described by @var{finfo} resides on.
}

@defproc[#:link-target? #f (file-info:inode [finfo file-info?]) integer?]{
Returns an integer denoting the file system inode that points to the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:mode [finfo file-info?]) file-mode?]{
Returns a file-mode object describing the permissions set on the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:nlinks [finfo file-info?]) integer?]{
Returns the number of hard links to the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:uid [finfo file-info?]) integer?]{
Returns user id of the owner of the file file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:gid [finfo file-info?]) integer?]{
Returns the group id of the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:size [finfo file-info?]) integer?]{
Returns the size in bytes of the file described by @var{finfo}.
}

@defproc[#:link-target? #f (file-info:size [finfo file-info?]) integer?]{
Returns the time at which the file described by @var{finfo} was last accessed.
}

@defproc[#:link-target? #f (file-info:atime [finfo file-info?]) integer?]{
Returns the time at which the file described by @var{finfo} was last accessed.
}

@defproc[#:link-target? #f (file-info:mtime [finfo file-info?]) integer?]{
Returns the time at which the file described by @var{finfo} was last modified.
}

@defproc[#:link-target? #f (file-info:ctime [finfo file-info?]) integer?]{
Returns the time at which the file described by @var{finfo} last had its status changed.
}

@deftogether[(@defproc[#:link-target? #f (file:type [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t])
(or/c 'block-special 'char-special 'directory 'fifo 'regular 'socket 'symlink)]
@defproc[#:link-target? #f (file:device [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:inode [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:mode [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) file-mode?]
@defproc[#:link-target? #f (file:nlinks [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:uid [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:gid [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:size [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:atime [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:mtime [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?]
@defproc[#:link-target? #f (file:ctime [fname/fd/port (or/c string? integer? fdport?)] [chase? any/c #t]) integer?])]{
These procuders are a composition of @code{file-info} and its accessors. They allow more convenient
access to file based information, without handling an intermediary file-info object.
}
@@ -182,16 +182,16 @@
(define (proc fname/fd/port . maybe-chase?)
(info-slot (apply file-info fname/fd/port maybe-chase?))))

(define-stat-proc file-info-type file-info:type)
(define-stat-proc file-info-group file-info:gid)
(define-stat-proc file-info-inode file-info:inode)
(define-stat-proc file-info-last-access file-info:atime)
(define-stat-proc file-info-last-mod file-info:mtime)
(define-stat-proc file-info-last-status-change file-info:ctime)
(define-stat-proc file-info-mode file-info:mode)
(define-stat-proc file-info-nlinks file-info:nlinks)
(define-stat-proc file-info-owner file-info:uid)
(define-stat-proc file-info-size file-info:size)
(define-stat-proc file:type file-info:type)
(define-stat-proc file:group file-info:gid)
(define-stat-proc file:inode file-info:inode)
(define-stat-proc file:last-access file-info:atime)
(define-stat-proc file:last-mod file-info:mtime)
(define-stat-proc file:last-status-change file-info:ctime)
(define-stat-proc file:mode file-info:mode)
(define-stat-proc file:nlinks file-info:nlinks)
(define-stat-proc file:owner file-info:uid)
(define-stat-proc file:size file-info:size)

(define (file-info-to-fname/fd/port predicate)
(lambda (fname/fd/port . maybe-chase?)
@@ -198,16 +198,16 @@
file-info:atime
file-info:mtime
file-info:ctime
file-info-type
file-info-group
file-info-inode
file-info-last-access
file-info-last-mod
file-info-last-status-change
file-info-mode
file-info-nlinks
file-info-owner
file-info-size
file:type
file:group
file:inode
file:last-access
file:last-mod
file:last-status-change
file:mode
file:nlinks
file:owner
file:size
file-symlink?
file-directory?
file-fifo?
@@ -307,17 +307,7 @@
char-ready?
read-char))
(modify posix-files (hide file-type
file-info?
file-info-type
file-info-group
file-info-inode
file-info-last-access
file-info-last-mod
file-info-last-status-change
file-info-mode
file-info-nlinks
file-info-owner
file-info-size))
file-info?))
(subset os-strings (os-string->string))
(subset scsh-utilities (define-simple-syntax deprecated-proc real->exact-integer))
(subset signals (error))

0 comments on commit c1ac01b

Please sign in to comment.
You can’t perform that action at this time.