Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/posix-extras|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == posix-extras Provides "the things that the [[/manual/Unit posix|posix]] unit forgot." [[toc:]] == API === Stat vector accessors {{file-stat}} in Unit posix returns an untyped 13-element vector representing the stat information. These are its accessors. <procedure>(stat-inode s)</procedure> Inode number of stat vector S. <procedure>(stat-permissions s)</procedure> Permissions of stat vector S. You can test this value by performing bitwise operations on the result and the [[/manual/Unit posix#Permission bits|{{perm/...}}]] values from Unit posix. For compatibility with {{file-permissions}}, this returns the entire mode field, which happens to include the file type. You can use {{stat-mode}} and {{stat-mode-type}} to get the file mode and type separately. <procedure>(stat-mode s)</procedure> Like {{stat-permissions}}, but return only the file mode (permission) bits from the mode field. (number->string (stat-mode s) 8) ; => "644" <procedure>(stat-mode-type s)</procedure> Return only the file type bits from the mode field of stat vector S. You can then use equality operations with file type constants such as {{stat/ififo}}. However, it is probably better to use the wrappers {{stat-type}} and {{stat-fifo?}}, etc. (= stat/ifdir (stat-mode-type (file-stat "~/.emacs.d"))) ; => #t <procedure>(stat-links s)</procedure> Number of hard links of stat vector S. <procedure>(stat-owner s)</procedure> Numeric user id of stat vector S. <procedure>(stat-group s)</procedure> Numeric group id of stat vector S. <procedure>(stat-size s)</procedure> File size in bytes of stat vector S. <procedure>(stat-access-time s)</procedure> <procedure>(stat-change-time s)</procedure> <procedure>(stat-modification-time s)</procedure> Access, change or modification time of stat vector S in seconds since UNIX epoch. <procedure>(stat-device s)</procedure> Device number of the device that stat vector S resides on. Compare with {{stat-device-number}}. Not valid on Windows, where it returns an unspecified value. <procedure>(stat-device-number s)</procedure> Device number of the block- or character- special file represented by stat vector S. The device number can be deconstructed with {{device-major}} and {{device-minor}}. For all other file types, the device number is 0. '''Warning''': Due to a limitation in Chicken, only 30 bits of the device number are recorded in the stat vector on 32-bit systems (this is raised to 32 bits on 64-bit systems; technically speaking, its foreign type is {{unsigned-int}}). Although 32-bit device numbers are most common, some platforms such as Linux may use 64-bit numbers. Therefore, the device number may be somewhat unreliable. Not valid on Windows, where it returns an unspecified value. <procedure>(stat-block-size s)</procedure> Returns the "optimal" block size for I/O on the file represented by stat vector S. Not valid on Windows, where it returns an unspecified value. <procedure>(stat-blocks s)</procedure> Number of blocks allocated for the file represented by stat vector S. Not valid on Windows, where it returns an unspecified value. === Stat vector helpers These convenience procedures correspond to the {{file-*}} procedures in Unit posix, but can be used on stat vectors. <procedure>(stat-type s)</procedure> File type for stat vector S as a symbol, one of: regular-file directory fifo socket symbolic-link character-device block-device ;; Example (stat-type (file-stat "~/.emacs.d")) ;=> directory <procedure>(stat-regular-file? s)</procedure> Like {{regular-file?}} but for stat vectors. <procedure>(stat-symbolic-link? s)</procedure> Like {{symbolic-link?}} but for stat vectors. <procedure>(stat-block-device? s)</procedure> Like {{block-device?}} but for stat vectors. <procedure>(stat-character-device? s)</procedure> Like {{character-device?}} but for stat vectors. <procedure>(stat-fifo? s)</procedure> Like {{fifo?}} but for stat vectors. <procedure>(stat-socket? s)</procedure> Like {{socket?}} but for stat vectors. <procedure>(stat-directory? s)</procedure> Like {{directory?}} but for stat vectors. (stat-directory? (file-stat "~/.emacs.d")) ; => #t === Stat mode constants <constant>stat/ifmt</constant><br> <constant>stat/ififo</constant><br> <constant>stat/ifchr</constant><br> <constant>stat/ifdir</constant><br> <constant>stat/ifblk</constant><br> <constant>stat/ifreg</constant><br> <constant>stat/iflnk</constant><br> <constant>stat/ifsock</constant><br> Constants used with {{stat-mode-type}} to get the type of file. Consult {{stat(2)}} for more information and note that, for example, {{stat/ifdir}} corresponds to {{S_IFDIR}}. === Symlink ownership and mode <procedure>(change-link-mode filename mode)</procedure><br> Change the mode of symbolic link FILENAME to numeric MODE via the {{lchmod()}} C library function. This system call is only implemented on some platforms; it will raise an error otherwise. <procedure>(change-link-owner filename uid gid)</procedure><br> Change the owner and group of symbolic link FILENAME to numeric UID and GID via the {{lchown()}} C library function. This system call is only implemented on some platforms; it will raise an error otherwise. === File times <procedure>(change-file-times filename atime mtime)</procedure> Change the access and modification times on {{filename}} to {{atime}} and {{mtime}}, respectively. Note that {{atime}} and {{mtime}} must be within 32-bit range. <procedure>(file-access-time filename)</procedure> <setter>(set! (file-access-time FILE) SECONDS)</setter> Gets or sets the access time on FILENAME. On most platforms modification and access time must be set together, so this usually incurs a separate call to get the current modification time. For efficiency, use {{change-file-times}} when you want to set both. === Device special files <procedure>(create-special-file filename mode devnum #!optional minor)</procedure><br> Create a special file node called FILENAME with numeric mode MODE. DEVNUM is the desired device number and is relevant for block and character devices only; a device number can be constructed with {{make-device-number}}. Device numbers created in this manner are restricted to 32 bits only. If the optional MINOR argument is provided, then DEVNUM is taken as the major device number, and MINOR as the minor number. In this case, the resulting device number will be not be subject to the 32-bit restriction mentioned above. <procedure>(create-block-device filename major minor #!optional (mode #o666))</procedure><br> <procedure>(create-character-device filename major minor #!optional (mode #o666))</procedure><br> Create a block or character device called FILENAME having major device number MAJOR and minor device number MINOR. The optional creation MODE may also be specified via {{perm/...}} bits or directly in octal, and defaults to #o666, subject to your current umask. These are merely convenient aliases to {{create-special-file}}. === Device numbers <procedure>(device-major devnum)</procedure><br> Extract and return the major number from the device number DEVNUM. <procedure>(device-minor devnum)</procedure><br> Extract and return the minor number from the device number DEVNUM. <procedure>(make-device-number major minor)</procedure><br> Create a single device number from the given device MAJOR and MINOR IDs. Note: The resulting device number is capped at 32 bits even on platforms with 64-bit device IDs. You can still, however, create files with full-width device numbers with {{create-special-file}} and friends. === Pathnames <procedure>(resolve-pathname p)</procedure> Resolve all {{./}}, {{../}} and symbolic references in relative or absolute pathname string P. All components in the path must exist. Returns an absolute pathname string, or signals an error if (for example) a path component is missing. Platform notes: Solaris is reported to return a relative pathname in some instances. Unimplemented on Windows and will signal an error. === Processes <procedure>(sleep seconds)</procedure> Puts the process to sleep for ''seconds'', which is an inexact number (that is, may include a fractional number of seconds). The ''sleep'' from Unit posix only supports whole seconds. Returns either 0 if the time has completely elapsed, or the number of remaining seconds, if a signal occurred. (sleep 1.4) == About this egg === Author [[/users/alaric-blagrave-snellpym|Alaric Snell-Pym]] wrote the original implementation for [[/egg/ugarit|Ugarit]], and Jim Ursetto eggified it, made it portable and added a lot of stuff. Maintained by [[/users/jim-ursetto|Jim Ursetto]]. === Version history ; 0.1.5 : Use nanosleep instead of sleep+usleep ; 0.1.4 : Implement sub-second sleep ; 0.1.3 : Expand homedir path in {{resolve-pathname}} ; 0.1.2 : Add {{resolve-pathname}} ; 0.1.1 : Add {{change-file-times}} and {{file-access-time}} setter ; 0.1 : initial release === License Copyright (c) 2012, Ursetto Consulting Inc. Copyright (c) 2008-2009, Warhead.org.uk Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the names of Warhead.org.uk Ltd, Snell Systems, Kitten Technologies, Ursetto Consulting Inc. nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 5 by 7?