directory-to-file: Better nested syntax.
parent
d9df9fc3cc
commit
ffcb7839f6
|
@ -33,7 +33,7 @@ IN: escape-strings
|
||||||
|
|
||||||
: escape-simplest ( str -- str' )
|
: escape-simplest ( str -- str' )
|
||||||
dup { CHAR: ' CHAR: " CHAR: \r CHAR: \n CHAR: \s } counts {
|
dup { CHAR: ' CHAR: " CHAR: \r CHAR: \n CHAR: \s } counts {
|
||||||
{ [ dup { CHAR: ' CHAR: \r CHAR: \n CHAR: \s } values-of sum 0 = ] [ drop "'" prepend ] }
|
! { [ dup { CHAR: ' CHAR: \r CHAR: \n CHAR: \s } values-of sum 0 = ] [ drop "'" prepend ] }
|
||||||
{ [ dup CHAR: " of not ] [ drop "\"" "\"" surround ] }
|
{ [ dup CHAR: " of not ] [ drop "\"" "\"" surround ] }
|
||||||
[ drop escape-string ]
|
[ drop escape-string ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
|
@ -9,8 +9,8 @@ IN: tools.directory-to-file
|
||||||
: file-is-binary? ( path -- ? )
|
: file-is-binary? ( path -- ? )
|
||||||
binary file-contents [ 127 <= ] all? ;
|
binary file-contents [ 127 <= ] all? ;
|
||||||
|
|
||||||
: directory-to-string ( path -- string )
|
:: directory-to-string ( path -- string )
|
||||||
normalize-path
|
path normalize-path
|
||||||
[ path-separator = ] trim-tail "/" append
|
[ path-separator = ] trim-tail "/" append
|
||||||
[ recursive-directory-files [ file-info directory? ] reject ] keep
|
[ recursive-directory-files [ file-info directory? ] reject ] keep
|
||||||
dup '[
|
dup '[
|
||||||
|
@ -26,8 +26,10 @@ IN: tools.directory-to-file
|
||||||
] with-directory
|
] with-directory
|
||||||
[
|
[
|
||||||
first2
|
first2
|
||||||
[ escape-string "FILE: " prepend ] dip " " glue
|
[ escape-simplest "FILE:: " prepend ] dip " " glue
|
||||||
] map "\n\n" join ;
|
] map "\n\n" join
|
||||||
|
"<DIRECTORY: " path escape-simplest "\n\n" 3append
|
||||||
|
"\n\nDIRECTORY>" surround ;
|
||||||
|
|
||||||
: directory-to-file ( path -- )
|
: directory-to-file ( path -- )
|
||||||
[ directory-to-string ] keep ".modern" append
|
[ directory-to-string ] keep ".modern" append
|
||||||
|
|
Loading…
Reference in New Issue