directory changes
							parent
							
								
									83638c35da
								
							
						
					
					
						commit
						0e9ecc1ba9
					
				| 
						 | 
					@ -59,8 +59,8 @@ TUPLE: file-responder root hook special allow-listings ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\ serve-file NOTICE add-input-logging
 | 
					\ serve-file NOTICE add-input-logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: file. ( name dirp -- )
 | 
					: file. ( name -- )
 | 
				
			||||||
    [ "/" append ] when
 | 
					    dup link-info directory? [ "/" append ] when
 | 
				
			||||||
    dup <a =href a> escape-string write </a> ;
 | 
					    dup <a =href a> escape-string write </a> ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: directory. ( path -- )
 | 
					: directory. ( path -- )
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ TUPLE: file-responder root hook special allow-listings ;
 | 
				
			||||||
        [ <h1> file-name escape-string write </h1> ]
 | 
					        [ <h1> file-name escape-string write </h1> ]
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
            <ul>
 | 
					            <ul>
 | 
				
			||||||
                directory sort-keys
 | 
					                directory-files 
 | 
				
			||||||
                [ <li> file. </li> ] assoc-each
 | 
					                [ <li> file. </li> ] assoc-each
 | 
				
			||||||
            </ul>
 | 
					            </ul>
 | 
				
			||||||
        ] bi
 | 
					        ] bi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,11 +19,13 @@ DEFER: add-child-monitor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: add-child-monitors ( path -- )
 | 
					: add-child-monitors ( path -- )
 | 
				
			||||||
    #! We yield since this directory scan might take a while.
 | 
					    #! 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 -- )
 | 
					: add-child-monitor ( path -- )
 | 
				
			||||||
    notify? [ dup { +add-file+ } monitor tget queue-change ] when
 | 
					    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 ]
 | 
					        [ add-child-monitors ]
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
            [
 | 
					            [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ math.bitwise byte-arrays alien combinators calendar
 | 
				
			||||||
io.encodings.binary accessors sequences strings system
 | 
					io.encodings.binary accessors sequences strings system
 | 
				
			||||||
io.files.private destructors vocabs.loader calendar.unix
 | 
					io.files.private destructors vocabs.loader calendar.unix
 | 
				
			||||||
unix.stat alien.c-types arrays unix.users unix.groups
 | 
					unix.stat alien.c-types arrays unix.users unix.groups
 | 
				
			||||||
environment ;
 | 
					environment fry io.encodings.utf8 alien.strings ;
 | 
				
			||||||
IN: io.unix.files
 | 
					IN: io.unix.files
 | 
				
			||||||
 | 
					
 | 
				
			||||||
M: unix cwd ( -- path )
 | 
					M: unix cwd ( -- path )
 | 
				
			||||||
| 
						 | 
					@ -138,6 +138,27 @@ os {
 | 
				
			||||||
    { linux [ ] }
 | 
					    { linux [ ] }
 | 
				
			||||||
} case
 | 
					} 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
 | 
					<PRIVATE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: stat-mode ( path -- mode )
 | 
					: 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 chroot ( char* path ) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FUNCTION: int close ( int fd ) ;
 | 
					FUNCTION: int close ( int fd ) ;
 | 
				
			||||||
 | 
					FUNCTION: int closedir ( DIR* dirp ) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: close-file ( fd -- ) [ close ] unix-system-call drop ;
 | 
					: 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: int open ( char* path, int flags, int prot ) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FUNCTION: DIR* opendir ( char* path ) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: open-file ( path flags mode -- fd ) [ open ] unix-system-call ;
 | 
					: open-file ( path flags mode -- fd ) [ open ] unix-system-call ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
C-STRUCT: utimbuf
 | 
					C-STRUCT: utimbuf
 | 
				
			||||||
| 
						 | 
					@ -157,6 +160,8 @@ FUNCTION: int pipe ( int* filedes ) ;
 | 
				
			||||||
FUNCTION: void* popen ( char* command, char* type ) ;
 | 
					FUNCTION: void* popen ( char* command, char* type ) ;
 | 
				
			||||||
FUNCTION: ssize_t read ( int fd, void* buf, size_t nbytes ) ;
 | 
					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 ) ;
 | 
					FUNCTION: ssize_t readlink ( char* path, char* buf, size_t bufsize ) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: PATH_MAX 1024 ; inline
 | 
					: PATH_MAX 1024 ; inline
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ METHOD: expand { variable-expr } expr>> os-env ;
 | 
				
			||||||
METHOD: expand { glob-expr }
 | 
					METHOD: expand { glob-expr }
 | 
				
			||||||
  expr>>
 | 
					  expr>>
 | 
				
			||||||
  dup "*" =
 | 
					  dup "*" =
 | 
				
			||||||
    [ drop current-directory get directory [ first ] map ]
 | 
					    [ drop current-directory get directory-files ]
 | 
				
			||||||
    [ ]
 | 
					    [ ]
 | 
				
			||||||
  if ;
 | 
					  if ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -374,15 +374,16 @@ M: revision feed-entry-url id>> revision-url ;
 | 
				
			||||||
        { wiki "wiki-common" } >>template ;
 | 
					        { wiki "wiki-common" } >>template ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: init-wiki ( -- )
 | 
					: 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
 | 
					                swap ascii file-contents
 | 
				
			||||||
            f <revision>
 | 
					                f <revision>
 | 
				
			||||||
                swap >>content
 | 
					                    swap >>content
 | 
				
			||||||
                swap >>title
 | 
					                    swap >>title
 | 
				
			||||||
                "slava" >>author
 | 
					                    "slava" >>author
 | 
				
			||||||
                now >>date
 | 
					                    now >>date
 | 
				
			||||||
            add-revision
 | 
					                add-revision
 | 
				
			||||||
        ] [ 2drop ] if
 | 
					            ] [ 2drop ] if
 | 
				
			||||||
    ] each ;
 | 
					        ] each
 | 
				
			||||||
 | 
					    ] with-directory-files ;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue