io.files.info: use directory?, symbolic-link?, and regular-file?.
parent
136d793c6e
commit
2a3427bdff
|
@ -72,7 +72,7 @@ C: <ftp-disconnect> ftp-disconnect
|
|||
: can-serve-file? ( path -- ? )
|
||||
{
|
||||
[ exists? ]
|
||||
[ file-info type>> +regular-file+ = ]
|
||||
[ file-info regular-file? ]
|
||||
[ serving? ]
|
||||
} 1&& ;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ IN: io.directories.hierarchy
|
|||
: directory-tree-files% ( path prefix -- )
|
||||
[ dup directory-entries ] dip '[
|
||||
[ name>> [ append-path ] [ _ prepend-path ] bi ]
|
||||
[ type>> +directory+ = ] bi over ,
|
||||
[ directory? ] bi over ,
|
||||
[ directory-tree-files% ] [ 2drop ] if
|
||||
] with each ;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ ERROR: too-many-symlinks path n ;
|
|||
|
||||
: (follow-links) ( n path -- path' )
|
||||
over 0 = [ symlink-depth get too-many-symlinks ] when
|
||||
dup link-info type>> +symbolic-link+ =
|
||||
dup link-info symbolic-link?
|
||||
[ [ 1 - ] [ follow-link ] bi* (follow-links) ]
|
||||
[ nip ] if ; inline recursive
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays assocs colors.constants combinators
|
||||
combinators.short-circuit fry io.directories io.files
|
||||
io.files.info io.pathnames kernel locals make math math.order
|
||||
sequences sequences.private sorting splitting typed
|
||||
io.files.info io.files.types io.pathnames kernel locals make
|
||||
math math.order sequences sequences.private sorting splitting
|
||||
unicode.categories unicode.data vectors vocabs vocabs.hierarchy
|
||||
;
|
||||
|
||||
IN: tools.completion
|
||||
|
||||
<PRIVATE
|
||||
|
@ -115,11 +114,11 @@ PRIVATE>
|
|||
: directory-paths ( directory -- alist )
|
||||
dup '[
|
||||
[
|
||||
[ dup _ prepend-path ]
|
||||
[ file-info directory? [ path-separator append ] when ]
|
||||
[ name>> dup _ prepend-path ]
|
||||
[ directory? [ path-separator append ] when ]
|
||||
bi swap
|
||||
] { } map>assoc
|
||||
] with-directory-files ;
|
||||
] with-directory-entries ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2007, 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays assocs combinators.short-circuit fry
|
||||
io.directories io.files io.files.types io.pathnames kernel make
|
||||
io.directories io.files io.files.info io.pathnames kernel make
|
||||
memoize namespaces sequences sets sorting splitting vocabs
|
||||
vocabs.loader vocabs.metadata ;
|
||||
IN: vocabs.hierarchy
|
||||
|
@ -17,7 +17,7 @@ M: vocab-prefix vocab-name name>> ;
|
|||
: visible-dirs ( seq -- seq' )
|
||||
[
|
||||
{
|
||||
[ type>> +directory+ = ]
|
||||
[ directory? ]
|
||||
[ name>> "." head? not ]
|
||||
} 1&&
|
||||
] filter ;
|
||||
|
|
|
@ -45,7 +45,7 @@ TUPLE: code-file
|
|||
: include-file-name? ( name -- ? )
|
||||
{
|
||||
[ path-components [ "." head? ] any? not ]
|
||||
[ link-info type>> +regular-file+ = ]
|
||||
[ link-info regular-file? ]
|
||||
} 1&& ;
|
||||
|
||||
: code-files ( dir -- files )
|
||||
|
|
|
@ -27,7 +27,7 @@ IN: io.files.trash.unix
|
|||
{
|
||||
[ file-info directory? ]
|
||||
[ sticky? ]
|
||||
[ link-info type>> +symbolic-link+ = not ]
|
||||
[ link-info symbolic-link? not ]
|
||||
} 1&& [ "invalid trash path" throw ] unless ;
|
||||
|
||||
: trash-home ( -- path )
|
||||
|
|
|
@ -30,8 +30,7 @@ DEFER: write-tree
|
|||
] 2bi #directories [ 1 + ] change-global ;
|
||||
|
||||
: write-entry ( entry indents -- )
|
||||
nl over type>> +directory+ =
|
||||
[ write-dir ] [ write-file ] if ;
|
||||
nl over directory? [ write-dir ] [ write-file ] if ;
|
||||
|
||||
:: write-tree ( path indents -- )
|
||||
path [
|
||||
|
|
Loading…
Reference in New Issue