: load-vocab-roots ( -- )
"user-init" get [
- "~/.factor-roots" dup file-exists? [
+ "~/.factor-roots" [
utf8 file-lines harvest [ add-vocab-root ] each
- ] [ drop ] if
+ ] when-file-exists
"roots" get [
os windows? ";" ":" ?
split [ add-vocab-root ] each
:: glob-literal% ( root globs -- )
globs unclip :> ( remaining glob )
- root glob append-path dup file-exists? [
+ root glob append-path [
remaining over file-info ?glob%
- ] [
- drop
- ] if ;
+ ] when-file-exists ;
: glob% ( root globs -- )
dup ?first {
] [ delete-file ] if ;
: ?delete-tree ( path -- )
- dup file-exists? [ delete-tree ] [ drop ] if ;
+ [ delete-tree ] when-file-exists ;
DEFER: copy-trees-into
: scaffold-directory ( vocab-root vocab -- )
vocab-root/vocab>path
- dup file-exists? [ directory-exists ] [ make-directories ] if ;
+ [ directory-exists ] [ make-directories ] if-file-exists ;
: not-scaffolding ( path -- path )
"Not creating scaffolding for " write dup <pathname> . ;
"Creating scaffolding for " write dup <pathname> . ;
: scaffolding? ( path -- path ? )
- dup file-exists? [ not-scaffolding f ] [ scaffolding t ] if ;
+ [ not-scaffolding f ] [ scaffolding t ] if-file-exists ;
: scaffold-copyright ( -- )
"! Copyright (C) " write now year>> number>string write
drop "Current operating system not supported by this vocabulary" ;
: file-exists?, ( path -- )
- [ dup file-exists? [ , ] [ drop ] if ] when* ;
+ [ [ , ] when-file-exists ] when* ;
: vocab-metadata-files ( vocab -- paths )
[
] [ monitor-loop ] bi ;
: (start-vocab-monitor) ( vocab-root -- )
- dup file-exists?
- [ [ t <monitor> monitor-loop ] with-monitors ] [ drop ] if ;
+ [ [ t <monitor> monitor-loop ] with-monitors ] when-file-exists ;
: start-vocab-monitor ( vocab-root -- )
[
parse-file call( -- ) ;
: ?run-file ( path -- )
- dup file-exists? [ run-file ] [ drop ] if ;
+ [ run-file ] when-file-exists ;
ERROR: version-control-merge-conflict ;
] when* ;
: gemini-less ( -- )
- "gemini.txt" temp-file dup file-exists? [
+ "gemini.txt" temp-file [
utf8 [
<process>
"PAGER" os-env [ "less" ] unless* >>command
input-stream get >>stdin
try-process
] with-file-reader
- ] [ drop ] if ;
+ ] when-file-exists ;
: gemini-ls ( args -- )
[ PAGE ] [ "-l" = ] bi* print-links ;
] with-directory-entries ;
: send-directory ( server path -- )
- dup ".geminimap" append-path dup file-exists? [
+ dup ".geminimap" append-path [
send-file 2drop
] [
drop dup ".geminihead" append-path
- dup file-exists? [ send-file ] [ drop ] if
+ [ send-file ] when-file-exists
list-directory
- ] if ;
+ ] if-file-exists ;
: read-gemini-path ( -- path )
readln utf8 decode "\r" ?tail drop >url path>> ;
1 stack-url [ gopher-get ] when* ;
: gopher-less ( -- )
- "gopher.txt" temp-file dup file-exists? [
+ "gopher.txt" temp-file [
utf8 [
<process>
"PAGER" os-env [ "less" ] unless* >>command
input-stream get >>stdin
try-process
] with-file-reader
- ] [ drop ] if ;
+ ] when-file-exists ;
: gopher-ls ( args -- )
[ PAGE ] [ "-l" = ] bi* print-links ;
] with-directory-entries ;
: send-directory ( server path -- )
- dup ".gophermap" append-path dup file-exists? [
+ dup ".gophermap" append-path [
send-file 2drop
] [
drop dup ".gopherhead" append-path
- dup file-exists? [ send-file ] [ drop ] if
+ [ send-file ] when-file-exists
list-directory
- ] if ;
+ ] if-file-exists ;
: read-gopher-path ( -- path )
readln dup [ "\t\r\n" member? ] find drop [ head ] when*
IN: mason.cleanup
: compress ( filename -- )
- dup file-exists? [
- "bzip2" swap 2array short-running-process
- ] [ drop ] if ;
+ [ "bzip2" swap 2array short-running-process ] when-file-exists ;
: compress-image ( -- )
target-boot-image-name compress ;
'[ _ [ stream-write ] [ stream-flush ] bi ] each-stream-block ;
: cat-file ( path -- )
- dup file-exists? [
- binary [ cat-stream ] with-file-reader
- ] [ write ": not found" print flush ] if ;
+ [ binary [ cat-stream ] with-file-reader ]
+ [ write ": not found" print flush ] if-file-exists ;
: cat-files ( paths -- )
[ dup "-" = [ drop cat-stream ] [ cat-file ] if flush ] each ;