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