directory changes
parent
83638c35da
commit
0e9ecc1ba9
|
@ -59,8 +59,8 @@ TUPLE: file-responder root hook special allow-listings ;
|
|||
|
||||
\ serve-file NOTICE add-input-logging
|
||||
|
||||
: file. ( name dirp -- )
|
||||
[ "/" append ] when
|
||||
: file. ( name -- )
|
||||
dup link-info directory? [ "/" append ] when
|
||||
dup <a =href a> escape-string write </a> ;
|
||||
|
||||
: directory. ( path -- )
|
||||
|
@ -68,7 +68,7 @@ TUPLE: file-responder root hook special allow-listings ;
|
|||
[ <h1> file-name escape-string write </h1> ]
|
||||
[
|
||||
<ul>
|
||||
directory sort-keys
|
||||
directory-files
|
||||
[ <li> file. </li> ] assoc-each
|
||||
</ul>
|
||||
] bi
|
||||
|
|
|
@ -19,11 +19,13 @@ DEFER: add-child-monitor
|
|||
|
||||
: add-child-monitors ( path -- )
|
||||
#! We yield since this directory scan might take a while.
|
||||
directory* [ first add-child-monitor ] each yield ;
|
||||
[
|
||||
[ add-child-monitor ] each yield
|
||||
] with-directory-files ;
|
||||
|
||||
: add-child-monitor ( path -- )
|
||||
notify? [ dup { +add-file+ } monitor tget queue-change ] when
|
||||
qualify-path dup link-info type>> +directory+ eq? [
|
||||
qualify-path dup link-info directory? [
|
||||
[ add-child-monitors ]
|
||||
[
|
||||
[
|
||||
|
|
|
@ -6,7 +6,7 @@ math.bitwise byte-arrays alien combinators calendar
|
|||
io.encodings.binary accessors sequences strings system
|
||||
io.files.private destructors vocabs.loader calendar.unix
|
||||
unix.stat alien.c-types arrays unix.users unix.groups
|
||||
environment ;
|
||||
environment fry io.encodings.utf8 alien.strings ;
|
||||
IN: io.unix.files
|
||||
|
||||
M: unix cwd ( -- path )
|
||||
|
@ -138,6 +138,27 @@ os {
|
|||
{ linux [ ] }
|
||||
} case
|
||||
|
||||
: with-unix-directory ( path quot -- )
|
||||
[ opendir dup [ (io-error) ] unless ] dip
|
||||
dupd curry swap '[ _ closedir io-error ] [ ] cleanup ; inline
|
||||
|
||||
: find-next-file ( DIR* -- byte-array )
|
||||
"dirent" <c-object>
|
||||
f <void*>
|
||||
[ readdir_r 0 = [ (io-error) ] unless ] 2keep
|
||||
*void* [ drop f ] unless ;
|
||||
|
||||
M: unix >directory-entry ( byte-array -- directory-entry )
|
||||
[ dirent-d_name utf8 alien>string ]
|
||||
[ dirent-d_type ] bi directory-entry boa ;
|
||||
|
||||
M: unix (directory-entries) ( path -- seq )
|
||||
[
|
||||
'[ _ find-next-file dup ]
|
||||
[ >directory-entry ]
|
||||
[ drop ] produce
|
||||
] with-unix-directory ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: stat-mode ( path -- mode )
|
||||
|
|
|
@ -81,6 +81,7 @@ FUNCTION: int chown ( char* path, uid_t owner, gid_t group ) ;
|
|||
FUNCTION: int chroot ( char* path ) ;
|
||||
|
||||
FUNCTION: int close ( int fd ) ;
|
||||
FUNCTION: int closedir ( DIR* dirp ) ;
|
||||
|
||||
: close-file ( fd -- ) [ close ] unix-system-call drop ;
|
||||
|
||||
|
@ -136,6 +137,8 @@ FUNCTION: int shutdown ( int fd, int how ) ;
|
|||
|
||||
FUNCTION: int open ( char* path, int flags, int prot ) ;
|
||||
|
||||
FUNCTION: DIR* opendir ( char* path ) ;
|
||||
|
||||
: open-file ( path flags mode -- fd ) [ open ] unix-system-call ;
|
||||
|
||||
C-STRUCT: utimbuf
|
||||
|
@ -157,6 +160,8 @@ FUNCTION: int pipe ( int* filedes ) ;
|
|||
FUNCTION: void* popen ( char* command, char* type ) ;
|
||||
FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ;
|
||||
|
||||
FUNCTION: int readdir_r ( DIR* dirp, dirent* entry, dirent** result ) ;
|
||||
|
||||
FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ;
|
||||
|
||||
: PATH_MAX 1024 ; inline
|
||||
|
|
|
@ -39,7 +39,7 @@ METHOD: expand { variable-expr } expr>> os-env ;
|
|||
METHOD: expand { glob-expr }
|
||||
expr>>
|
||||
dup "*" =
|
||||
[ drop current-directory get directory [ first ] map ]
|
||||
[ drop current-directory get directory-files ]
|
||||
[ ]
|
||||
if ;
|
||||
|
||||
|
|
|
@ -374,9 +374,9 @@ M: revision feed-entry-url id>> revision-url ;
|
|||
{ wiki "wiki-common" } >>template ;
|
||||
|
||||
: init-wiki ( -- )
|
||||
"resource:extra/webapps/wiki/initial-content" directory* keys
|
||||
"resource:extra/webapps/wiki/initial-content" [
|
||||
[
|
||||
dup file-name ".txt" ?tail [
|
||||
dup ".txt" ?tail [
|
||||
swap ascii file-contents
|
||||
f <revision>
|
||||
swap >>content
|
||||
|
@ -385,4 +385,5 @@ M: revision feed-entry-url id>> revision-url ;
|
|||
now >>date
|
||||
add-revision
|
||||
] [ 2drop ] if
|
||||
] each ;
|
||||
] each
|
||||
] with-directory-files ;
|
||||
|
|
Loading…
Reference in New Issue