: can-serve-file? ( path -- ? )
{
[ exists? ]
- [ file-info type>> +regular-file+ = ]
+ [ file-info regular-file? ]
[ serving? ]
} 1&& ;
: 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 ;
: (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
! 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
: 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>
! 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
: visible-dirs ( seq -- seq' )
[
{
- [ type>> +directory+ = ]
+ [ directory? ]
[ name>> "." head? not ]
} 1&&
] filter ;
: include-file-name? ( name -- ? )
{
[ path-components [ "." head? ] any? not ]
- [ link-info type>> +regular-file+ = ]
+ [ link-info regular-file? ]
} 1&& ;
: code-files ( dir -- files )
{
[ file-info directory? ]
[ sticky? ]
- [ link-info type>> +symbolic-link+ = not ]
+ [ link-info symbolic-link? not ]
} 1&& [ "invalid trash path" throw ] unless ;
: trash-home ( -- path )
] 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 [