Merge branch 'master' of git://factorcode.org/git/factor
commit
7b6c8ee5f6
|
@ -1,16 +1,16 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays continuations deques dlists fry
|
USING: accessors arrays assocs continuations deques dlists fry
|
||||||
io.directories io.files io.files.info io.pathnames kernel
|
io.backend io.directories io.files.info io.pathnames kernel
|
||||||
sequences system vocabs.loader locals math namespaces
|
locals math sequences sorting system unicode.case vocabs.loader ;
|
||||||
sorting assocs calendar threads io math.parser unicode.case ;
|
|
||||||
IN: io.directories.search
|
IN: io.directories.search
|
||||||
|
|
||||||
: qualified-directory-entries ( path -- seq )
|
: qualified-directory-entries ( path -- seq )
|
||||||
dup directory-entries
|
normalize-path
|
||||||
[ [ append-path ] change-name ] with map ;
|
dup directory-entries [ [ append-path ] change-name ] with map ;
|
||||||
|
|
||||||
: qualified-directory-files ( path -- seq )
|
: qualified-directory-files ( path -- seq )
|
||||||
|
normalize-path
|
||||||
dup directory-files [ append-path ] with map ;
|
dup directory-files [ append-path ] with map ;
|
||||||
|
|
||||||
: with-qualified-directory-files ( path quot -- )
|
: with-qualified-directory-files ( path quot -- )
|
||||||
|
|
|
@ -54,6 +54,13 @@ HELP: with-unique-directory
|
||||||
}
|
}
|
||||||
{ $description "Creates a directory with " { $link unique-directory } " and calls the quotation with the pathname on the stack using the " { $link with-temporary-directory } " combinator. The quotation can access the " { $link current-temporary-directory } " symbol for the name of the temporary directory. Subsequent unique files will be created in this unique directory until the combinator returns." } ;
|
{ $description "Creates a directory with " { $link unique-directory } " and calls the quotation with the pathname on the stack using the " { $link with-temporary-directory } " combinator. The quotation can access the " { $link current-temporary-directory } " symbol for the name of the temporary directory. Subsequent unique files will be created in this unique directory until the combinator returns." } ;
|
||||||
|
|
||||||
|
HELP: move-file-unique
|
||||||
|
{ $values
|
||||||
|
{ "path" "a pathname string" } { "directory" "a directory" }
|
||||||
|
{ "path'" "a pathname string" }
|
||||||
|
}
|
||||||
|
{ $description "Moves " { $snippet "path" } " to " { $snippet "directory" } " by creating a unique file in this directory. Returns the new path." } ;
|
||||||
|
|
||||||
HELP: current-temporary-directory
|
HELP: current-temporary-directory
|
||||||
{ $values
|
{ $values
|
||||||
{ "value" "a path" }
|
{ "value" "a path" }
|
||||||
|
@ -90,6 +97,8 @@ ARTICLE: "io.files.unique" "Unique files"
|
||||||
cleanup-unique-directory
|
cleanup-unique-directory
|
||||||
}
|
}
|
||||||
"Default temporary directory:"
|
"Default temporary directory:"
|
||||||
{ $subsections default-temporary-directory } ;
|
{ $subsections default-temporary-directory }
|
||||||
|
"Moving files into a directory safely:"
|
||||||
|
{ $subsections move-file-unique } ;
|
||||||
|
|
||||||
ABOUT: "io.files.unique"
|
ABOUT: "io.files.unique"
|
||||||
|
|
|
@ -70,6 +70,11 @@ PRIVATE>
|
||||||
: unique-file ( prefix -- path )
|
: unique-file ( prefix -- path )
|
||||||
"" make-unique-file ;
|
"" make-unique-file ;
|
||||||
|
|
||||||
|
: move-file-unique ( path directory -- path' )
|
||||||
|
[
|
||||||
|
"" unique-file [ move-file ] keep
|
||||||
|
] with-temporary-directory ;
|
||||||
|
|
||||||
{
|
{
|
||||||
{ [ os unix? ] [ "io.files.unique.unix" ] }
|
{ [ os unix? ] [ "io.files.unique.unix" ] }
|
||||||
{ [ os windows? ] [ "io.files.unique.windows" ] }
|
{ [ os windows? ] [ "io.files.unique.windows" ] }
|
||||||
|
|
Loading…
Reference in New Issue