Remove unmaintained/io/ since basis/io/ now has all of the features from the old I/O library

db4
Slava Pestov 2008-11-19 21:02:21 -06:00
parent d6264a32ce
commit 825ad4e59d
8 changed files with 0 additions and 348 deletions

View File

@ -1,24 +0,0 @@
USING: kernel ;
REQUIRES: libs/calendar libs/shuffle ;
PROVIDE: libs/io
{ +files+ {
"io.factor"
"mmap.factor"
"shell.factor"
{ "os-unix.factor" [ unix? ] }
{ "os-unix-shell.factor" [ unix? ] }
{ "mmap-os-unix.factor" [ unix? ] }
{ "os-winnt.factor" [ winnt? ] }
{ "os-winnt-shell.factor" [ winnt? ] }
{ "mmap-os-winnt.factor" [ winnt? ] }
{ "os-wince.factor" [ wince? ] }
} }
{ +tests+ {
"test/io.factor"
"test/mmap.factor"
} } ;

View File

@ -1,46 +0,0 @@
USING: arrays kernel libs-io sequences prettyprint unix-internals
calendar namespaces math ;
USE: io
IN: shell
TUPLE: unix-shell ;
T{ unix-shell } \ shell set-global
TUPLE: file name mode nlink uid gid size mtime symbol ;
M: unix-shell directory* ( path -- seq )
dup (directory) [ tuck >r "/" r> 3append stat* 2array ] map-with ;
M: unix-shell make-file ( path -- file )
first2
[ stat-mode ] keep
[ stat-nlink ] keep
[ stat-uid ] keep
[ stat-gid ] keep
[ stat-size ] keep
[ stat-mtime timespec>timestamp >local-time ] keep
stat-mode mode>symbol <file> ;
M: unix-shell file. ( file -- )
[ [ file-mode >oct write ] keep ] with-cell
[ bl ] with-cell
[ [ file-nlink unparse write ] keep ] with-cell
[ bl ] with-cell
[ [ file-uid unparse write ] keep ] with-cell
[ bl ] with-cell
[ [ file-gid unparse write ] keep ] with-cell
[ bl ] with-cell
[ [ file-size unparse write ] keep ] with-cell
[ bl ] with-cell
[ [ file-mtime file-time-string write ] keep ] with-cell
[ bl ] with-cell
[ file-name write ] with-cell ;
USE: unix-internals
M: unix-shell touch-file ( path -- )
dup open-append dup -1 = [
drop now dup set-file-times
] [
nip [ now dup set-file-times* ] keep close
] if ;

View File

@ -1,24 +0,0 @@
! Copyright (C) 2007 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien arrays calendar errors io io-internals kernel
math nonblocking-io sequences unix-internals unix-io ;
IN: libs-io
: O_APPEND HEX: 100 ; inline
: O_EXCL HEX: 800 ; inline
: SEEK_SET 0 ; inline
: SEEK_CUR 1 ; inline
: SEEK_END 2 ; inline
: EEXIST 17 ; inline
: mode>symbol ( mode -- ch )
S_IFMT bitand
{
{ [ dup S_IFDIR = ] [ drop "/" ] }
{ [ dup S_IFIFO = ] [ drop "|" ] }
{ [ dup S_IXUSR = ] [ drop "*" ] }
{ [ dup S_IFLNK = ] [ drop "@" ] }
{ [ dup S_IFWHT = ] [ drop "%" ] }
{ [ dup S_IFSOCK = ] [ drop "=" ] }
{ [ t ] [ drop "" ] }
} cond ;

View File

@ -1,55 +0,0 @@
USING: alien calendar io io-internals kernel libs-io math
namespaces prettyprint sequences windows-api ;
IN: shell
TUPLE: winnt-shell ;
T{ winnt-shell } \ shell set-global
TUPLE: file name size mtime attributes ;
: ((directory*)) ( handle -- )
"WIN32_FIND_DATA" <c-object> [ FindNextFile ] 2keep
rot zero? [ 2drop ] [ , ((directory*)) ] if ;
: (directory*) ( path -- )
"WIN32_FIND_DATA" <c-object> [
FindFirstFile dup INVALID_HANDLE_VALUE = [
win32-error
] when
] keep ,
[ ((directory*)) ] keep FindClose win32-error=0/f ;
: append-star ( path -- path )
dup peek CHAR: \\ = "*" "\\*" ? append ;
M: winnt-shell directory* ( path -- seq )
normalize-pathname append-star [ (directory*) ] { } make ;
: WIN32_FIND_DATA>file-size ( WIN32_FILE_ATTRIBUTE_DATA -- n )
[ WIN32_FIND_DATA-nFileSizeLow ] keep
WIN32_FIND_DATA-nFileSizeHigh 32 shift + ;
M: winnt-shell make-file ( WIN32_FIND_DATA -- file )
[ WIN32_FIND_DATA-cFileName alien>u16-string ] keep
[ WIN32_FIND_DATA>file-size ] keep
[
WIN32_FIND_DATA-ftCreationTime
FILETIME>timestamp >local-time
] keep
WIN32_FIND_DATA-dwFileAttributes <file> ;
M: winnt-shell file. ( file -- )
[ [ file-attributes >oct write ] keep ] with-cell
[ bl ] with-cell
[ [ file-size unparse write ] keep ] with-cell
[ bl ] with-cell
[ [ file-mtime file-time-string write ] keep ] with-cell
[ bl ] with-cell
[ file-name write ] with-cell ;
M: winnt-shell touch-file ( path -- )
#! Set the file write time to 'now'
normalize-pathname
dup maybe-create-file [ drop ] [ now set-file-write-time ] if ;

View File

@ -1,96 +0,0 @@
USING: alien calendar errors generic io io-internals kernel
math namespaces nonblocking-io parser quotations sequences
shuffle windows-api words ;
IN: libs-io
: stat* ( path -- WIN32_FIND_DATA )
"WIN32_FIND_DATA" <c-object>
[
FindFirstFile
[ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep
FindClose win32-error=0/f
] keep ;
: set-file-time ( path timestamp/f timestamp/f timestamp/f -- )
#! timestamp order: creation access write
>r >r >r open-existing dup r> r> r>
[ timestamp>FILETIME ] 3 napply
SetFileTime win32-error=0/f
close-handle ;
: set-file-times ( path timestamp/f timestamp/f -- )
f -rot set-file-time ;
: set-file-create-time ( path timestamp -- )
f f set-file-time ;
: set-file-access-time ( path timestamp -- )
>r f r> f set-file-time ;
: set-file-write-time ( path timestamp -- )
>r f f r> set-file-time ;
: maybe-make-filetime ( ? -- FILETIME/f )
[ "FILETIME" <c-object> ] [ f ] if ;
: file-time ( path ? ? ? -- FILETIME/f FILETIME/f FILETIME/f )
>r >r >r open-existing dup r> r> r>
[ maybe-make-filetime ] 3 napply
[ GetFileTime win32-error=0/f close-handle ] 3keep ;
: file-times ( path -- FILETIME FILETIME FILETIME )
t t t file-time [ FILETIME>timestamp ] 3 napply ;
: file-create-time ( path -- FILETIME )
t f f file-time 2drop FILETIME>timestamp ;
: file-access-time ( path -- FILETIME )
f t f file-time drop nip FILETIME>timestamp ;
: file-write-time ( path -- FILETIME )
f f t file-time 2nip FILETIME>timestamp ;
: attrib ( path -- n )
[ stat* WIN32_FIND_DATA-dwFileAttributes ] catch
[ drop 0 ] when ;
: (read-only?) ( mode -- ? )
FILE_ATTRIBUTE_READONLY bit-set? ;
: read-only? ( path -- ? )
attrib (read-only?) ;
: (hidden?) ( mode -- ? )
FILE_ATTRIBUTE_HIDDEN bit-set? ;
: hidden? ( path -- ? )
attrib (hidden?) ;
: (system?) ( mode -- ? )
FILE_ATTRIBUTE_SYSTEM bit-set? ;
: system? ( path -- ? )
attrib (system?) ;
: (directory?) ( mode -- ? )
FILE_ATTRIBUTE_DIRECTORY bit-set? ;
: directory? ( path -- ? )
attrib (directory?) ;
: (archive?) ( mode -- ? )
FILE_ATTRIBUTE_ARCHIVE bit-set? ;
: archive? ( path -- ? )
attrib (archive?) ;
! FILE_ATTRIBUTE_DEVICE
! FILE_ATTRIBUTE_NORMAL
! FILE_ATTRIBUTE_TEMPORARY
! FILE_ATTRIBUTE_SPARSE_FILE
! FILE_ATTRIBUTE_REPARSE_POINT
! FILE_ATTRIBUTE_COMPRESSED
! FILE_ATTRIBUTE_OFFLINE
! FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
! FILE_ATTRIBUTE_ENCRYPTED

View File

@ -1,40 +0,0 @@
USING: calendar io io-internals kernel math namespaces
nonblocking-io prettyprint quotations sequences ;
IN: shell
SYMBOL: shell
HOOK: directory* shell ( path -- seq )
HOOK: make-file shell ( bytes -- file )
HOOK: file. shell ( file -- )
HOOK: touch-file shell ( path -- )
: (ls) ( path -- )
>r H{ } r> directory*
[
[ [ make-file file. ] with-row ] each
] curry tabular-output ;
: ls ( -- )
cwd (ls) ;
: pwd ( -- )
cwd pprint nl ;
: (slurp) ( quot -- )
>r default-buffer-size read r> over [
dup slip (slurp)
] [
2drop
] if ;
: slurp ( stream quot -- )
[ (slurp) ] curry with-stream ;
: cat ( path -- )
<file-reader> stdio get
duplex-stream-out <duplex-stream>
[ write ] slurp ;
: copy-file ( path path -- )
>r <file-reader> r>
<file-writer> <duplex-stream> [ write ] slurp ;

View File

@ -1,42 +0,0 @@
USING: calendar errors io kernel libs-io math namespaces sequences
shell test ;
IN: temporary
SYMBOL: file "file-appender-test.txt" \ file set
[ \ file get delete-file ] catch drop
[ f ] [ \ file get exists? ] unit-test
\ file get <file-appender> [ "asdf" write ] with-stream
[ t ] [ \ file get exists? ] unit-test
[ 4 ] [ \ file get file-length ] unit-test
\ file get <file-appender> [ "jkl;" write ] with-stream
[ t ] [ \ file get exists? ] unit-test
[ 8 ] [ \ file get file-length ] unit-test
[ "asdfjkl;" ] [ \ file get <file-reader> contents ] unit-test
\ file get delete-file
[ f ] [ \ file get exists? ] unit-test
SYMBOL: directory "test-directory" \ directory set
\ directory get create-directory
[ t ] [ \ directory get directory? ] unit-test
\ directory get delete-directory
[ f ] [ \ directory get directory? ] unit-test
SYMBOL: time "time-test.txt" \ time set
[ \ time get delete-file ] catch drop
\ time get touch-file
[ 0 ] [ \ time get file-length ] unit-test
[ t ] [ \ time get exists? ] unit-test
\ time get 0 unix-time>timestamp dup set-file-times
[ t ] [ \ time get file-write-time 0 unix-time>timestamp = ] unit-test
[ t ] [ \ time get file-access-time 0 unix-time>timestamp = ] unit-test
\ time get touch-file
[ t ] [ now \ time get file-write-time timestamp- 10 < ] unit-test
\ time get delete-file
SYMBOL: longname "" 255 CHAR: a pad-left \ longname set
\ longname get touch-file
[ t ] [ \ longname get exists? ] unit-test
[ 0 ] [ \ longname get file-length ] unit-test
\ longname get delete-file
[ f ] [ \ longname get exists? ] unit-test

View File

@ -1,21 +0,0 @@
USING: alien errors io kernel libs-io mmap namespaces test ;
IN: temporary
SYMBOL: mmap "mmap-test.txt" \ mmap set
[ \ mmap get delete-file ] catch drop
\ mmap get [
"Four" write
] with-file-writer
\ mmap get [
>r CHAR: R r> mmap-address 3 set-alien-unsigned-1
] with-mmap
\ mmap get [
mmap-address 3 alien-unsigned-1 CHAR: R = [
"mmap test failed" throw
] unless
] with-mmap
[ \ mmap get delete-file ] catch drop