--- /dev/null
+unportable
-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"
! 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
! 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
! 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 ;
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 )
-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
! 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
+USING: help.markup help.syntax io.files.private io.pathnames
+quotations ;
IN: io.directories
HELP: cwd
{ $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." }
{ $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 }
"Deleting files:"
{ $subsection delete-file }
{ $subsection delete-directory }
-{ $subsection delete-tree }
"Moving files:"
{ $subsection move-file }
{ $subsection move-file-into }
{ $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"
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" } ] [
! 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 -- )
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 -- )
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 ;
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 -- )
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 ] }
--- /dev/null
+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"
--- /dev/null
+! 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 ;
+
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
] 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
+USING: help.markup help.syntax arrays io.files ;
IN: io.files.info
HELP: file-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." } ;
{ "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 }
! 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
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
--- /dev/null
+! 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.info io.files.info.unix ;
+IN: io.files.unix
+
+HELP: file-group-id
+{ $values
+ { "path" "a pathname string" }
+ { "gid" integer } }
+{ $description "Returns the group id for a given file." } ;
+
+HELP: file-group-name
+{ $values
+ { "path" "a pathname string" }
+ { "string" string } }
+{ $description "Returns the group name for a given file." } ;
+
+HELP: file-permissions
+{ $values
+ { "path" "a pathname string" }
+ { "n" integer } }
+{ $description "Returns the Unix file permissions for a given file." } ;
+
+HELP: file-username
+{ $values
+ { "path" "a pathname string" }
+ { "string" string } }
+{ $description "Returns the username for a given file." } ;
+
+HELP: file-user-id
+{ $values
+ { "path" "a pathname string" }
+ { "uid" integer } }
+{ $description "Returns the user id for a given file." } ;
+
+HELP: group-execute?
+{ $values
+ { "obj" "a pathname string or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "group execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: group-read?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "group read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: group-write?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "group write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: other-execute?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "other execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: other-read?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "other read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: other-write?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "other write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: set-file-access-time
+{ $values
+ { "path" "a pathname string" } { "timestamp" timestamp } }
+{ $description "Sets a file's last access timestamp." } ;
+
+HELP: set-file-group
+{ $values
+ { "path" "a pathname string" } { "string/id" "a string or a group id" } }
+{ $description "Sets a file's group id from the given group id or group name." } ;
+
+HELP: set-file-ids
+{ $values
+ { "path" "a pathname string" } { "uid" integer } { "gid" integer } }
+{ $description "Sets the user id and group id of a file with a single library call." } ;
+
+HELP: set-file-permissions
+{ $values
+ { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
+{ $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
+{ $examples "Using the tradidional octal value:"
+ { $unchecked-example "USING: io.files.unix kernel ;"
+ "\"resource:license.txt\" OCT: 755 set-file-permissions"
+ ""
+ }
+ "Higher-level, setting named bits:"
+ { $unchecked-example "USING: io.files.unix kernel math.bitwise ;"
+ "\"resource:license.txt\""
+ "{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
+ "flags set-file-permissions"
+ "" }
+} ;
+
+HELP: set-file-times
+{ $values
+ { "path" "a pathname string" } { "timestamps" "an array of two timestamps" } }
+{ $description "Sets the access and write timestamps for a file as provided in the input array. A value of " { $link f } " provided for either of the timestamps will not change that timestamp." } ;
+
+HELP: set-file-user
+{ $values
+ { "path" "a pathname string" } { "string/id" "a string or a user id" } }
+{ $description "Sets a file's user id from the given user id or username." } ;
+
+HELP: set-file-modified-time
+{ $values
+ { "path" "a pathname string" } { "timestamp" timestamp } }
+{ $description "Sets a file's last modified timestamp, or write timestamp." } ;
+
+HELP: set-gid
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "gid" } " bit of a file to true or false." } ;
+
+HELP: gid?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "gid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: set-group-execute
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "group execute" } " bit of a file to true or false." } ;
+
+HELP: set-group-read
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "group read" } " bit of a file to true or false." } ;
+
+HELP: set-group-write
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "group write" } " bit of a file to true or false." } ;
+
+HELP: set-other-execute
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
+
+HELP: set-other-read
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "other read" } " bit of a file to true or false." } ;
+
+HELP: set-other-write
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
+
+HELP: set-sticky
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "sticky" } " bit of a file to true or false." } ;
+
+HELP: sticky?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "sticky" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: set-uid
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "uid" } " bit of a file to true or false." } ;
+
+HELP: uid?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "uid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: set-user-execute
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "user execute" } " bit of a file to true or false." } ;
+
+HELP: set-user-read
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "user read" } " bit of a file to true or false." } ;
+
+HELP: set-user-write
+{ $values
+ { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Sets the " { $snippet "user write" } " bit of a file to true or false." } ;
+
+HELP: user-execute?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "user execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: user-read?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "user read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+HELP: user-write?
+{ $values
+ { "obj" "a pathname string, file-info object, or an integer" }
+ { "?" "a boolean" } }
+{ $description "Tests whether the " { $snippet "user write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
+
+ARTICLE: "unix-file-permissions" "Unix file permissions"
+"Reading all file permissions:"
+{ $subsection file-permissions }
+"Reading individual file permissions:"
+{ $subsection uid? }
+{ $subsection gid? }
+{ $subsection sticky? }
+{ $subsection user-read? }
+{ $subsection user-write? }
+{ $subsection user-execute? }
+{ $subsection group-read? }
+{ $subsection group-write? }
+{ $subsection group-execute? }
+{ $subsection other-read? }
+{ $subsection other-write? }
+{ $subsection other-execute? }
+"Writing all file permissions:"
+{ $subsection set-file-permissions }
+"Writing individual file permissions:"
+{ $subsection set-uid }
+{ $subsection set-gid }
+{ $subsection set-sticky }
+{ $subsection set-user-read }
+{ $subsection set-user-write }
+{ $subsection set-user-execute }
+{ $subsection set-group-read }
+{ $subsection set-group-write }
+{ $subsection set-group-execute }
+{ $subsection set-other-read }
+{ $subsection set-other-write }
+{ $subsection set-other-execute } ;
+
+ARTICLE: "unix-file-timestamps" "Unix file timestamps"
+"To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
+"Setting multiple file times:"
+{ $subsection set-file-times }
+"Setting just the last access time:"
+{ $subsection set-file-access-time }
+"Setting just the last modified time:"
+{ $subsection set-file-modified-time } ;
+
+
+ARTICLE: "unix-file-ids" "Unix file user and group ids"
+"Reading file user data:"
+{ $subsection file-user-id }
+{ $subsection file-username }
+"Setting file user data:"
+{ $subsection set-file-user }
+"Reading file group data:"
+{ $subsection file-group-id }
+{ $subsection file-group-name }
+"Setting file group data:"
+{ $subsection set-file-group } ;
+
+
+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.info.unix"
! 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
+USING: help.markup help.syntax io.files.info ;
IN: io.files.links
HELP: make-link
--- /dev/null
+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"
--- /dev/null
+! 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+
+++ /dev/null
-! 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 ;
-IN: io.files.unix
-
-HELP: file-group-id
-{ $values
- { "path" "a pathname string" }
- { "gid" integer } }
-{ $description "Returns the group id for a given file." } ;
-
-HELP: file-group-name
-{ $values
- { "path" "a pathname string" }
- { "string" string } }
-{ $description "Returns the group name for a given file." } ;
-
-HELP: file-permissions
-{ $values
- { "path" "a pathname string" }
- { "n" integer } }
-{ $description "Returns the Unix file permissions for a given file." } ;
-
-HELP: file-username
-{ $values
- { "path" "a pathname string" }
- { "string" string } }
-{ $description "Returns the username for a given file." } ;
-
-HELP: file-user-id
-{ $values
- { "path" "a pathname string" }
- { "uid" integer } }
-{ $description "Returns the user id for a given file." } ;
-
-HELP: group-execute?
-{ $values
- { "obj" "a pathname string or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "group execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: group-read?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "group read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: group-write?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "group write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: other-execute?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "other execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: other-read?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "other read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: other-write?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "other write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: set-file-access-time
-{ $values
- { "path" "a pathname string" } { "timestamp" timestamp } }
-{ $description "Sets a file's last access timestamp." } ;
-
-HELP: set-file-group
-{ $values
- { "path" "a pathname string" } { "string/id" "a string or a group id" } }
-{ $description "Sets a file's group id from the given group id or group name." } ;
-
-HELP: set-file-ids
-{ $values
- { "path" "a pathname string" } { "uid" integer } { "gid" integer } }
-{ $description "Sets the user id and group id of a file with a single library call." } ;
-
-HELP: set-file-permissions
-{ $values
- { "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
-{ $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
-{ $examples "Using the tradidional octal value:"
- { $unchecked-example "USING: io.files.unix kernel ;"
- "\"resource:license.txt\" OCT: 755 set-file-permissions"
- ""
- }
- "Higher-level, setting named bits:"
- { $unchecked-example "USING: io.files.unix kernel math.bitwise ;"
- "\"resource:license.txt\""
- "{ USER-ALL GROUP-READ GROUP-EXECUTE OTHER-READ OTHER-EXECUTE }"
- "flags set-file-permissions"
- "" }
-} ;
-
-HELP: set-file-times
-{ $values
- { "path" "a pathname string" } { "timestamps" "an array of two timestamps" } }
-{ $description "Sets the access and write timestamps for a file as provided in the input array. A value of " { $link f } " provided for either of the timestamps will not change that timestamp." } ;
-
-HELP: set-file-user
-{ $values
- { "path" "a pathname string" } { "string/id" "a string or a user id" } }
-{ $description "Sets a file's user id from the given user id or username." } ;
-
-HELP: set-file-modified-time
-{ $values
- { "path" "a pathname string" } { "timestamp" timestamp } }
-{ $description "Sets a file's last modified timestamp, or write timestamp." } ;
-
-HELP: set-gid
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "gid" } " bit of a file to true or false." } ;
-
-HELP: gid?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "gid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: set-group-execute
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "group execute" } " bit of a file to true or false." } ;
-
-HELP: set-group-read
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "group read" } " bit of a file to true or false." } ;
-
-HELP: set-group-write
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "group write" } " bit of a file to true or false." } ;
-
-HELP: set-other-execute
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
-
-HELP: set-other-read
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "other read" } " bit of a file to true or false." } ;
-
-HELP: set-other-write
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "other execute" } " bit of a file to true or false." } ;
-
-HELP: set-sticky
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "sticky" } " bit of a file to true or false." } ;
-
-HELP: sticky?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "sticky" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: set-uid
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "uid" } " bit of a file to true or false." } ;
-
-HELP: uid?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "uid" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: set-user-execute
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "user execute" } " bit of a file to true or false." } ;
-
-HELP: set-user-read
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "user read" } " bit of a file to true or false." } ;
-
-HELP: set-user-write
-{ $values
- { "path" "a pathname string" } { "?" "a boolean" } }
-{ $description "Sets the " { $snippet "user write" } " bit of a file to true or false." } ;
-
-HELP: user-execute?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "user execute" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: user-read?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "user read" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-HELP: user-write?
-{ $values
- { "obj" "a pathname string, file-info object, or an integer" }
- { "?" "a boolean" } }
-{ $description "Tests whether the " { $snippet "user write" } " bit is set on a file, " { $link file-info } ", or an integer." } ;
-
-ARTICLE: "unix-file-permissions" "Unix file permissions"
-"Reading all file permissions:"
-{ $subsection file-permissions }
-"Reading individual file permissions:"
-{ $subsection uid? }
-{ $subsection gid? }
-{ $subsection sticky? }
-{ $subsection user-read? }
-{ $subsection user-write? }
-{ $subsection user-execute? }
-{ $subsection group-read? }
-{ $subsection group-write? }
-{ $subsection group-execute? }
-{ $subsection other-read? }
-{ $subsection other-write? }
-{ $subsection other-execute? }
-"Writing all file permissions:"
-{ $subsection set-file-permissions }
-"Writing individual file permissions:"
-{ $subsection set-uid }
-{ $subsection set-gid }
-{ $subsection set-sticky }
-{ $subsection set-user-read }
-{ $subsection set-user-write }
-{ $subsection set-user-execute }
-{ $subsection set-group-read }
-{ $subsection set-group-write }
-{ $subsection set-group-execute }
-{ $subsection set-other-read }
-{ $subsection set-other-write }
-{ $subsection set-other-execute } ;
-
-ARTICLE: "unix-file-timestamps" "Unix file timestamps"
-"To read file times, use the accessors on the object returned by the " { $link file-info } " word." $nl
-"Setting multiple file times:"
-{ $subsection set-file-times }
-"Setting just the last access time:"
-{ $subsection set-file-access-time }
-"Setting just the last modified time:"
-{ $subsection set-file-modified-time } ;
-
-
-ARTICLE: "unix-file-ids" "Unix file user and group ids"
-"Reading file user data:"
-{ $subsection file-user-id }
-{ $subsection file-username }
-"Setting file user data:"
-{ $subsection set-file-user }
-"Reading file group data:"
-{ $subsection file-group-id }
-{ $subsection file-group-name }
-"Setting file group data:"
-{ $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."
-{ $subsection "unix-file-permissions" }
-{ $subsection "unix-file-timestamps" }
-{ $subsection "unix-file-ids" } ;
-
-ABOUT: "io.files.unix"
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 )
! 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
! 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
} 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 ;
! 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 ;
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
! Copyright (C) 2008 Slava Pestov.\r
! See http://factorcode.org/license.txt for BSD license.\r
-USING: threads io.files io.monitors init kernel\r
+USING: threads io.files io.pathnames io.monitors init kernel\r
vocabs vocabs.loader tools.vocabs namespaces continuations\r
sequences splitting assocs command-line concurrency.messaging\r
io.backend sets tr ;\r
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
! 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
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
-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