Split up io.directories further, move file types to io.files.types. Bunny demo no longer pulls in file-info and file-system-info code, reducing image size by 35kb

Slava Pestov 2008-12-15 00:01:06 -06:00
parent 6ea1de887d
commit 59a5e554d4
31 changed files with 187 additions and 161 deletions

View File

@ -0,0 +1 @@
unportable

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
ARTICLE: "bootstrap.image" "Bootstrapping new images"

View File

@ -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

View File

@ -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

View File

@ -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 ;

View File

@ -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 )

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
urls.encoding byte-arrays strings assocs sequences ;
IN: http.client

View File

@ -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

View File

@ -1,3 +1,5 @@
USING: help.markup help.syntax io.files.private io.pathnames
quotations ;
IN: io.directories
HELP: cwd
@ -73,12 +75,6 @@ HELP: touch-file
{ $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: 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: move-file
{ $values { "from" "a pathname string" } { "to" "a pathname string" } }
{ $description "Moves or renames a file." }
@ -110,22 +106,6 @@ HELP: copy-files-into
{ $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." } ;
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: "current-directory" "Current working directory"
"File system I/O operations use the value of a variable to resolve relative pathnames:"
{ $subsection current-directory }
@ -165,7 +145,6 @@ $nl
"Deleting files:"
{ $subsection delete-file }
{ $subsection delete-directory }
{ $subsection delete-tree }
"Moving files:"
{ $subsection move-file }
{ $subsection move-file-into }
@ -174,10 +153,6 @@ $nl
{ $subsection copy-file }
{ $subsection copy-file-into }
{ $subsection copy-files-into }
"Copying directory trees recursively:"
{ $subsection copy-tree }
{ $subsection copy-tree-into }
{ $subsection copy-trees-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"

View File

@ -1,6 +1,7 @@
USING: continuations destructors io io.directories
io.encodings.ascii io.encodings.utf8 io.files io.files.info
io.files.temp io.pathnames kernel sequences tools.test ;
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" } ] [

View File

@ -1,8 +1,8 @@
! 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.files.info io.files.links
io.pathnames kernel namespaces sequences system vocabs.loader ;
io.encodings.binary io.files io.pathnames kernel namespaces
sequences system vocabs.loader fry ;
IN: io.directories
: set-current-directory ( path -- )
@ -42,7 +42,7 @@ HOOK: (directory-entries) os ( path -- seq )
directory-entries [ name>> ] map ;
: with-directory-files ( path quot -- )
[ "" directory-files ] prepose with-directory ; inline
'[ "" directory-files @ ] with-directory ; inline
! Touching files
HOOK: touch-file io-backend ( path -- )
@ -52,13 +52,6 @@ HOOK: delete-file io-backend ( path -- )
HOOK: delete-directory io-backend ( path -- )
: delete-tree ( path -- )
dup link-info type>> +directory+ = [
[ [ [ delete-tree ] each ] with-directory-files ]
[ delete-directory ]
bi
] [ delete-file ] if ;
: to-directory ( from to -- from to' )
over file-name append-path ;
@ -69,7 +62,7 @@ HOOK: move-file io-backend ( from to -- )
to-directory move-file ;
: move-files-into ( files to -- )
[ move-file-into ] curry each ;
'[ _ move-file-into ] each ;
! Copying files
HOOK: copy-file io-backend ( from to -- )
@ -86,28 +79,7 @@ M: object copy-file
to-directory copy-file ;
: copy-files-into ( files to -- )
[ copy-file-into ] curry each ;
DEFER: copy-tree-into
: copy-tree ( from to -- )
normalize-path
over link-info type>>
{
{ +symbolic-link+ [ copy-link ] }
{ +directory+ [
swap [
[ swap copy-tree-into ] with 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 ] curry each ;
'[ _ copy-file-into ] each ;
{
{ [ os unix? ] [ "io.directories.unix" require ] }

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

@ -3,7 +3,7 @@
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.files.info io.pathnames kernel math.bitwise sequences system
io.pathnames io.files.types kernel math.bitwise sequences system
unix unix.stat ;
IN: io.directories.unix
@ -36,10 +36,7 @@ M: unix delete-directory ( path -- )
] with-disposal ;
M: unix copy-file ( from to -- )
[ normalize-path ] bi@
[ (copy-file) ]
[ swap file-info permissions>> chmod io-error ]
2bi ;
[ normalize-path ] bi@ (copy-file) ;
: with-unix-directory ( path quot -- )
[ opendir dup [ (io-error) ] unless ] dip

View File

@ -1,3 +1,4 @@
USING: help.markup help.syntax arrays io.files ;
IN: io.files.info
HELP: file-info
@ -11,30 +12,6 @@ HELP: link-info
{ file-info link-info } related-words
HELP: +regular-file+
{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ;
HELP: +directory+
{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ;
HELP: +symbolic-link+
{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ;
HELP: +character-device+
{ $description "A Unix character device file. This type exists on Unix platforms only." } ;
HELP: +block-device+
{ $description "A Unix block device file. This type exists on Unix platforms only." } ;
HELP: +fifo+
{ $description "A Unix fifo file. This type exists on Unix platforms only." } ;
HELP: +socket+
{ $description "A Unix socket file. This type exists on Unix platforms only." } ;
HELP: +unknown+
{ $description "A unknown file type." } ;
HELP: directory?
{ $values { "file-info" file-info } { "?" "a boolean" } }
{ $description "Tests if " { $snippet "file-info" } " is a directory." } ;
@ -49,18 +26,6 @@ HELP: file-system-info
{ "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: "file-types" "File types"
"Platform-independent types:"
{ $subsection +regular-file+ }
{ $subsection +directory+ }
"Platform-specific types:"
{ $subsection +character-device+ }
{ $subsection +block-device+ }
{ $subsection +fifo+ }
{ $subsection +symbolic-link+ }
{ $subsection +socket+ }
{ $subsection +unknown+ } ;
ARTICLE: "io.files.info" "File system meta-data"
"File meta-data:"
{ $subsection file-info }

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Doug Coleman, Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel system sequences combinators
vocabs.loader ;
vocabs.loader io.files.types ;
IN: io.files.info
! File info
@ -12,16 +12,6 @@ HOOK: file-info os ( path -- info )
HOOK: link-info os ( path -- info )
SYMBOL: +regular-file+
SYMBOL: +directory+
SYMBOL: +symbolic-link+
SYMBOL: +character-device+
SYMBOL: +block-device+
SYMBOL: +fifo+
SYMBOL: +socket+
SYMBOL: +whiteout+
SYMBOL: +unknown+
: directory? ( file-info -- ? ) type>> +directory+ = ;
! File systems

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: classes help.markup help.syntax io.streams.string
strings math calendar io.files ;
strings math calendar io.files.info io.files.info.unix ;
IN: io.files.unix
HELP: file-group-id
@ -268,10 +268,10 @@ ARTICLE: "unix-file-ids" "Unix file user and group ids"
{ $subsection set-file-group } ;
ARTICLE: "io.files.unix" "Unix file attributes"
"The " { $vocab-link "io.files.unix" } " vocabulary implements the Unix backend for opening files and provides a high-level way to set permissions, timestamps, and user and group ids for files."
ARTICLE: "io.files.info.unix" "Unix file attributes"
"The " { $vocab-link "io.files.info.unix" } " vocabulary implements a high-level way to set Unix-specific permissions, timestamps, and user and group IDs for files."
{ $subsection "unix-file-permissions" }
{ $subsection "unix-file-timestamps" }
{ $subsection "unix-file-ids" } ;
ABOUT: "io.files.unix"
ABOUT: "io.files.info.unix"

View File

@ -2,8 +2,9 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel system math math.bitwise strings arrays
sequences combinators combinators.short-circuit alien.c-types
vocabs.loader calendar calendar.unix io.files.info io.backend
unix unix.stat unix.time unix.users unix.groups ;
vocabs.loader calendar calendar.unix io.files.info
io.files.types io.backend unix unix.stat unix.time unix.users
unix.groups ;
IN: io.files.info.unix
TUPLE: unix-file-system-info < file-system-info

View File

@ -1,3 +1,4 @@
USING: help.markup help.syntax io.files.info ;
IN: io.files.links
HELP: make-link

View File

@ -0,0 +1,40 @@
USING: help.markup help.syntax ;
IN: io.files.types
HELP: +regular-file+
{ $description "A regular file. This type exists on all platforms. See " { $link "file-streams" } " for words operating on files." } ;
HELP: +directory+
{ $description "A directory. This type exists on all platforms. See " { $link "directories" } " for words operating on directories." } ;
HELP: +symbolic-link+
{ $description "A symbolic link file. This type is currently implemented on Unix platforms only. See " { $link "symbolic-links" } " for words operating on symbolic links." } ;
HELP: +character-device+
{ $description "A Unix character device file. This type exists on Unix platforms only." } ;
HELP: +block-device+
{ $description "A Unix block device file. This type exists on Unix platforms only." } ;
HELP: +fifo+
{ $description "A Unix fifo file. This type exists on Unix platforms only." } ;
HELP: +socket+
{ $description "A Unix socket file. This type exists on Unix platforms only." } ;
HELP: +unknown+
{ $description "A unknown file type." } ;
ARTICLE: "file-types" "File types"
"Platform-independent types:"
{ $subsection +regular-file+ }
{ $subsection +directory+ }
"Platform-specific types:"
{ $subsection +character-device+ }
{ $subsection +block-device+ }
{ $subsection +fifo+ }
{ $subsection +symbolic-link+ }
{ $subsection +socket+ }
{ $subsection +unknown+ } ;
ABOUT: "file-types"

View File

@ -0,0 +1,13 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: io.files.types
SYMBOL: +regular-file+
SYMBOL: +directory+
SYMBOL: +symbolic-link+
SYMBOL: +character-device+
SYMBOL: +block-device+
SYMBOL: +fifo+
SYMBOL: +socket+
SYMBOL: +whiteout+
SYMBOL: +unknown+

View File

@ -4,9 +4,11 @@ USING: namespaces make continuations.private kernel.private init
assocs kernel vocabs words sequences memory io system arrays
continuations math definitions mirrors splitting parser classes
summary layouts vocabs.loader prettyprint.config prettyprint
debugger io.streams.c io.files io.backend quotations io.launcher
words.private tools.deploy.config tools.deploy.config.editor
bootstrap.image io.encodings.utf8 destructors accessors ;
debugger io.streams.c io.files io.files.temp io.pathnames
io.directories io.directories.hierarchy io.backend quotations
io.launcher words.private tools.deploy.config
tools.deploy.config.editor bootstrap.image io.encodings.utf8
destructors accessors ;
IN: tools.deploy.backend
: copy-vm ( executable bundle-name extension -- vm )

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs io.files kernel parser prettyprint sequences
USING: assocs io.pathnames kernel parser prettyprint sequences
splitting tools.deploy.config tools.vocabs vocabs.loader ;
IN: tools.deploy.config.editor

View File

@ -1,7 +1,8 @@
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files kernel namespaces make sequences system
tools.deploy.backend tools.deploy.config
USING: io io.files io.files.info.unix io.pathnames
io.directories io.directories.hierarchy kernel namespaces make
sequences system tools.deploy.backend tools.deploy.config
tools.deploy.config.editor assocs hashtables prettyprint
io.backend.unix cocoa io.encodings.utf8 io.backend
cocoa.application cocoa.classes cocoa.plists qualified
@ -53,7 +54,8 @@ IN: tools.deploy.macosx
} cleave
]
[ create-app-plist ]
[ "Contents/MacOS/" append-path "" copy-vm ] 2tri ;
[ "Contents/MacOS/" append-path "" copy-vm ] 2tri
dup OCT: 755 set-file-permissions ;
: deploy.app-image ( vocab bundle-name -- str )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;

View File

@ -1,13 +1,15 @@
! Copyright (C) 2008 James Cash
! See http://factorcode.org/license.txt for BSD license.
USING: io io.files io.backend kernel namespaces make sequences
system tools.deploy.backend tools.deploy.config
tools.deploy.config.editor assocs hashtables prettyprint ;
USING: io io.files io.files.info.unix io.backend kernel
namespaces make sequences system tools.deploy.backend
tools.deploy.config tools.deploy.config.editor assocs hashtables
prettyprint ;
IN: tools.deploy.unix
: create-app-dir ( vocab bundle-name -- vm )
dup "" copy-fonts
"" copy-vm ;
"" copy-vm
dup OCT: 755 set-file-permissions ;
: bundle-name ( -- str )
deploy-name get ;

View File

@ -3,8 +3,8 @@
USING: accessors arrays assocs classes classes.builtin
classes.intersection classes.mixin classes.predicate
classes.singleton classes.tuple classes.union combinators
definitions effects fry generic help help.markup
help.stylesheet help.topics io io.files io.styles kernel macros
definitions effects fry generic help help.markup help.stylesheet
help.topics io io.files io.pathnames io.styles kernel macros
make namespaces prettyprint sequences sets sorting summary
tools.vocabs vocabs vocabs.loader words ;
IN: tools.vocabs.browser

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: threads io.files io.monitors init kernel
USING: threads io.files io.pathnames io.monitors init kernel
vocabs vocabs.loader tools.vocabs namespaces continuations
sequences splitting assocs command-line concurrency.messaging
io.backend sets tr ;

View File

@ -3,8 +3,8 @@
USING: continuations definitions ui.tools.browser
ui.tools.interactor ui.tools.listener ui.tools.profiler
ui.tools.search ui.tools.traceback ui.tools.workspace generic
help.topics stack-checker summary inspector io.files io.styles
kernel namespaces parser prettyprint quotations
help.topics stack-checker summary inspector io.pathnames
io.styles kernel namespaces parser prettyprint quotations
tools.annotations editors tools.profiler tools.test tools.time
tools.walker ui.commands ui.gadgets.editors ui.gestures
ui.operations ui.tools.deploy vocabs vocabs.loader words

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs help help.topics io.files io.styles
USING: accessors assocs help help.topics io.pathnames io.styles
kernel models models.delay models.filter namespaces prettyprint
quotations sequences sorting source-files definitions strings
tools.completion tools.crossref classes.tuple vocabs words

View File

@ -1,6 +1,6 @@
USING: assocs hashtables help.markup help.syntax
io.streams.string io.files kernel strings present math multiline
;
io.streams.string io.files io.pathnames kernel strings present
math multiline ;
IN: urls
HELP: url

View File

@ -1,4 +1,4 @@
USING: help.markup help.syntax vocabs.loader io.files strings
USING: help.markup help.syntax vocabs.loader io.pathnames strings
definitions quotations compiler.units ;
IN: source-files