Merge branch 'master' of git://factorcode.org/git/factor

db4
John Benediktsson 2008-12-15 10:00:44 -08:00
commit ceb78e417f
315 changed files with 2329 additions and 2334 deletions

View File

@ -1,4 +1,4 @@
USING: help.markup help.syntax io io.files ; USING: help.markup help.syntax io io.files io.pathnames ;
IN: bootstrap.image IN: bootstrap.image
ARTICLE: "bootstrap.image" "Bootstrapping new images" ARTICLE: "bootstrap.image" "Bootstrapping new images"

View File

@ -1,14 +1,15 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien arrays byte-arrays generic assocs hashtables assocs USING: alien arrays byte-arrays generic assocs hashtables assocs
hashtables.private io kernel kernel.private math namespaces make hashtables.private io io.binary io.files io.encodings.binary
parser prettyprint sequences sequences.private strings sbufs io.pathnames kernel kernel.private math namespaces make parser
prettyprint sequences sequences.private strings sbufs
vectors words quotations assocs system layouts splitting vectors words quotations assocs system layouts splitting
grouping growable classes classes.builtin classes.tuple grouping growable classes classes.builtin classes.tuple
classes.tuple.private words.private io.binary io.files vocabs classes.tuple.private words.private vocabs
vocabs.loader source-files definitions debugger vocabs.loader source-files definitions debugger
quotations.private sequences.private combinators quotations.private sequences.private combinators
io.encodings.binary math.order math.private accessors math.order math.private accessors
slots.private compiler.units ; slots.private compiler.units ;
IN: bootstrap.image IN: bootstrap.image

View File

@ -2,7 +2,8 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: checksums checksums.openssl splitting assocs USING: checksums checksums.openssl splitting assocs
kernel io.files bootstrap.image sequences io namespaces make kernel io.files bootstrap.image sequences io namespaces make
io.launcher math io.encodings.ascii ; io.launcher math io.encodings.ascii io.files.temp io.pathnames
io.directories ;
IN: bootstrap.image.upload IN: bootstrap.image.upload
SYMBOL: upload-images-destination SYMBOL: upload-images-destination

View File

@ -1,12 +1,11 @@
USING: system vocabs vocabs.loader kernel combinators USING: system vocabs vocabs.loader kernel combinators
namespaces sequences io.backend ; namespaces sequences io.backend accessors ;
IN: bootstrap.io IN: bootstrap.io
"bootstrap.compiler" vocab [ "bootstrap.compiler" vocab [
"io." { "io.backend." {
{ [ "io-backend" get ] [ "io-backend" get ] } { [ "io-backend" get ] [ "io-backend" get ] }
{ [ os unix? ] [ "unix" ] } { [ os unix? ] [ "unix." os name>> append ] }
{ [ os winnt? ] [ "windows.nt" ] } { [ os winnt? ] [ "windows.nt" ] }
{ [ os wince? ] [ "windows.ce" ] }
} cond append require } cond append require
] when ] when

View File

@ -1,11 +1,11 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors init namespaces words io USING: accessors init namespaces words io kernel.private math
kernel.private math memory continuations kernel io.files memory continuations kernel io.files io.pathnames io.backend
io.backend system parser vocabs sequences system parser vocabs sequences vocabs.loader combinators
vocabs.loader combinators splitting source-files strings splitting source-files strings definitions assocs
definitions assocs compiler.errors compiler.units compiler.errors compiler.units math.parser generic sets
math.parser generic sets command-line ; command-line ;
IN: bootstrap.stage2 IN: bootstrap.stage2
SYMBOL: core-bootstrap-time SYMBOL: core-bootstrap-time

View File

@ -1,8 +1,8 @@
! Copyright (C) 2003, 2008 Slava Pestov. ! Copyright (C) 2003, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: init continuations hashtables io io.encodings.utf8 USING: init continuations hashtables io io.encodings.utf8
io.files kernel kernel.private namespaces parser sequences io.files io.pathnames kernel kernel.private namespaces parser
strings system splitting vocabs.loader ; sequences strings system splitting vocabs.loader ;
IN: command-line IN: command-line
SYMBOL: script SYMBOL: script

View File

@ -1,7 +1,8 @@
IN: concurrency.distributed.tests IN: concurrency.distributed.tests
USING: tools.test concurrency.distributed kernel io.files USING: tools.test concurrency.distributed kernel io.files
arrays io.sockets system combinators threads math sequences io.files.temp io.directories arrays io.sockets system
concurrency.messaging continuations accessors prettyprint ; combinators threads math sequences concurrency.messaging
continuations accessors prettyprint ;
: test-node ( -- addrspec ) : test-node ( -- addrspec )
{ {

View File

@ -14,6 +14,7 @@ TYPEDEF: int SInt32
TYPEDEF: uint UInt32 TYPEDEF: uint UInt32
TYPEDEF: ulong CFTypeID TYPEDEF: ulong CFTypeID
TYPEDEF: UInt32 CFOptionFlags TYPEDEF: UInt32 CFOptionFlags
TYPEDEF: void* CFUUIDRef
FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) ; FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) ;

View File

@ -8,7 +8,6 @@ TYPEDEF: void* CFDictionaryRef
TYPEDEF: void* CFMutableDictionaryRef TYPEDEF: void* CFMutableDictionaryRef
TYPEDEF: void* CFNumberRef TYPEDEF: void* CFNumberRef
TYPEDEF: void* CFSetRef TYPEDEF: void* CFSetRef
TYPEDEF: void* CFUUIDRef
TYPEDEF: int CFNumberType TYPEDEF: int CFNumberType
: kCFNumberSInt8Type 1 ; inline : kCFNumberSInt8Type 1 ; inline

View File

@ -1,6 +1,6 @@
IN: db.pools.tests IN: db.pools.tests
USING: db.pools tools.test continuations io.files namespaces USING: db.pools tools.test continuations io.files io.files.temp
accessors kernel math destructors ; io.directories namespaces accessors kernel math destructors ;
\ <db-pool> must-infer \ <db-pool> must-infer

View File

@ -1,5 +1,5 @@
USING: io io.files io.launcher kernel namespaces USING: io io.files io.files.temp io.directories io.launcher
prettyprint tools.test db.sqlite db sequences kernel namespaces prettyprint tools.test db.sqlite db sequences
continuations db.types db.tuples unicode.case ; continuations db.types db.tuples unicode.case ;
IN: db.sqlite.tests IN: db.sqlite.tests

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.files kernel tools.test db db.tuples classes USING: io.files io.files.temp kernel tools.test db db.tuples classes
db.types continuations namespaces math math.ranges db.types continuations namespaces math math.ranges
prettyprint calendar sequences db.sqlite math.intervals prettyprint calendar sequences db.sqlite math.intervals
db.postgresql accessors random math.bitwise system db.postgresql accessors random math.bitwise system

View File

@ -2,10 +2,10 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: slots arrays definitions generic hashtables summary io USING: slots arrays definitions generic hashtables summary io
kernel math namespaces make prettyprint prettyprint.config kernel math namespaces make prettyprint prettyprint.config
sequences assocs sequences.private strings io.styles io.files sequences assocs sequences.private strings io.styles
vectors words system splitting math.parser classes.mixin io.pathnames vectors words system splitting math.parser
classes.tuple continuations continuations.private combinators classes.mixin classes.tuple continuations continuations.private
generic.math classes.builtin classes compiler.units combinators generic.math classes.builtin classes compiler.units
generic.standard vocabs init kernel.private io.encodings generic.standard vocabs init kernel.private io.encodings
accessors math.order destructors source-files parser accessors math.order destructors source-files parser
classes.tuple.parser effects.parser lexer compiler.errors classes.tuple.parser effects.parser lexer compiler.errors

View File

@ -1,9 +1,9 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: parser lexer kernel namespaces sequences definitions USING: parser lexer kernel namespaces sequences definitions
io.files summary continuations tools.crossref tools.vocabs io io.files io.backend io.pathnames io summary continuations
prettyprint source-files assocs vocabs vocabs.loader io.backend tools.crossref tools.vocabs prettyprint source-files assocs
splitting accessors ; vocabs vocabs.loader splitting accessors ;
IN: editors IN: editors
TUPLE: no-edit-hook ; TUPLE: no-edit-hook ;

View File

@ -1,5 +1,4 @@
USING: io.unix.backend kernel namespaces editors.gvim USING: kernel namespaces editors.gvim system ;
system ;
IN: editors.gvim.unix IN: editors.gvim.unix
M: unix gvim-path M: unix gvim-path

View File

@ -1,5 +1,5 @@
USING: editors.gvim io.files io.windows kernel namespaces USING: editors.gvim io.files kernel namespaces sequences
sequences windows.shell32 io.paths.windows system ; windows.shell32 io.paths.windows system ;
IN: editors.gvim.windows IN: editors.gvim.windows
M: windows gvim-path M: windows gvim-path

View File

@ -4,7 +4,7 @@ USING: arrays definitions io kernel math
namespaces parser prettyprint sequences strings words namespaces parser prettyprint sequences strings words
editors io.files io.sockets io.streams.byte-array io.binary editors io.files io.sockets io.streams.byte-array io.binary
math.parser io.encodings.ascii io.encodings.binary math.parser io.encodings.ascii io.encodings.binary
io.encodings.utf8 io.files.private ; io.encodings.utf8 io.files.private io.pathnames ;
IN: editors.jedit IN: editors.jedit
: jedit-server-info ( -- port auth ) : jedit-server-info ( -- port auth )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays classes.singleton combinators USING: accessors arrays classes.singleton combinators
continuations io io.encodings.binary io.encodings.utf8 continuations io io.encodings.binary io.encodings.utf8
io.files io.sockets kernel io.streams.duplex math io.files io.pathnames io.sockets kernel io.streams.duplex math
math.parser sequences splitting namespaces strings fry ftp math.parser sequences splitting namespaces strings fry ftp
ftp.client.listing-parser urls ; ftp.client.listing-parser urls ;
IN: ftp.client IN: ftp.client
@ -104,7 +104,3 @@ ERROR: ftp-error got expected ;
[ nip parent-directory ftp-cwd drop ] [ nip parent-directory ftp-cwd drop ]
[ file-name (ftp-get) ] 2bi [ file-name (ftp-get) ] 2bi
] with-ftp-client ; ] with-ftp-client ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators io.files kernel math.parser USING: accessors combinators io.files.types kernel math.parser
sequences splitting ; sequences splitting ;
IN: ftp.client.listing-parser IN: ftp.client.listing-parser

View File

@ -2,12 +2,13 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: combinators.short-circuit accessors combinators io USING: combinators.short-circuit accessors combinators io
io.encodings.8-bit io.encodings io.encodings.binary io.encodings.8-bit io.encodings io.encodings.binary
io.encodings.utf8 io.files io.sockets kernel math.parser io.encodings.utf8 io.files io.files.info io.directories
namespaces make sequences ftp io.unix.launcher.parser io.pathnames io.sockets kernel math.parser namespaces make
unicode.case splitting assocs classes io.servers.connection sequences ftp io.launcher.unix.parser unicode.case splitting
destructors calendar io.timeouts io.streams.duplex threads assocs classes io.servers.connection destructors calendar
continuations math concurrency.promises byte-arrays io.timeouts io.streams.duplex threads continuations math
io.backend tools.hexdump tools.files io.streams.string ; concurrency.promises byte-arrays io.backend tools.hexdump
tools.files io.streams.string ;
IN: ftp.server IN: ftp.server
TUPLE: ftp-client url mode state command-promise user password ; TUPLE: ftp-client url mode state command-promise user password ;

View File

@ -5,7 +5,7 @@ furnace.auth.login
furnace.auth.providers furnace.auth.providers
furnace.auth.providers.db tools.test furnace.auth.providers.db tools.test
namespaces db db.sqlite db.tuples continuations namespaces db db.sqlite db.tuples continuations
io.files accessors kernel ; io.files io.files.temp io.directories accessors kernel ;
<action> "test" <login-realm> realm set <action> "test" <login-realm> realm set

View File

@ -2,9 +2,9 @@ IN: furnace.sessions.tests
USING: tools.test http furnace.sessions furnace.actions USING: tools.test http furnace.sessions furnace.actions
http.server http.server.responses math namespaces make kernel http.server http.server.responses math namespaces make kernel
accessors io.sockets io.servers.connection prettyprint accessors io.sockets io.servers.connection prettyprint
io.streams.string io.files splitting destructors sequences db io.streams.string io.files io.files.temp io.directories
db.tuples db.sqlite continuations urls math.parser furnace splitting destructors sequences db db.tuples db.sqlite
furnace.utilities ; continuations urls math.parser furnace furnace.utilities ;
: with-session : with-session
[ [

View File

@ -168,6 +168,11 @@ ARTICLE: "io" "Input and output"
{ $heading "Streams" } { $heading "Streams" }
{ $subsection "streams" } { $subsection "streams" }
{ $subsection "io.files" } { $subsection "io.files" }
{ $heading "The file system" }
{ $subsection "io.pathnames" }
{ $subsection "io.files.info" }
{ $subsection "io.files.links" }
{ $subsection "io.directories" }
{ $heading "Encodings" } { $heading "Encodings" }
{ $subsection "encodings-introduction" } { $subsection "encodings-introduction" }
{ $subsection "io.encodings" } { $subsection "io.encodings" }

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
io.files html.streams html.elements help kernel io.files io.files.temp io.directories html.streams html.elements help kernel
assocs sequences make words accessors arrays help.topics vocabs assocs sequences make words accessors arrays help.topics vocabs
tools.vocabs tools.vocabs.browser namespaces prettyprint io tools.vocabs tools.vocabs.browser namespaces prettyprint io
vocabs.loader serialize fry memoize unicode.case math.order vocabs.loader serialize fry memoize unicode.case math.order

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel sequences combinators kernel fry USING: accessors kernel sequences combinators kernel fry
namespaces make classes.tuple assocs splitting words arrays io namespaces make classes.tuple assocs splitting words arrays io
io.files io.encodings.utf8 io.streams.string unicode.case io.files io.files.info io.encodings.utf8 io.streams.string
mirrors math urls present multiline quotations xml logging unicode.case mirrors math urls present multiline quotations xml
continuations logging continuations
xml.data xml.data
html.forms html.forms
html.elements html.elements

View File

@ -1,4 +1,4 @@
USING: http help.markup help.syntax io.files io.streams.string USING: http help.markup help.syntax io.pathnames io.streams.string
io.encodings.8-bit io.encodings.binary kernel strings urls io.encodings.8-bit io.encodings.binary kernel strings urls
urls.encoding byte-arrays strings assocs sequences ; urls.encoding byte-arrays strings assocs sequences ;
IN: http.client IN: http.client

View File

@ -1,17 +1,12 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs kernel math math.parser namespaces make USING: accessors assocs kernel math math.parser namespaces make
sequences io io.sockets io.streams.string io.files io.timeouts sequences strings splitting calendar continuations accessors vectors
strings splitting calendar continuations accessors vectors
math.order hashtables byte-arrays destructors math.order hashtables byte-arrays destructors
io.encodings io io.sockets io.streams.string io.files io.timeouts
io.encodings.string io.pathnames io.encodings io.encodings.string io.encodings.ascii
io.encodings.ascii io.encodings.utf8 io.encodings.8-bit io.encodings.binary
io.encodings.utf8 io.streams.duplex fry ascii urls urls.encoding present
io.encodings.8-bit
io.encodings.binary
io.streams.duplex
fry ascii urls urls.encoding present
http http.parsers ; http http.parsers ;
IN: http.client IN: http.client

View File

@ -179,7 +179,7 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
! Live-fire exercise ! Live-fire exercise
USING: http.server http.server.static furnace.sessions furnace.alloy USING: http.server http.server.static furnace.sessions furnace.alloy
furnace.actions furnace.auth furnace.auth.login furnace.db http.client furnace.actions furnace.auth furnace.auth.login furnace.db http.client
io.servers.connection io.files io io.encodings.ascii io.servers.connection io.files io.files.temp io.directories io io.encodings.ascii
accessors namespaces threads accessors namespaces threads
http.server.responses http.server.redirection furnace.redirection http.server.responses http.server.redirection furnace.redirection
http.server.dispatchers db.tuples ; http.server.dispatchers db.tuples ;

View File

@ -1,14 +1,11 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: calendar io io.files kernel math math.order USING: calendar kernel math math.order math.parser namespaces
math.parser namespaces parser sequences strings parser sequences strings assocs hashtables debugger mime.types
assocs hashtables debugger mime.types sorting logging sorting logging calendar.format accessors splitting io io.files
calendar.format accessors splitting io.files.info io.directories io.pathnames io.encodings.binary
io.encodings.binary fry xml.entities destructors urls fry xml.entities destructors urls html.elements
html.elements html.templates.fhtml html.templates.fhtml http http.server http.server.responses
http
http.server
http.server.responses
http.server.redirection ; http.server.redirection ;
IN: http.server.static IN: http.server.static

View File

@ -1,9 +1,9 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: namespaces system kernel accessors assocs continuations USING: namespaces system kernel accessors assocs continuations
unix io.backend io.unix.backend io.unix.multiplexers unix io.backend io.backend.unix io.backend.unix.multiplexers
io.unix.multiplexers.kqueue ; io.backend.unix.multiplexers.kqueue io.files.unix ;
IN: io.unix.bsd IN: io.backend.unix.bsd
M: bsd init-io ( -- ) M: bsd init-io ( -- )
<kqueue-mx> mx set-global ; <kqueue-mx> mx set-global ;

View File

@ -0,0 +1,3 @@
USING: io.backend.unix.bsd io.backend system ;
freebsd set-io-backend

View File

@ -1,8 +1,9 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel system namespaces io.backend io.unix.backend USING: kernel system namespaces io.files.unix io.backend
io.unix.multiplexers io.unix.multiplexers.epoll ; io.backend.unix io.backend.unix.multiplexers
IN: io.unix.linux io.backend.unix.multiplexers.epoll ;
IN: io.backend.unix.linux
M: linux init-io ( -- ) M: linux init-io ( -- )
<epoll-mx> mx set-global ; <epoll-mx> mx set-global ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.backend system namespaces io.unix.multiplexers USING: io.backend system namespaces io.backend.unix.bsd
io.unix.multiplexers.run-loop ; io.backend.unix.multiplexers io.backend.unix.multiplexers.run-loop ;
IN: io.unix.macosx IN: io.backend.macosx
M: macosx init-io ( -- ) M: macosx init-io ( -- )
<run-loop-mx> mx set-global ; <run-loop-mx> mx set-global ;

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types kernel destructors bit-arrays USING: accessors alien.c-types kernel destructors bit-arrays
sequences assocs struct-arrays math namespaces locals fry unix sequences assocs struct-arrays math namespaces locals fry unix
unix.linux.epoll unix.time io.ports io.unix.backend unix.linux.epoll unix.time io.ports io.backend.unix
io.unix.multiplexers ; io.backend.unix.multiplexers ;
IN: io.unix.multiplexers.epoll IN: io.backend.unix.multiplexers.epoll
TUPLE: epoll-mx < mx events ; TUPLE: epoll-mx < mx events ;

View File

@ -1,9 +1,9 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types combinators destructors USING: accessors alien.c-types combinators destructors
io.unix.backend kernel math.bitwise sequences struct-arrays unix io.backend.unix kernel math.bitwise sequences struct-arrays unix
unix.kqueue unix.time assocs io.unix.multiplexers ; unix.kqueue unix.time assocs io.backend.unix.multiplexers ;
IN: io.unix.multiplexers.kqueue IN: io.backend.unix.multiplexers.kqueue
TUPLE: kqueue-mx < mx events ; TUPLE: kqueue-mx < mx events ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors assocs sequences threads ; USING: kernel accessors assocs sequences threads ;
IN: io.unix.multiplexers IN: io.backend.unix.multiplexers
TUPLE: mx fd reads writes ; TUPLE: mx fd reads writes ;

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel arrays namespaces math accessors alien locals USING: kernel arrays namespaces math accessors alien locals
destructors system threads io.unix.multiplexers destructors system threads io.backend.unix.multiplexers
io.unix.multiplexers.kqueue core-foundation io.backend.unix.multiplexers.kqueue core-foundation
core-foundation.run-loop ; core-foundation.run-loop ;
IN: io.unix.multiplexers.run-loop IN: io.backend.unix.multiplexers.run-loop
TUPLE: run-loop-mx kqueue-mx ; TUPLE: run-loop-mx kqueue-mx ;

View File

@ -2,8 +2,8 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types kernel bit-arrays sequences assocs unix USING: alien.c-types kernel bit-arrays sequences assocs unix
math namespaces accessors math.order locals unix.time fry math namespaces accessors math.order locals unix.time fry
io.ports io.unix.backend io.unix.multiplexers ; io.ports io.backend.unix io.backend.unix.multiplexers ;
IN: io.unix.multiplexers.select IN: io.backend.unix.multiplexers.select
TUPLE: select-mx < mx read-fdset write-fdset ; TUPLE: select-mx < mx read-fdset write-fdset ;

View File

@ -0,0 +1,3 @@
USING: io.backend.unix.bsd io.backend system ;
netbsd set-io-backend

View File

@ -0,0 +1,3 @@
USING: io.backend.unix.bsd io.backend system ;
openbsd set-io-backend

View File

@ -1,8 +1,8 @@
USING: io.files io.sockets io kernel threads USING: io.files io.files.temp io.directories io.sockets io kernel threads
namespaces tools.test continuations strings byte-arrays namespaces tools.test continuations strings byte-arrays
sequences prettyprint system io.encodings.binary io.encodings.ascii sequences prettyprint system io.encodings.binary io.encodings.ascii
io.streams.duplex destructors make ; io.streams.duplex destructors make ;
IN: io.unix.tests IN: io.backend.unix.tests
! Unix domain stream sockets ! Unix domain stream sockets
: socket-server "unix-domain-socket-test" temp-file ; : socket-server "unix-domain-socket-test" temp-file ;

View File

@ -5,9 +5,9 @@ kernel.private math io.ports sequences strings sbufs threads
unix vectors io.buffers io.backend io.encodings math.parser unix vectors io.buffers io.backend io.encodings math.parser
continuations system libc qualified namespaces make io.timeouts continuations system libc qualified namespaces make io.timeouts
io.encodings.utf8 destructors accessors summary combinators io.encodings.utf8 destructors accessors summary combinators
locals unix.time fry io.unix.multiplexers ; locals unix.time fry io.backend.unix.multiplexers ;
QUALIFIED: io QUALIFIED: io
IN: io.unix.backend IN: io.backend.unix
GENERIC: handle-fd ( handle -- fd ) GENERIC: handle-fd ( handle -- fd )

View File

@ -1,11 +1,11 @@
USING: alien alien.c-types arrays assocs combinators USING: alien alien.c-types arrays assocs combinators
continuations destructors io io.backend io.ports io.timeouts continuations destructors io io.backend io.ports io.timeouts
io.windows io.windows.files io.files io.buffers io.streams.c io.backend.windows io.files.windows io.files.windows.nt io.files
libc kernel math namespaces sequences threads windows io.pathnames io.buffers io.streams.c libc kernel math namespaces
windows.errors windows.kernel32 strings splitting qualified sequences threads windows windows.errors windows.kernel32
ascii system accessors locals ; strings splitting qualified ascii system accessors locals ;
QUALIFIED: windows.winsock QUALIFIED: windows.winsock
IN: io.windows.nt.backend IN: io.backend.windows.nt
! Global variable with assoc mapping overlapped to threads ! Global variable with assoc mapping overlapped to threads
SYMBOL: pending-overlapped SYMBOL: pending-overlapped
@ -118,3 +118,5 @@ M: winnt (wait-to-read) ( port -- )
] with-destructors ; ] with-destructors ;
M: winnt (init-stdio) init-c-stdio ; M: winnt (init-stdio) init-c-stdio ;
winnt set-io-backend

View File

@ -1,9 +1,9 @@
USING: alien alien.c-types alien.syntax arrays continuations USING: alien alien.c-types alien.syntax arrays continuations
destructors generic io.mmap io.ports io.windows io.windows.files destructors generic io.mmap io.ports io.backend.windows io.files.windows
kernel libc math math.bitwise namespaces quotations sequences windows kernel libc math math.bitwise namespaces quotations sequences windows
windows.advapi32 windows.kernel32 io.backend system accessors windows.advapi32 windows.kernel32 io.backend system accessors
io.windows.privileges ; io.backend.windows.privileges ;
IN: io.windows.nt.privileges IN: io.backend.windows.nt.privileges
TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES

View File

@ -1,6 +1,6 @@
USING: io.backend kernel continuations sequences USING: io.backend kernel continuations sequences
system vocabs.loader combinators ; system vocabs.loader combinators ;
IN: io.windows.privileges IN: io.backend.windows.privileges
HOOK: set-privilege io-backend ( name ? -- ) inline HOOK: set-privilege io-backend ( name ? -- ) inline
@ -9,6 +9,6 @@ HOOK: set-privilege io-backend ( name ? -- ) inline
swap [ [ f set-privilege ] each ] curry [ ] cleanup ; inline swap [ [ f set-privilege ] each ] curry [ ] cleanup ; inline
{ {
{ [ os winnt? ] [ "io.windows.nt.privileges" require ] } { [ os winnt? ] [ "io.backend.windows.nt.privileges" require ] }
{ [ os wince? ] [ "io.windows.ce.privileges" require ] } { [ os wince? ] [ "io.backend.windows.ce.privileges" require ] }
} cond } cond

View File

View File

@ -5,7 +5,7 @@ io.buffers io.files io.ports io.binary io.timeouts
windows.errors strings kernel math namespaces sequences windows windows.errors strings kernel math namespaces sequences windows
windows.kernel32 windows.shell32 windows.types windows.winsock windows.kernel32 windows.shell32 windows.types windows.winsock
splitting continuations math.bitwise system accessors ; splitting continuations math.bitwise system accessors ;
IN: io.windows IN: io.backend.windows
: set-inherit ( handle ? -- ) : set-inherit ( handle ? -- )
[ HANDLE_FLAG_INHERIT ] dip [ HANDLE_FLAG_INHERIT ] dip

View File

@ -1 +1,2 @@
Slava Pestov Slava Pestov
Doug Coleman

View File

@ -0,0 +1,166 @@
USING: help.markup help.syntax io.files.private io.pathnames
quotations ;
IN: io.directories
HELP: cwd
{ $values { "path" "a pathname string" } }
{ $description "Outputs the current working directory of the Factor process." }
{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." }
{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
HELP: cd
{ $values { "path" "a pathname string" } }
{ $description "Changes the current working directory of the Factor process." }
{ $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." }
{ $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
{ cd cwd current-directory set-current-directory with-directory } related-words
HELP: current-directory
{ $description "A variable holding the current directory as an absolute path. Words that use the filesystem do so in relation to this variable."
$nl
"This variable should never be set directly; instead, use " { $link set-current-directory } " or " { $link with-directory } ". This preserves the invariant that the value of this variable is an absolute path." } ;
HELP: set-current-directory
{ $values { "path" "a pathname string" } }
{ $description "Changes the " { $link current-directory } " variable."
$nl
"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ;
HELP: with-directory
{ $values { "path" "a pathname string" } { "quot" quotation } }
{ $description "Calls the quotation in a new dynamic scope with the " { $link current-directory } " variable rebound."
$nl
"If " { $snippet "path" } " is relative, it is first resolved relative to the current directory. If " { $snippet "path" } " is absolute, it becomes the new current directory." } ;
HELP: (directory-entries)
{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $snippet "{ name dir? }" } " pairs" } }
{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." }
{ $notes "This is a low-level word, and user code should call one of the related words instead." } ;
HELP: directory-entries
{ $values { "path" "a pathname string" } { "seq" "a sequence of " { $link directory-entry } " objects" } }
{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ;
HELP: directory-files
{ $values { "path" "a pathname string" } { "seq" "a sequence of filenames" } }
{ $description "Outputs the contents of a directory named by " { $snippet "path" } "." } ;
HELP: with-directory-files
{ $values { "path" "a pathname string" } { "quot" quotation } }
{ $description "Calls the quotation with the directory file names on the stack and with the directory set as the " { $link current-directory } ". Restores the current directory after the quotation is called." } ;
HELP: delete-file
{ $values { "path" "a pathname string" } }
{ $description "Deletes a file." }
{ $errors "Throws an error if the file could not be deleted." } ;
HELP: make-directory
{ $values { "path" "a pathname string" } }
{ $description "Creates a directory." }
{ $errors "Throws an error if the directory could not be created." } ;
HELP: make-directories
{ $values { "path" "a pathname string" } }
{ $description "Creates a directory and any parent directories which do not yet exist." }
{ $errors "Throws an error if the directories could not be created." } ;
HELP: delete-directory
{ $values { "path" "a pathname string" } }
{ $description "Deletes a directory. The directory must be empty." }
{ $errors "Throws an error if the directory could not be deleted." } ;
HELP: touch-file
{ $values { "path" "a pathname string" } }
{ $description "Updates the modification time of a file or directory. If the file does not exist, creates a new, empty file." }
{ $errors "Throws an error if the file could not be touched." } ;
HELP: move-file
{ $values { "from" "a pathname string" } { "to" "a pathname string" } }
{ $description "Moves or renames a file." }
{ $errors "Throws an error if the file does not exist or if the move operation fails." } ;
HELP: move-file-into
{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } }
{ $description "Moves a file to another directory without renaming it." }
{ $errors "Throws an error if the file does not exist or if the move operation fails." } ;
HELP: move-files-into
{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } }
{ $description "Moves a set of files to another directory." }
{ $errors "Throws an error if the file does not exist or if the move operation fails." } ;
HELP: copy-file
{ $values { "from" "a pathname string" } { "to" "a pathname string" } }
{ $description "Copies a file." }
{ $notes "This operation attempts to preserve the original file's attributes, however not all attributes may be preserved." }
{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ;
HELP: copy-file-into
{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } }
{ $description "Copies a file to another directory." }
{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ;
HELP: copy-files-into
{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } }
{ $description "Copies a set of files to another directory." }
{ $errors "Throws an error if the file does not exist or if the copy operation fails." } ;
ARTICLE: "current-directory" "Current working directory"
"File system I/O operations use the value of a variable to resolve relative pathnames:"
{ $subsection current-directory }
"This variable can be changed with a pair of words:"
{ $subsection set-current-directory }
{ $subsection with-directory }
"This variable is independent of the operating system notion of ``current working directory''. While all Factor I/O operations use the variable and not the operating system's value, care must be taken when making FFI calls which expect a pathname. The first option is to resolve relative paths:"
{ $subsection (normalize-path) }
"The second is to change the working directory of the current process:"
{ $subsection cd }
{ $subsection cwd } ;
ARTICLE: "io.directories.listing" "Directory listing"
"Directory listing:"
{ $subsection directory-entries }
{ $subsection directory-files }
{ $subsection with-directory-files } ;
ARTICLE: "io.directories.create" "Creating directories"
{ $subsection make-directory }
{ $subsection make-directories } ;
ARTICLE: "delete-move-copy" "Deleting, moving, and copying files"
"Operations for deleting and copying files come in two forms:"
{ $list
{ "Words named " { $snippet { $emphasis "operation" } "-file" } " which work on regular files only." }
{ "Words named " { $snippet { $emphasis "operation" } "-tree" } " works on directory trees recursively, and also accepts regular files." }
}
"The operations for moving and copying files come in three flavors:"
{ $list
{ "A word named " { $snippet { $emphasis "operation" } } " which takes a source and destination path." }
{ "A word named " { $snippet { $emphasis "operation" } "-into" } " which takes a source path and destination directory. The destination file will be stored in the destination directory and will have the same file name as the source path." }
{ "A word named " { $snippet { $emphasis "operation" } "s-into" } " which takes a sequence of source paths and destination directory." }
}
"Since both of the above lists apply to copying files, that this means that there are a total of six variations on copying a file."
$nl
"Deleting files:"
{ $subsection delete-file }
{ $subsection delete-directory }
"Moving files:"
{ $subsection move-file }
{ $subsection move-file-into }
{ $subsection move-files-into }
"Copying files:"
{ $subsection copy-file }
{ $subsection copy-file-into }
{ $subsection copy-files-into }
"On most operating systems, files can only be moved within the same file system. To move files between file systems, use " { $link copy-file } " followed by " { $link delete-file } " on the old name." ;
ARTICLE: "io.directories" "Directory manipulation"
"The " { $vocab-link "io.directories" } " vocabulary defines words for inspecting and manipulating directory trees."
{ $subsection home }
{ $subsection "current-directory" }
{ $subsection "io.directories.listing" }
{ $subsection "io.directories.create" }
{ $subsection "delete-move-copy" } ;
ABOUT: "io.directories"

View File

@ -0,0 +1,189 @@
USING: continuations destructors io io.directories
io.directories.hierarchy io.encodings.ascii io.encodings.utf8
io.files io.files.info io.files.temp io.pathnames kernel
sequences tools.test ;
IN: io.directories.tests
[ { "kernel" } ] [
"core" resource-path [
"." directory-files [ "kernel" = ] filter
] with-directory
] unit-test
[ { "kernel" } ] [
"resource:core" [
"." directory-files [ "kernel" = ] filter
] with-directory
] unit-test
[ { "kernel" } ] [
"resource:core" [
[ "kernel" = ] filter
] with-directory-files
] unit-test
[ ] [ "blahblah" temp-file dup exists? [ delete-directory ] [ drop ] if ] unit-test
[ ] [ "blahblah" temp-file make-directory ] unit-test
[ t ] [ "blahblah" temp-file file-info directory? ] unit-test
[ t ] [
[ temp-directory "loldir" append-path delete-directory ] ignore-errors
temp-directory [
"loldir" make-directory
] with-directory
temp-directory "loldir" append-path exists?
] unit-test
[ ] [
[ temp-directory "loldir" append-path delete-directory ] ignore-errors
temp-directory [
"loldir" make-directory
"loldir" delete-directory
] with-directory
] unit-test
[ "file1 contents" ] [
[ temp-directory "loldir" append-path delete-directory ] ignore-errors
temp-directory [
"file1 contents" "file1" utf8 set-file-contents
"file1" "file2" copy-file
"file2" utf8 file-contents
] with-directory
"file1" temp-file delete-file
"file2" temp-file delete-file
] unit-test
[ "file3 contents" ] [
temp-directory [
"file3 contents" "file3" utf8 set-file-contents
"file3" "file4" move-file
"file4" utf8 file-contents
] with-directory
"file4" temp-file delete-file
] unit-test
[ "file5" temp-file delete-file ] ignore-errors
[ ] [
temp-directory [
"file5" touch-file
"file5" delete-file
] with-directory
] unit-test
[ "file6" temp-file delete-file ] ignore-errors
[ ] [
temp-directory [
"file6" touch-file
"file6" link-info drop
] with-directory
] unit-test
[ ] [
{ "Hello world." }
"test-foo.txt" temp-file ascii set-file-lines
] unit-test
[ ] [
"test-foo.txt" temp-file ascii [
"Hello appender." print
] with-file-appender
] unit-test
[ ] [
"test-bar.txt" temp-file ascii [
"Hello appender." print
] with-file-appender
] unit-test
[ "Hello world.\nHello appender.\n" ] [
"test-foo.txt" temp-file ascii file-contents
] unit-test
[ "Hello appender.\n" ] [
"test-bar.txt" temp-file ascii file-contents
] unit-test
[ ] [ "test-foo.txt" temp-file delete-file ] unit-test
[ ] [ "test-bar.txt" temp-file delete-file ] unit-test
[ f ] [ "test-foo.txt" temp-file exists? ] unit-test
[ f ] [ "test-bar.txt" temp-file exists? ] unit-test
[ "test-blah" temp-file delete-tree ] ignore-errors
[ ] [ "test-blah" temp-file make-directory ] unit-test
[ ] [
"test-blah/fooz" temp-file ascii <file-writer> dispose
] unit-test
[ t ] [
"test-blah/fooz" temp-file exists?
] unit-test
[ ] [ "test-blah/fooz" temp-file delete-file ] unit-test
[ ] [ "test-blah" temp-file delete-directory ] unit-test
[ f ] [ "test-blah" temp-file exists? ] unit-test
[ ] [ "delete-tree-test/a/b/c" temp-file make-directories ] unit-test
[ ] [
{ "Hi" }
"delete-tree-test/a/b/c/d" temp-file ascii set-file-lines
] unit-test
[ ] [
"delete-tree-test" temp-file delete-tree
] unit-test
[ ] [
"copy-tree-test/a/b/c" temp-file make-directories
] unit-test
[ ] [
"Foobar"
"copy-tree-test/a/b/c/d" temp-file
ascii set-file-contents
] unit-test
[ ] [
"copy-tree-test" temp-file
"copy-destination" temp-file copy-tree
] unit-test
[ "Foobar" ] [
"copy-destination/a/b/c/d" temp-file ascii file-contents
] unit-test
[ ] [
"copy-destination" temp-file delete-tree
] unit-test
[ ] [
"copy-tree-test" temp-file
"copy-destination" temp-file copy-tree-into
] unit-test
[ "Foobar" ] [
"copy-destination/copy-tree-test/a/b/c/d" temp-file ascii file-contents
] unit-test
[ ] [
"copy-destination/copy-tree-test/a/b/c/d" temp-file "" temp-file copy-file-into
] unit-test
[ "Foobar" ] [
"d" temp-file ascii file-contents
] unit-test
[ ] [ "d" temp-file delete-file ] unit-test
[ ] [ "copy-destination" temp-file delete-tree ] unit-test
[ ] [ "copy-tree-test" temp-file delete-tree ] unit-test

View File

@ -0,0 +1,87 @@
! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors combinators destructors io io.backend
io.encodings.binary io.files io.pathnames kernel namespaces
sequences system vocabs.loader fry ;
IN: io.directories
: set-current-directory ( path -- )
(normalize-path) current-directory set ;
: with-directory ( path quot -- )
[ (normalize-path) current-directory ] dip with-variable ; inline
! Creating directories
HOOK: make-directory io-backend ( path -- )
: make-directories ( path -- )
normalize-path trim-right-separators {
{ [ dup "." = ] [ ] }
{ [ dup root-directory? ] [ ] }
{ [ dup empty? ] [ ] }
{ [ dup exists? ] [ ] }
[
dup parent-directory make-directories
dup make-directory
]
} cond drop ;
! Listing directories
TUPLE: directory-entry name type ;
HOOK: >directory-entry os ( byte-array -- directory-entry )
HOOK: (directory-entries) os ( path -- seq )
: directory-entries ( path -- seq )
normalize-path
(directory-entries)
[ name>> { "." ".." } member? not ] filter ;
: directory-files ( path -- seq )
directory-entries [ name>> ] map ;
: with-directory-files ( path quot -- )
'[ "" directory-files @ ] with-directory ; inline
! Touching files
HOOK: touch-file io-backend ( path -- )
! Deleting files
HOOK: delete-file io-backend ( path -- )
HOOK: delete-directory io-backend ( path -- )
: to-directory ( from to -- from to' )
over file-name append-path ;
! Moving and renaming files
HOOK: move-file io-backend ( from to -- )
: move-file-into ( from to -- )
to-directory move-file ;
: move-files-into ( files to -- )
'[ _ move-file-into ] each ;
! Copying files
HOOK: copy-file io-backend ( from to -- )
M: object copy-file
dup parent-directory make-directories
binary <file-writer> [
swap binary <file-reader> [
swap stream-copy
] with-disposal
] with-disposal ;
: copy-file-into ( from to -- )
to-directory copy-file ;
: copy-files-into ( files to -- )
'[ _ copy-file-into ] each ;
{
{ [ os unix? ] [ "io.directories.unix" require ] }
{ [ os windows? ] [ "io.directories.windows" require ] }
} cond

View File

@ -0,0 +1,36 @@
USING: help.markup help.syntax ;
IN: io.directories.hierarchy
HELP: delete-tree
{ $values { "path" "a pathname string" } }
{ $description "Deletes a file or directory, recursing into subdirectories." }
{ $errors "Throws an error if the deletion fails." }
{ $warning "Misuse of this word can lead to catastrophic data loss." } ;
HELP: copy-tree
{ $values { "from" "a pathname string" } { "to" "a pathname string" } }
{ $description "Copies a directory tree recursively." }
{ $notes "This operation attempts to preserve original file attributes, however not all attributes may be preserved." }
{ $errors "Throws an error if the copy operation fails." } ;
HELP: copy-tree-into
{ $values { "from" "a pathname string" } { "to" "a directory pathname string" } }
{ $description "Copies a directory tree to another directory, recursively." }
{ $errors "Throws an error if the copy operation fails." } ;
HELP: copy-trees-into
{ $values { "files" "a sequence of pathname strings" } { "to" "a directory pathname string" } }
{ $description "Copies a set of directory trees to another directory, recursively." }
{ $errors "Throws an error if the copy operation fails." } ;
ARTICLE: "io.directories.hierarchy" "Directory hierarchy manipulation"
"The " { $vocab-link "io.directories.hierarchy" } " vocabulary defines words for operating on directory hierarchies recursively."
$nl
"Deleting directory trees recursively:"
{ $subsection delete-tree }
"Copying directory trees recursively:"
{ $subsection copy-tree }
{ $subsection copy-tree-into }
{ $subsection copy-trees-into } ;
ABOUT: "io.directories.hierarchy"

View File

@ -0,0 +1,31 @@
! Copyright (C) 2004, 2008 Slava Pestov, Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors sequences combinators fry io.directories
io.pathnames io.files.info io.files.types io.files.links
io.backend ;
IN: io.directories.hierarchy
: delete-tree ( path -- )
dup link-info directory? [
[ [ [ delete-tree ] each ] with-directory-files ]
[ delete-directory ]
bi
] [ delete-file ] if ;
DEFER: copy-tree-into
: copy-tree ( from to -- )
normalize-path
over link-info type>>
{
{ +symbolic-link+ [ copy-link ] }
{ +directory+ [ '[ [ _ copy-tree-into ] each ] with-directory-files ] }
[ drop copy-file ]
} case ;
: copy-tree-into ( from to -- )
to-directory copy-tree ;
: copy-trees-into ( files to -- )
'[ _ copy-tree-into ] each ;

View File

@ -0,0 +1 @@
Deleting and copying directory hierarchies

View File

@ -1,6 +1,6 @@
USING: io.paths kernel tools.test io.files.unique sequences USING: io.directories.search io.files io.files.unique
io.files namespaces sorting ; io.pathnames kernel namespaces sequences sorting tools.test ;
IN: io.paths.tests IN: io.directories.search.tests
[ t ] [ [ t ] [
[ [

View File

@ -1,8 +1,9 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays deques dlists io.files USING: accessors arrays continuations deques dlists fry
kernel sequences system vocabs.loader fry continuations ; io.directories io.files io.files.info io.pathnames kernel
IN: io.paths sequences system vocabs.loader ;
IN: io.directories.search
TUPLE: directory-iterator path bfs queue ; TUPLE: directory-iterator path bfs queue ;

View File

@ -1,8 +1,7 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays continuations fry io.files io.paths USING: arrays fry io.pathnames kernel sequences windows.shell32 ;
kernel windows.shell32 sequences ; IN: io.paths
IN: io.paths.windows
: program-files-directories ( -- array ) : program-files-directories ( -- array )
program-files program-files-x86 2array ; inline program-files program-files-x86 2array ; inline

View File

@ -0,0 +1 @@
Listing directories, moving, copying and deleting files

View File

@ -0,0 +1,73 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.strings combinators
continuations destructors fry io io.backend io.backend.unix
io.directories io.encodings.binary io.encodings.utf8 io.files
io.pathnames io.files.types kernel math.bitwise sequences system
unix unix.stat ;
IN: io.directories.unix
: touch-mode ( -- n )
{ O_WRONLY O_APPEND O_CREAT O_EXCL } flags ; foldable
M: unix touch-file ( path -- )
normalize-path
dup exists? [ touch ] [
touch-mode file-mode open-file close-file
] if ;
M: unix move-file ( from to -- )
[ normalize-path ] bi@ rename io-error ;
M: unix delete-file ( path -- ) normalize-path unlink-file ;
M: unix make-directory ( path -- )
normalize-path OCT: 777 mkdir io-error ;
M: unix delete-directory ( path -- )
normalize-path rmdir io-error ;
: (copy-file) ( from to -- )
dup parent-directory make-directories
binary <file-writer> [
swap binary <file-reader> [
swap stream-copy
] with-disposal
] with-disposal ;
M: unix copy-file ( from to -- )
[ normalize-path ] bi@ (copy-file) ;
: with-unix-directory ( path quot -- )
[ opendir dup [ (io-error) ] unless ] dip
dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline
: find-next-file ( DIR* -- byte-array )
"dirent" <c-object>
f <void*>
[ readdir_r 0 = [ (io-error) ] unless ] 2keep
*void* [ drop f ] unless ;
: dirent-type>file-type ( ch -- type )
{
{ DT_BLK [ +block-device+ ] }
{ DT_CHR [ +character-device+ ] }
{ DT_DIR [ +directory+ ] }
{ DT_LNK [ +symbolic-link+ ] }
{ DT_SOCK [ +socket+ ] }
{ DT_FIFO [ +fifo+ ] }
{ DT_REG [ +regular-file+ ] }
{ DT_WHT [ +whiteout+ ] }
[ drop +unknown+ ]
} case ;
M: unix >directory-entry ( byte-array -- directory-entry )
[ dirent-d_name utf8 alien>string ]
[ dirent-d_type dirent-type>file-type ] bi directory-entry boa ;
M: unix (directory-entries) ( path -- seq )
[
'[ _ find-next-file dup ]
[ >directory-entry ]
[ drop ] produce
] with-unix-directory ;

View File

@ -0,0 +1,68 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: system io.directories io.encodings.utf16n alien.strings
io.pathnames io.backend io.files.windows destructors
kernel accessors calendar windows windows.errors
windows.kernel32 alien.c-types sequences splitting
fry continuations ;
IN: io.directories.windows
M: windows touch-file ( path -- )
[
normalize-path
maybe-create-file [ &dispose ] dip
[ drop ] [ handle>> f now dup (set-file-times) ] if
] with-destructors ;
M: windows move-file ( from to -- )
[ normalize-path ] bi@ MoveFile win32-error=0/f ;
M: windows delete-file ( path -- )
normalize-path DeleteFile win32-error=0/f ;
M: windows copy-file ( from to -- )
dup parent-directory make-directories
[ normalize-path ] bi@ 0 CopyFile win32-error=0/f ;
M: windows make-directory ( path -- )
normalize-path
f CreateDirectory win32-error=0/f ;
M: windows delete-directory ( path -- )
normalize-path
RemoveDirectory win32-error=0/f ;
: find-first-file ( path -- WIN32_FIND_DATA handle )
"WIN32_FIND_DATA" <c-object> tuck
FindFirstFile
[ INVALID_HANDLE_VALUE = [ win32-error-string throw ] when ] keep ;
: find-next-file ( path -- WIN32_FIND_DATA/f )
"WIN32_FIND_DATA" <c-object> tuck
FindNextFile 0 = [
GetLastError ERROR_NO_MORE_FILES = [
win32-error
] unless drop f
] when ;
TUPLE: windows-directory-entry < directory-entry attributes ;
M: windows >directory-entry ( byte-array -- directory-entry )
[ WIN32_FIND_DATA-cFileName utf16n alien>string ]
[ WIN32_FIND_DATA-dwFileAttributes win32-file-type ]
[ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ]
tri
dupd remove windows-directory-entry boa ;
M: windows (directory-entries) ( path -- seq )
"\\" ?tail drop "\\*" append
find-first-file [ >directory-entry ] dip
[
'[
[ _ find-next-file dup ]
[ >directory-entry ]
[ drop ] produce
over name>> "." = [ nip ] [ swap prefix ] if
]
] [ '[ _ FindClose win32-error=0/f ] ] bi [ ] cleanup ;

View File

@ -0,0 +1 @@
Daniel Ehrenberg

View File

@ -0,0 +1,11 @@
USING: help.syntax help.markup ;
IN: io.encodings.binary
HELP: binary
{ $class-description "Encoding descriptor for binary I/O." } ;
ARTICLE: "io.encodings.binary" "Binary encoding"
"Making an encoded stream with the binary encoding is a no-op; streams with this encoding deal with byte-arrays, not strings."
{ $subsection binary } ;
ABOUT: "io.encodings.binary"

View File

@ -0,0 +1,8 @@
! Copyright (C) 2008 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: io.encodings kernel ;
IN: io.encodings.binary
SINGLETON: binary
M: binary <encoder> drop ;
M: binary <decoder> drop ;

View File

@ -0,0 +1 @@
Dummy encoding for binary I/O

View File

@ -0,0 +1 @@
text

View File

@ -1 +1,2 @@
Slava Pestov Slava Pestov
Doug Coleman

View File

@ -0,0 +1,41 @@
USING: help.markup help.syntax arrays io.files ;
IN: io.files.info
HELP: file-info
{ $values { "path" "a pathname string" } { "info" file-info } }
{ $description "Queries the file system for metadata. If " { $snippet "path" } " refers to a symbolic link, it is followed. See the article " { $link "file-types" } " for a list of metadata symbols." }
{ $errors "Throws an error if the file does not exist." } ;
HELP: link-info
{ $values { "path" "a pathname string" } { "info" "a file-info tuple" } }
{ $description "Queries the file system for metadata. If path refers to a symbolic link, information about the symbolic link itself is returned. If the file does not exist, an exception is thrown." } ;
{ file-info link-info } related-words
HELP: directory?
{ $values { "file-info" file-info } { "?" "a boolean" } }
{ $description "Tests if " { $snippet "file-info" } " is a directory." } ;
HELP: file-systems
{ $values { "array" array } }
{ $description "Returns an array of " { $link file-system-info } " objects returned by iterating the mount points and calling " { $link file-system-info } " on each." } ;
HELP: file-system-info
{ $values
{ "path" "a pathname string" }
{ "file-system-info" file-system-info } }
{ $description "Returns a platform-specific object describing the file-system that contains the path. The cross-platform slot is " { $slot "free-space" } "." } ;
ARTICLE: "io.files.info" "File system meta-data"
"File meta-data:"
{ $subsection file-info }
{ $subsection link-info }
{ $subsection exists? }
{ $subsection directory? }
"File types:"
{ $subsection "file-types" }
"File system meta-data:"
{ $subsection file-system-info }
{ $subsection file-systems } ;
ABOUT: "io.files.info"

View File

@ -0,0 +1,19 @@
USING: io.files.info io.pathnames io.encodings.utf8 io.files
io.directories kernel io.pathnames accessors tools.test
sequences io.files.temp ;
IN: io.files.info.tests
\ file-info must-infer
\ link-info must-infer
[ t ] [
temp-directory [ "hi41" "test41" utf8 set-file-contents ] with-directory
temp-directory "test41" append-path utf8 file-contents "hi41" =
] unit-test
[ t ] [
temp-directory [ "test41" file-info size>> ] with-directory 4 =
] unit-test
[ t ] [ "/" file-system-info file-system-info? ] unit-test
[ t ] [ file-systems [ file-system-info? ] all? ] unit-test

View File

@ -0,0 +1,28 @@
! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel system sequences combinators
vocabs.loader io.files.types ;
IN: io.files.info
! File info
TUPLE: file-info type size permissions created modified
accessed ;
HOOK: file-info os ( path -- info )
HOOK: link-info os ( path -- info )
: directory? ( file-info -- ? ) type>> +directory+ = ;
! File systems
HOOK: file-systems os ( -- array )
TUPLE: file-system-info device-name mount-point type
available-space free-space used-space total-space ;
HOOK: file-system-info os ( path -- file-system-info )
{
{ [ os unix? ] [ "io.files.info.unix." os name>> append ] }
{ [ os windows? ] [ "io.files.info.windows" ] }
} cond require

View File

@ -0,0 +1 @@
File and file system meta-data

Some files were not shown because too many files have changed in this diff Show More