Merge branch 'master' of git://factorcode.org/git/factor
commit
ceb78e417f
|
@ -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
|
||||
|
||||
ARTICLE: "bootstrap.image" "Bootstrapping new images"
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien arrays byte-arrays generic assocs hashtables assocs
|
||||
hashtables.private io kernel kernel.private math namespaces make
|
||||
parser prettyprint sequences sequences.private strings sbufs
|
||||
hashtables.private io io.binary io.files io.encodings.binary
|
||||
io.pathnames kernel kernel.private math namespaces make parser
|
||||
prettyprint sequences sequences.private strings sbufs
|
||||
vectors words quotations assocs system layouts splitting
|
||||
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
|
||||
quotations.private sequences.private combinators
|
||||
io.encodings.binary math.order math.private accessors
|
||||
math.order math.private accessors
|
||||
slots.private compiler.units ;
|
||||
IN: bootstrap.image
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: checksums checksums.openssl splitting assocs
|
||||
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
|
||||
|
||||
SYMBOL: upload-images-destination
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
USING: system vocabs vocabs.loader kernel combinators
|
||||
namespaces sequences io.backend ;
|
||||
namespaces sequences io.backend accessors ;
|
||||
IN: bootstrap.io
|
||||
|
||||
"bootstrap.compiler" vocab [
|
||||
"io." {
|
||||
"io.backend." {
|
||||
{ [ "io-backend" get ] [ "io-backend" get ] }
|
||||
{ [ os unix? ] [ "unix" ] }
|
||||
{ [ os unix? ] [ "unix." os name>> append ] }
|
||||
{ [ os winnt? ] [ "windows.nt" ] }
|
||||
{ [ os wince? ] [ "windows.ce" ] }
|
||||
} cond append require
|
||||
] when
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors init namespaces words io
|
||||
kernel.private math memory continuations kernel io.files
|
||||
io.backend system parser vocabs sequences
|
||||
vocabs.loader combinators splitting source-files strings
|
||||
definitions assocs compiler.errors compiler.units
|
||||
math.parser generic sets command-line ;
|
||||
USING: accessors init namespaces words io kernel.private math
|
||||
memory continuations kernel io.files io.pathnames io.backend
|
||||
system parser vocabs sequences vocabs.loader combinators
|
||||
splitting source-files strings definitions assocs
|
||||
compiler.errors compiler.units math.parser generic sets
|
||||
command-line ;
|
||||
IN: bootstrap.stage2
|
||||
|
||||
SYMBOL: core-bootstrap-time
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2003, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: init continuations hashtables io io.encodings.utf8
|
||||
io.files kernel kernel.private namespaces parser sequences
|
||||
strings system splitting vocabs.loader ;
|
||||
io.files io.pathnames kernel kernel.private namespaces parser
|
||||
sequences strings system splitting vocabs.loader ;
|
||||
IN: command-line
|
||||
|
||||
SYMBOL: script
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
IN: concurrency.distributed.tests
|
||||
USING: tools.test concurrency.distributed kernel io.files
|
||||
arrays io.sockets system combinators threads math sequences
|
||||
concurrency.messaging continuations accessors prettyprint ;
|
||||
io.files.temp io.directories arrays io.sockets system
|
||||
combinators threads math sequences concurrency.messaging
|
||||
continuations accessors prettyprint ;
|
||||
|
||||
: test-node ( -- addrspec )
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ TYPEDEF: int SInt32
|
|||
TYPEDEF: uint UInt32
|
||||
TYPEDEF: ulong CFTypeID
|
||||
TYPEDEF: UInt32 CFOptionFlags
|
||||
TYPEDEF: void* CFUUIDRef
|
||||
|
||||
FUNCTION: CFTypeRef CFRetain ( CFTypeRef cf ) ;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ TYPEDEF: void* CFDictionaryRef
|
|||
TYPEDEF: void* CFMutableDictionaryRef
|
||||
TYPEDEF: void* CFNumberRef
|
||||
TYPEDEF: void* CFSetRef
|
||||
TYPEDEF: void* CFUUIDRef
|
||||
|
||||
TYPEDEF: int CFNumberType
|
||||
: kCFNumberSInt8Type 1 ; inline
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
IN: db.pools.tests
|
||||
USING: db.pools tools.test continuations io.files namespaces
|
||||
accessors kernel math destructors ;
|
||||
USING: db.pools tools.test continuations io.files io.files.temp
|
||||
io.directories namespaces accessors kernel math destructors ;
|
||||
|
||||
\ <db-pool> must-infer
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: io io.files io.launcher kernel namespaces
|
||||
prettyprint tools.test db.sqlite db sequences
|
||||
USING: io io.files io.files.temp io.directories io.launcher
|
||||
kernel namespaces prettyprint tools.test db.sqlite db sequences
|
||||
continuations db.types db.tuples unicode.case ;
|
||||
IN: db.sqlite.tests
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! 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
|
||||
prettyprint calendar sequences db.sqlite math.intervals
|
||||
db.postgresql accessors random math.bitwise system
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: slots arrays definitions generic hashtables summary io
|
||||
kernel math namespaces make prettyprint prettyprint.config
|
||||
sequences assocs sequences.private strings io.styles io.files
|
||||
vectors words system splitting math.parser classes.mixin
|
||||
classes.tuple continuations continuations.private combinators
|
||||
generic.math classes.builtin classes compiler.units
|
||||
sequences assocs sequences.private strings io.styles
|
||||
io.pathnames vectors words system splitting math.parser
|
||||
classes.mixin classes.tuple continuations continuations.private
|
||||
combinators generic.math classes.builtin classes compiler.units
|
||||
generic.standard vocabs init kernel.private io.encodings
|
||||
accessors math.order destructors source-files parser
|
||||
classes.tuple.parser effects.parser lexer compiler.errors
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: parser lexer kernel namespaces sequences definitions
|
||||
io.files summary continuations tools.crossref tools.vocabs io
|
||||
prettyprint source-files assocs vocabs vocabs.loader io.backend
|
||||
splitting accessors ;
|
||||
io.files io.backend io.pathnames io summary continuations
|
||||
tools.crossref tools.vocabs prettyprint source-files assocs
|
||||
vocabs vocabs.loader splitting accessors ;
|
||||
IN: editors
|
||||
|
||||
TUPLE: no-edit-hook ;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
USING: io.unix.backend kernel namespaces editors.gvim
|
||||
system ;
|
||||
USING: kernel namespaces editors.gvim system ;
|
||||
IN: editors.gvim.unix
|
||||
|
||||
M: unix gvim-path
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: editors.gvim io.files io.windows kernel namespaces
|
||||
sequences windows.shell32 io.paths.windows system ;
|
||||
USING: editors.gvim io.files kernel namespaces sequences
|
||||
windows.shell32 io.paths.windows system ;
|
||||
IN: editors.gvim.windows
|
||||
|
||||
M: windows gvim-path
|
||||
|
|
|
@ -4,7 +4,7 @@ USING: arrays definitions io kernel math
|
|||
namespaces parser prettyprint sequences strings words
|
||||
editors io.files io.sockets io.streams.byte-array io.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
|
||||
|
||||
: jedit-server-info ( -- port auth )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays classes.singleton combinators
|
||||
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
|
||||
ftp.client.listing-parser urls ;
|
||||
IN: ftp.client
|
||||
|
@ -104,7 +104,3 @@ ERROR: ftp-error got expected ;
|
|||
[ nip parent-directory ftp-cwd drop ]
|
||||
[ file-name (ftp-get) ] 2bi
|
||||
] with-ftp-client ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! 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 ;
|
||||
IN: ftp.client.listing-parser
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: combinators.short-circuit accessors combinators io
|
||||
io.encodings.8-bit io.encodings io.encodings.binary
|
||||
io.encodings.utf8 io.files io.sockets kernel math.parser
|
||||
namespaces make sequences ftp io.unix.launcher.parser
|
||||
unicode.case splitting assocs classes io.servers.connection
|
||||
destructors calendar io.timeouts io.streams.duplex threads
|
||||
continuations math concurrency.promises byte-arrays
|
||||
io.backend tools.hexdump tools.files io.streams.string ;
|
||||
io.encodings.utf8 io.files io.files.info io.directories
|
||||
io.pathnames io.sockets kernel math.parser namespaces make
|
||||
sequences ftp io.launcher.unix.parser unicode.case splitting
|
||||
assocs classes io.servers.connection destructors calendar
|
||||
io.timeouts io.streams.duplex threads continuations math
|
||||
concurrency.promises byte-arrays io.backend tools.hexdump
|
||||
tools.files io.streams.string ;
|
||||
IN: ftp.server
|
||||
|
||||
TUPLE: ftp-client url mode state command-promise user password ;
|
||||
|
|
|
@ -5,7 +5,7 @@ furnace.auth.login
|
|||
furnace.auth.providers
|
||||
furnace.auth.providers.db tools.test
|
||||
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
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ IN: furnace.sessions.tests
|
|||
USING: tools.test http furnace.sessions furnace.actions
|
||||
http.server http.server.responses math namespaces make kernel
|
||||
accessors io.sockets io.servers.connection prettyprint
|
||||
io.streams.string io.files splitting destructors sequences db
|
||||
db.tuples db.sqlite continuations urls math.parser furnace
|
||||
furnace.utilities ;
|
||||
io.streams.string io.files io.files.temp io.directories
|
||||
splitting destructors sequences db db.tuples db.sqlite
|
||||
continuations urls math.parser furnace furnace.utilities ;
|
||||
|
||||
: with-session
|
||||
[
|
||||
|
|
|
@ -168,6 +168,11 @@ ARTICLE: "io" "Input and output"
|
|||
{ $heading "Streams" }
|
||||
{ $subsection "streams" }
|
||||
{ $subsection "io.files" }
|
||||
{ $heading "The file system" }
|
||||
{ $subsection "io.pathnames" }
|
||||
{ $subsection "io.files.info" }
|
||||
{ $subsection "io.files.links" }
|
||||
{ $subsection "io.directories" }
|
||||
{ $heading "Encodings" }
|
||||
{ $subsection "encodings-introduction" }
|
||||
{ $subsection "io.encodings" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
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
|
||||
tools.vocabs tools.vocabs.browser namespaces prettyprint io
|
||||
vocabs.loader serialize fry memoize unicode.case math.order
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors kernel sequences combinators kernel fry
|
||||
namespaces make classes.tuple assocs splitting words arrays io
|
||||
io.files io.encodings.utf8 io.streams.string unicode.case
|
||||
mirrors math urls present multiline quotations xml logging
|
||||
continuations
|
||||
io.files io.files.info io.encodings.utf8 io.streams.string
|
||||
unicode.case mirrors math urls present multiline quotations xml
|
||||
logging continuations
|
||||
xml.data
|
||||
html.forms
|
||||
html.elements
|
||||
|
|
|
@ -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
|
||||
urls.encoding byte-arrays strings assocs sequences ;
|
||||
IN: http.client
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
! Copyright (C) 2005, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors assocs kernel math math.parser namespaces make
|
||||
sequences io io.sockets io.streams.string io.files io.timeouts
|
||||
strings splitting calendar continuations accessors vectors
|
||||
sequences strings splitting calendar continuations accessors vectors
|
||||
math.order hashtables byte-arrays destructors
|
||||
io.encodings
|
||||
io.encodings.string
|
||||
io.encodings.ascii
|
||||
io.encodings.utf8
|
||||
io.encodings.8-bit
|
||||
io.encodings.binary
|
||||
io.streams.duplex
|
||||
fry ascii urls urls.encoding present
|
||||
io io.sockets io.streams.string io.files io.timeouts
|
||||
io.pathnames io.encodings io.encodings.string io.encodings.ascii
|
||||
io.encodings.utf8 io.encodings.8-bit io.encodings.binary
|
||||
io.streams.duplex fry ascii urls urls.encoding present
|
||||
http http.parsers ;
|
||||
IN: http.client
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
|
|||
! Live-fire exercise
|
||||
USING: http.server http.server.static furnace.sessions furnace.alloy
|
||||
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
|
||||
http.server.responses http.server.redirection furnace.redirection
|
||||
http.server.dispatchers db.tuples ;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
! Copyright (C) 2004, 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: calendar io io.files kernel math math.order
|
||||
math.parser namespaces parser sequences strings
|
||||
assocs hashtables debugger mime.types sorting logging
|
||||
calendar.format accessors splitting
|
||||
io.encodings.binary fry xml.entities destructors urls
|
||||
html.elements html.templates.fhtml
|
||||
http
|
||||
http.server
|
||||
http.server.responses
|
||||
USING: calendar kernel math math.order math.parser namespaces
|
||||
parser sequences strings assocs hashtables debugger mime.types
|
||||
sorting logging calendar.format accessors splitting io io.files
|
||||
io.files.info io.directories io.pathnames io.encodings.binary
|
||||
fry xml.entities destructors urls html.elements
|
||||
html.templates.fhtml http http.server http.server.responses
|
||||
http.server.redirection ;
|
||||
IN: http.server.static
|
||||
|
||||
|
|
0
basis/io/unix/backend/authors.txt → basis/io/backend/unix/bsd/authors.txt
Normal file → Executable file
0
basis/io/unix/backend/authors.txt → basis/io/backend/unix/bsd/authors.txt
Normal file → Executable file
|
@ -1,9 +1,9 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: namespaces system kernel accessors assocs continuations
|
||||
unix io.backend io.unix.backend io.unix.multiplexers
|
||||
io.unix.multiplexers.kqueue ;
|
||||
IN: io.unix.bsd
|
||||
unix io.backend io.backend.unix io.backend.unix.multiplexers
|
||||
io.backend.unix.multiplexers.kqueue io.files.unix ;
|
||||
IN: io.backend.unix.bsd
|
||||
|
||||
M: bsd init-io ( -- )
|
||||
<kqueue-mx> mx set-global ;
|
|
@ -0,0 +1,3 @@
|
|||
USING: io.backend.unix.bsd io.backend system ;
|
||||
|
||||
freebsd set-io-backend
|
|
@ -1,8 +1,9 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel system namespaces io.backend io.unix.backend
|
||||
io.unix.multiplexers io.unix.multiplexers.epoll ;
|
||||
IN: io.unix.linux
|
||||
USING: kernel system namespaces io.files.unix io.backend
|
||||
io.backend.unix io.backend.unix.multiplexers
|
||||
io.backend.unix.multiplexers.epoll ;
|
||||
IN: io.backend.unix.linux
|
||||
|
||||
M: linux init-io ( -- )
|
||||
<epoll-mx> mx set-global ;
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: io.backend system namespaces io.unix.multiplexers
|
||||
io.unix.multiplexers.run-loop ;
|
||||
IN: io.unix.macosx
|
||||
USING: io.backend system namespaces io.backend.unix.bsd
|
||||
io.backend.unix.multiplexers io.backend.unix.multiplexers.run-loop ;
|
||||
IN: io.backend.macosx
|
||||
|
||||
M: macosx init-io ( -- )
|
||||
<run-loop-mx> mx set-global ;
|
|
@ -2,9 +2,9 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types kernel destructors bit-arrays
|
||||
sequences assocs struct-arrays math namespaces locals fry unix
|
||||
unix.linux.epoll unix.time io.ports io.unix.backend
|
||||
io.unix.multiplexers ;
|
||||
IN: io.unix.multiplexers.epoll
|
||||
unix.linux.epoll unix.time io.ports io.backend.unix
|
||||
io.backend.unix.multiplexers ;
|
||||
IN: io.backend.unix.multiplexers.epoll
|
||||
|
||||
TUPLE: epoll-mx < mx events ;
|
||||
|
0
basis/io/unix/files/authors.txt → basis/io/backend/unix/multiplexers/kqueue/authors.txt
Normal file → Executable file
0
basis/io/unix/files/authors.txt → basis/io/backend/unix/multiplexers/kqueue/authors.txt
Normal file → Executable file
|
@ -1,9 +1,9 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types combinators destructors
|
||||
io.unix.backend kernel math.bitwise sequences struct-arrays unix
|
||||
unix.kqueue unix.time assocs io.unix.multiplexers ;
|
||||
IN: io.unix.multiplexers.kqueue
|
||||
io.backend.unix kernel math.bitwise sequences struct-arrays unix
|
||||
unix.kqueue unix.time assocs io.backend.unix.multiplexers ;
|
||||
IN: io.backend.unix.multiplexers.kqueue
|
||||
|
||||
TUPLE: kqueue-mx < mx events ;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel accessors assocs sequences threads ;
|
||||
IN: io.unix.multiplexers
|
||||
IN: io.backend.unix.multiplexers
|
||||
|
||||
TUPLE: mx fd reads writes ;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
! Copyright (C) 2008 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel arrays namespaces math accessors alien locals
|
||||
destructors system threads io.unix.multiplexers
|
||||
io.unix.multiplexers.kqueue core-foundation
|
||||
destructors system threads io.backend.unix.multiplexers
|
||||
io.backend.unix.multiplexers.kqueue core-foundation
|
||||
core-foundation.run-loop ;
|
||||
IN: io.unix.multiplexers.run-loop
|
||||
IN: io.backend.unix.multiplexers.run-loop
|
||||
|
||||
TUPLE: run-loop-mx kqueue-mx ;
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.c-types kernel bit-arrays sequences assocs unix
|
||||
math namespaces accessors math.order locals unix.time fry
|
||||
io.ports io.unix.backend io.unix.multiplexers ;
|
||||
IN: io.unix.multiplexers.select
|
||||
io.ports io.backend.unix io.backend.unix.multiplexers ;
|
||||
IN: io.backend.unix.multiplexers.select
|
||||
|
||||
TUPLE: select-mx < mx read-fdset write-fdset ;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
USING: io.backend.unix.bsd io.backend system ;
|
||||
|
||||
netbsd set-io-backend
|
|
@ -0,0 +1,3 @@
|
|||
USING: io.backend.unix.bsd io.backend system ;
|
||||
|
||||
openbsd set-io-backend
|
|
@ -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
|
||||
sequences prettyprint system io.encodings.binary io.encodings.ascii
|
||||
io.streams.duplex destructors make ;
|
||||
IN: io.unix.tests
|
||||
IN: io.backend.unix.tests
|
||||
|
||||
! Unix domain stream sockets
|
||||
: socket-server "unix-domain-socket-test" temp-file ;
|
|
@ -5,9 +5,9 @@ kernel.private math io.ports sequences strings sbufs threads
|
|||
unix vectors io.buffers io.backend io.encodings math.parser
|
||||
continuations system libc qualified namespaces make io.timeouts
|
||||
io.encodings.utf8 destructors accessors summary combinators
|
||||
locals unix.time fry io.unix.multiplexers ;
|
||||
locals unix.time fry io.backend.unix.multiplexers ;
|
||||
QUALIFIED: io
|
||||
IN: io.unix.backend
|
||||
IN: io.backend.unix
|
||||
|
||||
GENERIC: handle-fd ( handle -- fd )
|
||||
|
12
basis/io/windows/nt/backend/backend.factor → basis/io/backend/windows/nt/nt.factor
Normal file → Executable file
12
basis/io/windows/nt/backend/backend.factor → basis/io/backend/windows/nt/nt.factor
Normal file → Executable file
|
@ -1,11 +1,11 @@
|
|||
USING: alien alien.c-types arrays assocs combinators
|
||||
continuations destructors io io.backend io.ports io.timeouts
|
||||
io.windows io.windows.files io.files io.buffers io.streams.c
|
||||
libc kernel math namespaces sequences threads windows
|
||||
windows.errors windows.kernel32 strings splitting qualified
|
||||
ascii system accessors locals ;
|
||||
io.backend.windows io.files.windows io.files.windows.nt io.files
|
||||
io.pathnames io.buffers io.streams.c libc kernel math namespaces
|
||||
sequences threads windows windows.errors windows.kernel32
|
||||
strings splitting qualified ascii system accessors locals ;
|
||||
QUALIFIED: windows.winsock
|
||||
IN: io.windows.nt.backend
|
||||
IN: io.backend.windows.nt
|
||||
|
||||
! Global variable with assoc mapping overlapped to threads
|
||||
SYMBOL: pending-overlapped
|
||||
|
@ -118,3 +118,5 @@ M: winnt (wait-to-read) ( port -- )
|
|||
] with-destructors ;
|
||||
|
||||
M: winnt (init-stdio) init-c-stdio ;
|
||||
|
||||
winnt set-io-backend
|
|
@ -1,9 +1,9 @@
|
|||
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
|
||||
windows.advapi32 windows.kernel32 io.backend system accessors
|
||||
io.windows.privileges ;
|
||||
IN: io.windows.nt.privileges
|
||||
io.backend.windows.privileges ;
|
||||
IN: io.backend.windows.nt.privileges
|
||||
|
||||
TYPEDEF: TOKEN_PRIVILEGES* PTOKEN_PRIVILEGES
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
USING: io.backend kernel continuations sequences
|
||||
system vocabs.loader combinators ;
|
||||
IN: io.windows.privileges
|
||||
IN: io.backend.windows.privileges
|
||||
|
||||
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
|
||||
|
||||
{
|
||||
{ [ os winnt? ] [ "io.windows.nt.privileges" require ] }
|
||||
{ [ os wince? ] [ "io.windows.ce.privileges" require ] }
|
||||
{ [ os winnt? ] [ "io.backend.windows.nt.privileges" require ] }
|
||||
{ [ os wince? ] [ "io.backend.windows.ce.privileges" require ] }
|
||||
} cond
|
|
@ -5,7 +5,7 @@ io.buffers io.files io.ports io.binary io.timeouts
|
|||
windows.errors strings kernel math namespaces sequences windows
|
||||
windows.kernel32 windows.shell32 windows.types windows.winsock
|
||||
splitting continuations math.bitwise system accessors ;
|
||||
IN: io.windows
|
||||
IN: io.backend.windows
|
||||
|
||||
: set-inherit ( handle ? -- )
|
||||
[ HANDLE_FLAG_INHERIT ] dip
|
|
@ -1 +1,2 @@
|
|||
Slava Pestov
|
||||
Doug Coleman
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
0
basis/io/unix/launcher/authors.txt → basis/io/directories/hierarchy/authors.txt
Executable file → Normal file
0
basis/io/unix/launcher/authors.txt → basis/io/directories/hierarchy/authors.txt
Executable file → Normal 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"
|
|
@ -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 ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
Deleting and copying directory hierarchies
|
|
@ -1,6 +1,6 @@
|
|||
USING: io.paths kernel tools.test io.files.unique sequences
|
||||
io.files namespaces sorting ;
|
||||
IN: io.paths.tests
|
||||
USING: io.directories.search io.files io.files.unique
|
||||
io.pathnames kernel namespaces sequences sorting tools.test ;
|
||||
IN: io.directories.search.tests
|
||||
|
||||
[ t ] [
|
||||
[
|
|
@ -1,8 +1,9 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays deques dlists io.files
|
||||
kernel sequences system vocabs.loader fry continuations ;
|
||||
IN: io.paths
|
||||
USING: accessors arrays continuations deques dlists fry
|
||||
io.directories io.files io.files.info io.pathnames kernel
|
||||
sequences system vocabs.loader ;
|
||||
IN: io.directories.search
|
||||
|
||||
TUPLE: directory-iterator path bfs queue ;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays continuations fry io.files io.paths
|
||||
kernel windows.shell32 sequences ;
|
||||
IN: io.paths.windows
|
||||
USING: arrays fry io.pathnames kernel sequences windows.shell32 ;
|
||||
IN: io.paths
|
||||
|
||||
: program-files-directories ( -- array )
|
||||
program-files program-files-x86 2array ; inline
|
|
@ -0,0 +1 @@
|
|||
Listing directories, moving, copying and deleting files
|
|
@ -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 ;
|
|
@ -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 ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
Daniel Ehrenberg
|
|
@ -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"
|
|
@ -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 ;
|
|
@ -0,0 +1 @@
|
|||
Dummy encoding for binary I/O
|
|
@ -0,0 +1 @@
|
|||
text
|
|
@ -1 +1,2 @@
|
|||
Slava Pestov
|
||||
Doug Coleman
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
|
@ -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
Loading…
Reference in New Issue