update docs pl0x

db4
Doug Coleman 2008-04-03 21:39:52 -05:00
parent 653bc1cd80
commit e22a7a6100
2 changed files with 115 additions and 48 deletions

View File

@ -11,7 +11,9 @@ ARTICLE: "file-streams" "Reading and writing files"
{ $subsection with-file-reader } { $subsection with-file-reader }
{ $subsection with-file-writer } { $subsection with-file-writer }
{ $subsection with-file-appender } { $subsection with-file-appender }
{ $subsection set-file-contents }
{ $subsection file-contents } { $subsection file-contents }
{ $subsection set-file-lines }
{ $subsection file-lines } ; { $subsection file-lines } ;
ARTICLE: "pathnames" "Pathname manipulation" ARTICLE: "pathnames" "Pathname manipulation"
@ -27,15 +29,22 @@ ARTICLE: "pathnames" "Pathname manipulation"
{ $subsection pathname } { $subsection pathname }
{ $subsection <pathname> } ; { $subsection <pathname> } ;
ARTICLE: "symbolic-links" "Symbolic links"
"Reading and creating links:"
{ $subsection read-link }
{ $subsection make-link }
"Copying links:"
{ $subsection copy-link }
"Not all operating systems support symbolic links."
{ $see-also link-info } ;
ARTICLE: "directories" "Directories" ARTICLE: "directories" "Directories"
"Current directory:" "Current directory:"
{ $subsection with-directory }
{ $subsection current-directory } { $subsection current-directory }
{ $subsection set-current-directory }
{ $subsection with-directory }
"Home directory:" "Home directory:"
{ $subsection home } { $subsection home }
"Current system directory:"
{ $subsection cwd }
{ $subsection cd }
"Directory listing:" "Directory listing:"
{ $subsection directory } { $subsection directory }
{ $subsection directory* } { $subsection directory* }
@ -43,18 +52,26 @@ ARTICLE: "directories" "Directories"
{ $subsection make-directory } { $subsection make-directory }
{ $subsection make-directories } ; { $subsection make-directories } ;
! ARTICLE: "file-types" "File Types" ARTICLE: "file-types" "File Types"
"Platform-independent types:"
! { $table { +directory+ "" } } { $subsection +regular-file+ }
{ $subsection +directory+ }
! ; "Platform-specific types:"
{ $subsection +character-device+ }
ARTICLE: "fs-meta" "File meta-data" { $subsection +block-device+ }
{ $subsection +fifo+ }
{ $subsection +symbolic-link+ }
{ $subsection +socket+ }
{ $subsection +unknown+ } ;
ARTICLE: "fs-meta" "File metadata"
"Querying file-system metadata:"
{ $subsection file-info } { $subsection file-info }
{ $subsection link-info } { $subsection link-info }
{ $subsection exists? } { $subsection exists? }
{ $subsection directory? } ; { $subsection directory? }
"File types:"
{ $subsection "file-types" } ;
ARTICLE: "delete-move-copy" "Deleting, moving, copying files" ARTICLE: "delete-move-copy" "Deleting, moving, copying files"
"Operations for deleting and copying files come in two forms:" "Operations for deleting and copying files come in two forms:"
@ -123,39 +140,40 @@ HELP: file-name
! need a $class-description file-info ! need a $class-description file-info
HELP: file-info HELP: file-info
{ $values { "path" "a pathname string" } { "info" file-info } }
{ $values { "path" "a pathname string" } { $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." }
{ "info" file-info } } { $errors "Throws an error if the file does not exist." } ;
{ $description "Queries the file system for meta data. "
"If path refers to a symbolic link, it is followed."
"If the file does not exist, an exception is thrown." }
{ $class-description "File meta data" }
{ $table
{ "type" { "One of the following:"
{ $list { $link +regular-file+ }
{ $link +directory+ }
{ $link +symbolic-link+ } } } }
{ "size" "Size of the file in bytes" }
{ "modified" "Last modification timestamp." } }
;
! need a see also to link-info
HELP: link-info HELP: link-info
{ $values { "path" "a pathname string" } { $values { "path" "a pathname string" } { "info" "a file-info tuple" } }
{ "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." } ;
{ $description "Queries the file system for meta data. "
"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." } ;
! need a see also to file-info
{ file-info link-info } related-words { 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: <file-reader> HELP: <file-reader>
{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" { "stream" "an input stream" } } { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" { "stream" "an input stream" } }
{ "stream" "an input stream" } } { "stream" "an input stream" } }
@ -187,29 +205,44 @@ HELP: with-file-appender
{ $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-stream } "." } { $description "Opens a file for appending using the given encoding and calls the quotation using " { $link with-stream } "." }
{ $errors "Throws an error if the file cannot be opened for writing." } ; { $errors "Throws an error if the file cannot be opened for writing." } ;
HELP: set-file-lines
{ $values { "seq" "an array of strings" } { "path" "a pathname string" } { "encoding" "an encoding descriptor" } }
{ $description "Sets the contents of a file to the strings with the given encoding." }
{ $errors "Throws an error if the file cannot be opened for writing." } ;
HELP: file-lines HELP: file-lines
{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "seq" "an array of strings" } } { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "seq" "an array of strings" } }
{ $description "Opens the file at the given path using the given encoding, and returns a list of the lines in that file." } { $description "Opens the file at the given path using the given encoding, and returns a list of the lines in that file." }
{ $errors "Throws an error if the file cannot be opened for reading." } ;
HELP: set-file-contents
{ $values { "str" "a string" } { "path" "a pathname string" } { "encoding" "an encoding descriptor" } }
{ $description "Sets the contents of a file to a string with the given encoding." }
{ $errors "Throws an error if the file cannot be opened for writing." } ; { $errors "Throws an error if the file cannot be opened for writing." } ;
HELP: file-contents HELP: file-contents
{ $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "str" "a string" } } { $values { "path" "a pathname string" } { "encoding" "an encoding descriptor" } { "str" "a string" } }
{ $description "Opens the file at the given path using the given encoding, and the contents of that file as a string." } { $description "Opens the file at the given path using the given encoding, and the contents of that file as a string." }
{ $errors "Throws an error if the file cannot be opened for writing." } ; { $errors "Throws an error if the file cannot be opened for reading." } ;
{ set-file-lines file-lines set-file-contents file-contents } related-words
HELP: cwd HELP: cwd
{ $values { "path" "a pathname string" } } { $values { "path" "a pathname string" } }
{ $description "Outputs the current working directory of the Factor process." } { $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." } { $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." }
{ $warning "Modifying the current directory through system calls is unsafe. Use the " { $link with-directory } " word instead." } ; { $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
HELP: cd HELP: cd
{ $values { "path" "a pathname string" } } { $values { "path" "a pathname string" } }
{ $description "Changes the current working directory of the Factor process." } { $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." } { $errors "Windows CE has no concept of ``current directory'', so this word throws an error there." }
{ $warning "Modifying the current directory through system calls is unsafe. Use the " { $link with-directory } " word instead." } ; { $notes "User code should use " { $link with-directory } " or " { $link set-current-directory } " instead." } ;
{ cd cwd current-directory with-directory } related-words { cd cwd current-directory set-current-directory with-directory } related-words
HELP: current-directory
{ $description "A variable holding the current directory. Words that use the filesystem do so in relation to this variable. On startup, an init hook sets this word to the directory from which Factor was run." } ;
HELP: with-directory HELP: with-directory
{ $values { "path" "a pathname string" } { "quot" quotation } } { $values { "path" "a pathname string" } { "quot" quotation } }
@ -219,6 +252,26 @@ HELP: append-path
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } } { $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
{ $description "Concatenates two pathnames." } ; { $description "Concatenates two pathnames." } ;
HELP: prepend-path
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
{ $description "Concatenates two pathnames." } ;
{ append-path prepend-path } related-words
HELP: absolute-path?
{ $values { "path" "a pathname string" } { "?" "a boolean" } }
{ $description "Tests if a pathname is absolute. Examples of absolute pathnames are " { $snippet "/foo/bar" } " on Unix and " { $snippet "c:\\foo\\bar" } " on Windows." } ;
HELP: windows-absolute-path?
{ $values { "path" "a pathname string" } { "?" "a boolean" } }
{ $description "Tests if a pathname is absolute on Windows. Examples of absolute pathnames on Windows are " { $snippet "c:\\foo\\bar" } " and " { $snippet "\\\\?\\c:\\foo\\bar" } " for absolute Unicode pathnames." } ;
HELP: root-directory?
{ $values { "path" "a pathname string" } { "?" "a boolean" } }
{ $description "Tests if a pathname is a root directory. Examples of root directory pathnames are " { $snippet "/" } " on Unix and " { $snippet "c:\\" } " on Windows." } ;
{ absolute-path? windows-absolute-path? root-directory? } related-words
HELP: exists? HELP: exists?
{ $values { "path" "a pathname string" } { "?" "a boolean" } } { $values { "path" "a pathname string" } { "?" "a boolean" } }
{ $description "Tests if the file named by " { $snippet "path" } " exists." } ; { $description "Tests if the file named by " { $snippet "path" } " exists." } ;
@ -264,6 +317,20 @@ HELP: <pathname> ( str -- pathname )
{ $values { "str" "a pathname string" } { "pathname" pathname } } { $values { "str" "a pathname string" } { "pathname" pathname } }
{ $description "Creates a new " { $link pathname } "." } ; { $description "Creates a new " { $link pathname } "." } ;
HELP: make-link
{ $values { "target" "a path to the symbolic link's target" } { "symlink" "a path to new symbolic link" } }
{ $description "Creates a symbolic link." } ;
HELP: read-link
{ $values { "symlink" "a path to an existing symbolic link" } { "path" "the path pointed to by the symbolic link" } }
{ $description "Reads the symbolic link and returns its target path." } ;
HELP: copy-link
{ $values { "target" "a path to an existing symlink" } { "symlink" "a path to a new symbolic link" } }
{ $description "Copies a symbolic link without following the link." } ;
{ make-link read-link copy-link } related-words
HELP: home HELP: home
{ $values { "dir" string } } { $values { "dir" string } }
{ $description "Outputs the user's home directory." } ; { $description "Outputs the user's home directory." } ;

View File

@ -153,19 +153,19 @@ HOOK: file-info io-backend ( path -- info )
! Symlinks ! Symlinks
HOOK: link-info io-backend ( path -- info ) HOOK: link-info io-backend ( path -- info )
HOOK: make-link io-backend ( path1 path2 -- ) HOOK: make-link io-backend ( target symlink -- )
HOOK: read-link io-backend ( path -- info ) HOOK: read-link io-backend ( symlink -- path )
: copy-link ( path1 path2 -- ) : copy-link ( target symlink -- )
>r read-link r> make-link ; >r read-link r> make-link ;
SYMBOL: +regular-file+ SYMBOL: +regular-file+
SYMBOL: +directory+ SYMBOL: +directory+
SYMBOL: +symbolic-link+
SYMBOL: +character-device+ SYMBOL: +character-device+
SYMBOL: +block-device+ SYMBOL: +block-device+
SYMBOL: +fifo+ SYMBOL: +fifo+
SYMBOL: +symbolic-link+
SYMBOL: +socket+ SYMBOL: +socket+
SYMBOL: +unknown+ SYMBOL: +unknown+