io.files.info: use directory?, symbolic-link?, and regular-file?.

db4
John Benediktsson 2015-08-05 18:33:35 -07:00
parent 136d793c6e
commit 2a3427bdff
8 changed files with 13 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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