: dyld-find ( name -- path/f )
dyld-search-paths [
{
- { [ dup exists? ] [ file-info regular-file? ] }
+ { [ dup file-exists? ] [ file-info regular-file? ] }
{ [ use-dyld-shared-cache? ] [ _dyld_shared_cache_contains_path ] }
[ drop f ]
} cond
: find-library-paths ( name -- path/f )
candidate-paths [
- { [ exists? ] [ file-info regular-file? ] } 1&&
+ { [ file-exists? ] [ file-info regular-file? ] } 1&&
] find nip ;
: find-library-file ( name -- path/f )
download-checksums at ;
: need-new-image? ( image -- ? )
- dup exists?
+ dup file-exists?
[ [ file-checksum ] [ download-checksum ] bi = not ]
[ drop t ]
if ;
{
"io.files.private"
{
- { "(exists?)" ( path -- ? ) "existsp" { string } { object } f }
+ { "(file-exists?)" ( path -- ? ) "existsp" { string } { object } f }
}
}
{
: load-vocab-roots ( -- )
"user-init" get [
- "~/.factor-roots" dup exists? [
+ "~/.factor-roots" dup file-exists? [
utf8 file-lines harvest [ add-vocab-root ] each
] [ drop ] if
"roots" get [
[ "Code" which ]
[ home "VSCode-linux-x64/Code" append-path ]
[ "/usr/share/code/code" ]
- } [ dup exists? [ drop f ] unless ] map-compose 0|| ] }
+ } [ dup file-exists? [ drop f ] unless ] map-compose 0|| ] }
{ macosx [
"com.microsoft.VSCode" find-native-bundle
[ "Contents/MacOS/Electron" append-path ] [ f ] if* ] }
resolve-symlinks server get serving-directory>> head? ;
: can-serve-directory? ( path -- ? )
- { [ exists? ] [ file-info directory? ] [ serving? ] } 1&& ;
+ { [ file-exists? ] [ file-info directory? ] [ serving? ] } 1&& ;
: can-serve-file? ( path -- ? )
{
- [ exists? ]
+ [ file-exists? ]
[ file-info regular-file? ]
[ serving? ]
} 1&& ;
:: glob-literal% ( root globs -- )
globs unclip :> ( remaining glob )
- root glob append-path dup exists? [
+ root glob append-path dup file-exists? [
remaining over file-info ?glob%
] [
drop
] { } make ;
:: resolve-gir-path ( path -- path )
- path exists?
+ path file-exists?
[ path ] [
current-vocab-dirs custom-gir-dirs system-gir-dirs
3append sift :> paths
- paths [ path append-path exists? ] find nip
+ paths [ path append-path file-exists? ] find nip
[ path append-path ] [ path paths gir-not-found ] if*
] if ;
"@2x" over subseq? [ "." split1-last "@2x." glue ] unless ;
: ?copy-file ( from to -- )
- dup exists? [ 2drop ] [ copy-file ] if ;
+ dup file-exists? [ 2drop ] [ copy-file ] if ;
: cache-images ( body -- body' )
dup [
] with-file-writer ;
: ?download-to ( url file -- )
- dup exists? [ 2drop ] [ download-to ] if ;
+ dup file-exists? [ 2drop ] [ download-to ] if ;
: download ( url -- )
dup download-name download-to ;
: find-index ( filename -- path )
file-responder get index-names>>
- [ append-path dup exists? [ drop f ] unless ] with map-find
+ [ append-path dup file-exists? [ drop f ] unless ] with map-find
drop ;
: serve-directory ( filename -- response )
] if ;
: serve-object ( filename -- response )
- serving-path dup exists?
+ serving-path dup file-exists?
[ dup file-info directory? [ serve-directory ] [ serve-file ] if ]
[ drop <404> ]
if ;
[
{ t t f } [
"blahblah" make-directory
- "blahblah" exists?
+ "blahblah" file-exists?
"blahblah" file-info directory?
"blahblah" delete-directory
- "blahblah" exists?
+ "blahblah" file-exists?
] unit-test
{ "file1 contents" } [
{ } [ "test-foo.txt" delete-file ] unit-test
{ } [ "test-bar.txt" delete-file ] unit-test
- { f } [ "test-foo.txt" exists? ] unit-test
- { f } [ "test-bar.txt" exists? ] unit-test
+ { f } [ "test-foo.txt" file-exists? ] unit-test
+ { f } [ "test-bar.txt" file-exists? ] unit-test
{ } [ "test-blah" make-directory ] unit-test
] unit-test
{ t } [
- "test-blah/fooz" exists?
+ "test-blah/fooz" file-exists?
] unit-test
{ } [ "test-blah/fooz" delete-file ] unit-test
{ } [ "test-blah" delete-directory ] unit-test
- { f } [ "test-blah" exists? ] unit-test
+ { f } [ "test-blah" file-exists? ] unit-test
{ } [ "delete-tree-test/a/b/c" make-directories ] unit-test
{ f t } [
"foo" [ make-directories ] keep
[
- "bar" exists?
+ "bar" file-exists?
vm-path "-e=USE: io.directories \"bar\" touch-file" 2array try-output-process
- "bar" exists?
+ "bar" file-exists?
] with-directory
] unit-test
{ t } [
- "one/two/three" make-parent-directories parent-directory exists?
+ "one/two/three" make-parent-directories parent-directory file-exists?
] unit-test
] with-test-directory
[ "." = ]
[ root-directory? ]
[ empty? ]
- [ exists? ]
+ [ file-exists? ]
} 1|| [
make-parent-directories
dup make-directory
M: unix touch-file
normalize-path
- dup exists? [ touch ] [
+ dup file-exists? [ touch ] [
touch-mode file-mode open-file close-file
] if ;
{ $subsections
file-info
link-info
- exists?
+ file-exists?
directory?
regular-file?
symbolic-link?
HOOK: file-info os ( path -- info )
: ?file-info ( path -- info/f )
- dup exists? [ file-info ] [ drop f ] if ;
+ dup file-exists? [ file-info ] [ drop f ] if ;
HOOK: link-info os ( path -- info )
: ?link-info ( path -- info/f )
- dup exists? [ link-info ] [ drop f ] if ;
+ dup file-exists? [ link-info ] [ drop f ] if ;
<PRIVATE
M: unix resolve-symlinks
path-components "/"
- [ append-path dup exists? [ follow-links ] when ] reduce ;
+ [ append-path dup file-exists? [ follow-links ] when ] reduce ;
factor-bundle-name append-path ;
: first-existing ( paths -- path )
- [ exists? ] find nip
+ [ file-exists? ] find nip
[ "no user cache directory found" throw ] unless* ; inline
PRIVATE>
{ t } [
[
[ ] with-unique-directory
- [ exists? ] [ delete-tree ] bi
+ [ file-exists? ] [ delete-tree ] bi
] with-temp-directory
] unit-test
] unit-test
[ "c:\\blah" ] [ "c:\\foo\\bar" "\\blah" append-path ] unit-test
-[ t ] [ "" resource-path 2 tail exists? ] unit-test
+[ t ] [ "" resource-path 2 tail file-exists? ] unit-test
! win32-file-attributes
{
[
{ } [ { "touch" "launcher-test-1" } try-process ] unit-test
- { t } [ "launcher-test-1" exists? ] unit-test
+ { t } [ "launcher-test-1" file-exists? ] unit-test
{ } [
"launcher-test-1" ?delete-file
{ } [ "a2" make-directory ] unit-test
{ } [ "a1" "a2" move-file-into ] unit-test
- { t } [ "a2/a1" exists? ] unit-test
+ { t } [ "a2/a1" file-exists? ] unit-test
{ } [ "a2/a1/a3.txt" touch-file ] unit-test
- { t } [ "a2/a1/a3.txt" exists? ] unit-test
+ { t } [ "a2/a1/a3.txt" file-exists? ] unit-test
{ } [ "a2/a1/a4.txt" touch-file ] unit-test
{ } [ "a2/a1/a5.txt" touch-file ] unit-test
{ } [ "a2/a1/a4.txt" delete-file ] unit-test
{ } [ "a2/a1/a5.txt" "a2/a1/a4.txt" move-file ] unit-test
- { t } [ "a2/a1/a4.txt" exists? ] unit-test
+ { t } [ "a2/a1/a4.txt" file-exists? ] unit-test
{ } [ "m" get dispose ] unit-test
] with-monitors
M: mock-io-backend (monitor)
nip
- over exists? [
+ over file-exists? [
dummy-monitor new-monitor
dummy-monitor-created get [ 1 + ] change-i drop
] [
ERROR: file-expected path ;
: ensure-exists ( path -- path )
- dup exists? [ file-expected ] unless ; inline
+ dup file-exists? [ file-expected ] unless ; inline
: ssl-file-path ( path -- path' )
absolute-path ensure-exists ;
M: unix find-in-path*
[ "PATH" os-env ":" split ] dip
- '[ _ append-path exists? ] find nip ;
+ '[ _ append-path file-exists? ] find nip ;
! iterm2 spews some terminal info on every bash command.
: parse-login-paths ( seq -- strings )
binary <process-reader> stream-contents parse-login-paths ;
M: unix find-in-standard-login-path*
- [ standard-login-paths ] dip '[ _ append-path exists? ] find nip ;
+ [ standard-login-paths ] dip '[ _ append-path file-exists? ] find nip ;
M: windows find-in-path*
[ "PATH" os-env ";" split ] dip
- '[ _ append-path exists? ] find nip ;
+ '[ _ append-path file-exists? ] find nip ;
] { } make ;
: parse-log-file ( service -- entries )
- log-path 1 log# dup exists?
+ log-path 1 log# dup file-exists?
[ utf8 file-lines parse-log ] [ drop f ] if ;
GENERIC: log-timestamp. ( date -- )
keep-logs log# ?delete-file ;
: ?move-file ( old new -- )
- over exists? [ move-file ] [ 2drop ] if ;
+ over file-exists? [ move-file ] [ 2drop ] if ;
: advance-log ( path n -- )
[ 1 - log# ] 2keep log# ?move-file ;
: paths-matching ( str -- seq )
dup last-path-separator [ 1 + cut ] [ drop "" ] if swap
- dup { [ exists? ] [ file-info directory? ] } 1&&
+ dup { [ file-exists? ] [ file-info directory? ] } 1&&
[ directory-paths completions ] [ 2drop { } ] if ;
<PRIVATE
: make-boot-image ( -- )
! If stage1 image doesn't exist, create one.
- my-boot-image-name resource-path exists?
+ my-boot-image-name resource-path file-exists?
[ make-my-image ] unless ;
: staging-image-name ( profile -- name )
] { } make ;
: make-staging-image ( profile -- )
- { } [ suffix ] accumulate* [ staging-image-name exists? ] reject
+ { } [ suffix ] accumulate* [ staging-image-name file-exists? ] reject
[ staging-command-line ] map
[ vm-path swap run-factor ] each ;
vocab-dir "icon.icns" append-path ;
: copy-icns ( vocab bundle-name -- icon? )
- swap dup vocab-mac-icon-path vocab-append-path dup exists?
+ swap dup vocab-mac-icon-path vocab-append-path dup file-exists?
[ swap "Contents/Resources/Icon.icns" append-path copy-file t ]
[ 2drop f ] if ;
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: deploy-app-bundle ( vocab -- )
- bundle-name dup exists? [ delete-tree ] [ drop ] if
+ bundle-name dup file-exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep
[ bundle-name deploy.app-image-name ] keep
namespace make-deploy-image
vocab-dir "icon.ico" append-path ;
: embed-ico ( vm-path vocab -- )
- dup vocab-windows-icon-path vocab-append-path dup exists?
+ dup vocab-windows-icon-path vocab-append-path dup file-exists?
[ binary file-contents app-icon-resource-id embed-icon-resource ]
[ 2drop ] if ;
: scaffold-directory ( vocab-root vocab -- )
vocab-root/vocab>path
- dup exists? [ directory-exists ] [ make-directories ] if ;
+ dup file-exists? [ directory-exists ] [ make-directories ] if ;
: not-scaffolding ( path -- path )
"Not creating scaffolding for " write dup <pathname> . ;
"Creating scaffolding for " write dup <pathname> . ;
: scaffolding? ( path -- path ? )
- dup exists? [ not-scaffolding f ] [ scaffolding t ] if ;
+ dup file-exists? [ not-scaffolding f ] [ scaffolding t ] if ;
: scaffold-copyright ( -- )
"! Copyright (C) " write now year>> number>string write
: executable? ( path -- ? )
{
- [ exists? ]
+ [ file-exists? ]
[ file-executable? ]
[ file-info directory? not ]
} 1&& ;
dup vocab-dir { "icon.png" "icon.ico" } [
append-path vocab-append-path
] 2with map default-icon-path suffix
- [ exists? ] find nip binary file-contents ;
+ [ file-exists? ] find nip binary file-contents ;
: load-icon ( -- )
icon-data get [
: vocab-tests-dir ( vocab -- paths )
dup vocab-dir "tests" append-path vocab-append-path [
- dup exists? [
+ dup file-exists? [
dup directory-files [ ".factor" tail? ] filter
[ append-path ] with map
] [ drop f ] if
: vocab-tests ( vocab -- paths )
vocab-name ".private" ?tail drop
[
- [ vocab-tests-path [ dup exists? [ , ] [ drop ] if ] when* ]
+ [ vocab-tests-path [ dup file-exists? [ , ] [ drop ] if ] when* ]
[ vocab-tests-dir % ] bi
] { } make ;
: vocab-directory-entries ( root prefix -- vocab-path vocab-name entries )
ensure-vocab-root/prefix [ vocab-dir append-path ] keep
- over dup exists? [ directory-entries ] [ drop { } ] if ;
+ over dup file-exists? [ directory-entries ] [ drop { } ] if ;
: (disk-vocabs) ( root prefix -- seq )
vocab-directory-entries visible-dirs [
name>>
[ dup ".factor" append append-path append-path ]
[ over empty? [ nip ] [ "." glue ] if ] bi-curry bi*
- swap exists? [ >vocab-link ] [ <vocab-prefix> ] if
+ swap file-exists? [ >vocab-link ] [ <vocab-prefix> ] if
] 2with map ;
DEFER: add-vocab%
MEMO: vocab-file-lines ( vocab name -- lines/f )
vocab-file-path dup [
- dup exists? [
+ dup file-exists? [
utf8 file-lines harvest
] [
drop f
M: unsupported-platform summary
drop "Current operating system not supported by this vocabulary" ;
-: exists?, ( path -- )
- [ dup exists? [ , ] [ drop ] if ] when* ;
+: file-exists?, ( path -- )
+ [ dup file-exists? [ , ] [ drop ] if ] when* ;
: vocab-metadata-files ( vocab -- paths )
[
{
- [ vocab-summary-path exists?, ]
- [ vocab-authors-path exists?, ]
- [ vocab-tags-path exists?, ]
- [ vocab-platforms-path exists?, ]
- [ vocab-resources-path exists?, ]
+ [ vocab-summary-path file-exists?, ]
+ [ vocab-authors-path file-exists?, ]
+ [ vocab-tags-path file-exists?, ]
+ [ vocab-platforms-path file-exists?, ]
+ [ vocab-resources-path file-exists?, ]
} cleave
] { } make ;
] [ monitor-loop ] bi ;
: (start-vocab-monitor) ( vocab-root -- )
- dup exists?
+ dup file-exists?
[ [ t <monitor> monitor-loop ] with-monitors ] [ drop ] if ;
: start-vocab-monitor ( vocab-root -- )
: source-modified? ( path -- ? )
dup source-files get at [
dup path>>
- dup exists? [
+ dup file-exists? [
utf8 file-lines crc32 checksum-lines
swap checksum>> = not
] [
2drop f
] if
] [
- exists?
+ file-exists?
] ?if ;
SYMBOL: changed-vocabs
init-resource-path
"resource:basis/bootstrap/stage2.factor"
- dup exists? [
+ dup file-exists? [
run-file
] [
"Cannot find " write write "." print
{ set-file-lines file-lines change-file-lines set-file-contents file-contents change-file-contents } related-words
-HELP: exists?
+HELP: file-exists?
{ $values { "path" "a pathname string" } { "?" boolean } }
{ $description "Tests if the file named by " { $snippet "path" } " exists." } ;
{ } [ "test.txt" "test2.txt" move-file ] unit-test
- { t } [ "test2.txt" exists? ] unit-test
+ { t } [ "test2.txt" file-exists? ] unit-test
{ } [ "test2.txt" delete-file ] unit-test
] with-test-directory
IN: io.files
<PRIVATE
-PRIMITIVE: (exists?) ( path -- ? )
+PRIMITIVE: (file-exists?) ( path -- ? )
PRIVATE>
SYMBOL: +retry+ ! just try the operation again without blocking
: with-file-appender ( path encoding quot -- )
[ <file-appender> ] dip with-output-stream ; inline
-: exists? ( path -- ? )
- normalize-path native-string>alien (exists?) ;
+: file-exists? ( path -- ? )
+ normalize-path native-string>alien (file-exists?) ;
+
+ALIAS: exists? file-exists?
! Current directory
<PRIVATE
parse-file call( -- ) ;
: ?run-file ( path -- )
- dup exists? [ run-file ] [ drop ] if ;
+ dup file-exists? [ run-file ] [ drop ] if ;
ERROR: version-control-merge-conflict ;
: reset-checksums ( -- )
source-files get [
- over exists? [
+ over file-exists? [
[ utf8 file-lines ] dip record-checksum
] [ 2drop ] if
] assoc-each ;
<PRIVATE
: find-root-for ( path -- path/f )
- vocab-roots get [ prepend-path exists? ] with find nip ;
+ vocab-roots get [ prepend-path file-exists? ] with find nip ;
M: string vocab-path
dup find-root-for [ prepend-path ] [ not-found-in-roots ] if* ;
:: read-standard-include ( preprocessor-state path -- )
preprocessor-state dup library-paths>>
- [ path append-path exists? ] find nip
+ [ path append-path file-exists? ] find nip
[
dup [
path append-path
] if* ;
: read-local-include ( preprocessor-state path -- )
- dup exists? [ preprocess-file ] [ 2drop ] if ;
+ dup file-exists? [ preprocess-file ] [ 2drop ] if ;
: skip-whitespace/comments ( sequence-parser -- sequence-parser )
skip-whitespace
{ "123" "1" } [ "1" "123" [ length ] [ < ] swap-when ] unit-test
-{ t } [ "resource:" [ exists? ] ?1arg >boolean ] unit-test
-{ f } [ f [ exists? ] ?1arg ] unit-test
-{ f } [ "/homeasdfasdf123123" [ exists? ] ?1arg ] unit-test
+{ t } [ "resource:" [ file-exists? ] ?1arg >boolean ] unit-test
+{ f } [ f [ file-exists? ] ?1arg ] unit-test
+{ f } [ "/homeasdfasdf123123" [ file-exists? ] ?1arg ] unit-test
{ "hi " "there" } [
"hi there" {
: rom-dir ( -- string )
rom-root get [
- home "roms" append-path dup exists? [ drop f ] unless
+ home "roms" append-path dup file-exists? [ drop f ] unless
] unless* ;
: load-rom* ( seq cpu -- )
] loop ;
: delete-if-exists ( file -- )
- dup exists? [ delete-file ] [ drop ] if ;
+ dup file-exists? [ delete-file ] [ drop ] if ;
: make-local-socket ( socket-path -- socket )
[ delete-if-exists ] keep
{ $values { "error" gdbm-error } { "msg" string } }
{ $description "Returns error message in human readable format." } ;
-HELP: exists?
+HELP: file-exists?
{ $values { "key" object } { "?" boolean } }
{ $description "Searches for a particular key without retreiving it." } ;
"All interaction with gdbm database should be realized using special combinator which automates all work for database initialisation and cleanup. All initialisation options are passed to combinator with a database configuration object."
{ $subsections gdbm <gdbm> with-gdbm }
"For actual record manipulation the following words are used:"
-{ $subsections insert exists? fetch delete }
+{ $subsections insert file-exists? fetch delete }
{ $heading "Sequential access" }
"It is possible to iterate through all records in the database with"
test.db reader >>role [ ] with-gdbm
] [ gdbm-file-open-error = ] must-fail-with
-{ f } [ [ "foo" exists? ] with-test.db ] unit-test
+{ f } [ [ "foo" file-exists? ] with-test.db ] unit-test
{ } [ [ "foo" 41 insert ] with-test.db ] unit-test
{ f }
[
- test.db newdb >>role [ "foo" exists? ] with-gdbm
+ test.db newdb >>role [ "foo" file-exists? ] with-gdbm
] unit-test
CLEANUP
: synchronize ( -- ) dbf gdbm_sync ;
-: exists? ( key -- ? )
+: file-exists? ( key -- ? )
[ dbf swap object>datum gdbm_exists c-bool> ]
with-destructors ;
] when* ;
: gemini-less ( -- )
- "gemini.txt" temp-file dup exists? [
+ "gemini.txt" temp-file dup file-exists? [
"less" swap 2array try-process
] [ drop ] if ;
URL ?first [ >url "/" >>path gemini-go ] when* ;
: gemini-shell ( args -- )
- "|" split "gemini.txt" temp-file dup exists? [
+ "|" split "gemini.txt" temp-file dup file-exists? [
"cat" swap 2array prefix run-pipeline drop
] [ 2drop ] if ;
] with-directory-entries ;
: send-directory ( server path -- )
- dup ".geminimap" append-path dup exists? [
+ dup ".geminimap" append-path dup file-exists? [
send-file 2drop
] [
drop dup ".geminihead" append-path
- dup exists? [ send-file ] [ drop ] if
+ dup file-exists? [ send-file ] [ drop ] if
list-directory
] if ;
CONSTANT: db-url "http://software77.net/geo-ip/?DL=1"
: download-db ( -- path )
- db-path dup exists? [
+ db-path dup file-exists? [
db-url over ".gz" append download-to
{ "gunzip" } over ".gz" append absolute-path suffix try-process
] unless ;
[ first ] [ expected-one-line ] if ;
: git-unpacked-object-exists? ( hash -- ? )
- make-object-path exists? ;
+ make-object-path file-exists? ;
TUPLE: index-entry ctime mtime dev ino mode uid gid size sha1 flags name ;
CONSTRUCTOR: <index-entry> index-entry ( ctime mtime dev ino mode uid gid size sha1 flags name -- obj ) ;
] with-directory-entries ;
: send-directory ( server path -- )
- dup ".gophermap" append-path dup exists? [
+ dup ".gophermap" append-path dup file-exists? [
send-file 2drop
] [
drop dup ".gopherhead" append-path
- dup exists? [ send-file ] [ drop ] if
+ dup file-exists? [ send-file ] [ drop ] if
list-directory
] if ;
] with-test-directory ;
: preview-smoke-test ( graph -- pass? )
- [ exists? ] with-preview ;
+ [ file-exists? ] with-preview ;
: K_n ( n -- graph )
<graph>
[ unsupported-encoding ] unless ;
: ?delete-file ( path -- )
- dup exists? [ delete-file ] [ drop ] if ;
+ dup file-exists? [ delete-file ] [ drop ] if ;
PRIVATE>
clear-errno
ACL_TYPE_EXTENDED acl_get_file dup [
errno ENOENT = [
- [ path exists? ] preserve-errno
+ [ path file-exists? ] preserve-errno
[ drop f ] [ throw-errno ] if
] [
throw-errno
top-directory dup trash-home top-directory = [
drop trash-home
] [
- dup ".Trash" append-path exists?
+ dup ".Trash" append-path file-exists?
[ trash-1 ] [ trash-2 ] if
[ make-user-directory ] keep
] if ;
] dip swap "%s%s %s%s" sprintf ;
: safe-file-name ( path -- path' )
- dup 0 [ over exists? ] [
+ dup 0 [ over file-exists? ] [
[ parent-directory to-directory ] [ 1 + ] bi*
[ (safe-file-name) ] keep
] while drop nip ;
: download-to-directory ( url directory -- )
dup make-directories
[
- dup { [ download-name exists? ] [ file-stem exists? ] } 1|| [
+ dup { [ download-name file-exists? ] [ file-stem file-exists? ] } 1|| [
drop
] [
download
"http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz"
}
[ [ "resource:datasets/" download-to-directory ] parallel-each ]
- [ [ dup file-stem exists? [ drop ] [ file-name gzip-decompress-file ] if ] each ]
+ [ [ dup file-stem file-exists? [ drop ] [ file-name gzip-decompress-file ] if ] each ]
[ [ file-stem binary file-contents ] map ] tri
first4 {
[ mnist-data>array ]
IN: mason.cleanup
: compress ( filename -- )
- dup exists? [
+ dup file-exists? [
"bzip2" swap 2array short-running-process
] [ drop ] if ;
: git-clone-or-pull ( -- id )
! Must be run from builds-dir.
- "factor" exists? [
+ "factor" file-exists? [
check-repository [
"factor" [
[ git-pull-cmd short-running-process ]
: tidy ( -- )
"factor" [
useless-files
- [ exists? ] filter
+ [ file-exists? ] filter
[ delete-tree ] each
] with-directory ;
{ 0 0 } [ [ ] with-report ] must-infer-as
: verify-report ( -- )
- [ t ] [ "report" exists? ] unit-test
+ [ t ] [ "report" file-exists? ] unit-test
[ ] [ "report" file>xml drop ] unit-test
[ ] [ "report" delete-file ] unit-test ;
extra-vocabs
] { } append-outputs-as ;
-: filter-exists ( seq -- seq' ) [ exists? ] filter ;
+: filter-exists ( seq -- seq' ) [ file-exists? ] filter ;
! These paths have syntax errors on purpose...
: reject-some-paths ( seq -- seq' )
! digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is
! also prime.
-! What is the largest n-digit pandigital prime that exists?
+! What is the largest n-digit pandigital prime that file-exists?
! SOLUTION
: handle-send-file ( bytes -- )
"\0" split harvest first2 [ utf8 decode ] bi@
- over { [ exists? ] [ file-info directory? not ] } 1&& [
+ over { [ file-exists? ] [ file-info directory? not ] } 1&& [
"netascii" sequence= utf8 binary ? 0 read-file boa
tftp-client get clients get set-at
0 handle-send-file-next
: process ( max line -- max ) split-line inc-current-count update-time ;
MEMO: mlijobs ( -- lines )
- "mlijobs.txt" temp-file dup exists? [
+ "mlijobs.txt" temp-file dup file-exists? [
URL" http://rosettacode.org/resources/mlijobs.txt"
over download-to
] unless ascii file-lines ;
: terminfo-path ( name -- path )
terminfo-relative-path TERMINFO-DIRS [ swap append-path ] with map
- [ exists? ] find nip ;
+ [ file-exists? ] find nip ;
: terminfo-names-for-path ( path -- names )
[
] with-directory-entries ;
MEMO: terminfo-names ( -- names )
- TERMINFO-DIRS [ exists? ] filter
+ TERMINFO-DIRS [ file-exists? ] filter
[ terminfo-names-for-path ] map concat ;
<PRIVATE
] with-directory ;
: ?download-tldr ( -- )
- "tldr/tldr.zip" cache-file exists? [ download-tldr ] unless ;
+ "tldr/tldr.zip" cache-file file-exists? [ download-tldr ] unless ;
MEMO: tldr-index ( -- index )
"tldr/index.json" cache-file path>json ;
'[ _ stream-write ] each-stream-block ;
: cat-file ( path -- )
- dup exists? [
+ dup file-exists? [
binary [ cat-stream ] with-file-reader
] [ "%s: not found\n" printf flush ] if ;
[ unclip-last copy-files-into ] [ drop usage ] if ;
: copy-to-file ( args -- )
- dup last { [ exists? ] [ file-info directory? ] } 1&&
+ dup last { [ file-exists? ] [ file-info directory? ] } 1&&
[ copy-to-dir ] [ first2 copy-file ] if ;
: run-copy ( -- )
boot-image-name resource-path ;
: ?make-image ( arch -- )
- dup boot-image-path exists? [ drop ] [ make-image ] if ;
+ dup boot-image-path file-exists? [ drop ] [ make-image ] if ;
: loadable-images ( -- images )
image-names cpu name>> '[ _ tail? ] filter ;
boot-image-name resource-path ;
: ?make-image ( arch -- )
- dup boot-image-path exists? [ drop ] [ make-image ] if ;
+ dup boot-image-path file-exists? [ drop ] [ make-image ] if ;
: loadable-images ( -- images )
image-names cpu name>> '[ _ tail? ] filter ;
[ imagebin set ] [ call-next-method ] bi ;
: move-image ( mime-file -- )
- [ next-image-path dup exists? ] [ drop ] while
+ [ next-image-path dup file-exists? ] [ drop ] while
[ [ temporary-path>> ] dip move-file ]
[ [ filename>> ] dip ".txt" append utf8 set-file-contents ] 2bi ;
: update-docs ( -- )
home [
- "newdocs" exists? [ "newdocs" delete-tree ] when
+ "newdocs" file-exists? [ "newdocs" delete-tree ] when
"newdocs" make-directory
"newdocs" [ { "tar" "xfz" } docs-path suffix try-process ] with-directory
- "docs" exists? [ "docs" "docs.old" move-file ] when
+ "docs" file-exists? [ "docs" "docs.old" move-file ] when
"newdocs/docs" "docs" move-file
"newdocs" delete-directory
- "docs.old" exists? [ "docs.old" delete-tree ] when
+ "docs.old" file-exists? [ "docs.old" delete-tree ] when
\ load-index reset-memoized
] with-directory ;
SynKeywordFactorWord factorWord_io_encodings | syn keyword factorWord_io_encodings contained (decode-until) <decoder> <encoder> decode-char decode-error decode-error? decode-input decode-until decoder decoder? encode-char encode-error encode-error? encode-output encode-string encoder encoder? guess-decoded-length guess-encoded-length re-decode re-encode replacement-char with-decoded-input with-encoded-output
SynKeywordFactorWord factorWord_io_encodings_binary | syn keyword factorWord_io_encodings_binary contained binary binary?
SynKeywordFactorWord factorWord_io_encodings_utf8 | syn keyword factorWord_io_encodings_utf8 contained >utf8-index code-point-length code-point-offsets utf8 utf8-index> utf8?
-SynKeywordFactorWord factorWord_io_files | syn keyword factorWord_io_files contained (file-appender) (file-reader) (file-writer) +input+ +output+ +retry+ <file-appender> <file-reader> <file-writer> change-file-contents change-file-lines drain exists? file-contents file-lines file-reader file-reader? file-writer file-writer? init-resource-path refill set-file-contents set-file-lines wait-for-fd with-file-appender with-file-reader with-file-writer
+SynKeywordFactorWord factorWord_io_files | syn keyword factorWord_io_files contained (file-appender) (file-reader) (file-writer) +input+ +output+ +retry+ <file-appender> <file-reader> <file-writer> change-file-contents change-file-lines drain file-exists? file-contents file-lines file-reader file-reader? file-writer file-writer? init-resource-path refill set-file-contents set-file-lines wait-for-fd with-file-appender with-file-reader with-file-writer
SynKeywordFactorWord factorWord_kernel | syn keyword factorWord_kernel contained (clone) -roll -rot -rotd 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2keep 2keepd 2nip 2nipd 2over 2tri 2tri* 2tri@ 2with 3bi 3curry 3dip 3drop 3dup 3keep 3nip 3nipd 3tri 4dip 4drop 4dup 4keep 4nip 5drop 5nip <wrapper> = >boolean ? ?if and assert assert= assert? bi bi* bi-curry bi-curry* bi-curry@ bi@ boa boolean boolean? both? build call callstack callstack>array callstack? clear clone compose composed composed? curried curried? curry die dip do drop dup dupd either? eq? equal? execute get-callstack get-datastack get-retainstack hashcode hashcode* identity-hashcode identity-tuple identity-tuple? if if* keep keepd keepdd loop most new nip nipd not null object or over overd pick pickd prepose reach recursive-hashcode roll rot rotd same? spin swap swapd throw tri tri* tri-curry tri-curry* tri-curry@ tri@ tuck tuple tuple? unless unless* until when when* while while* with wrapper wrapper? xor
SynKeywordFactorWord factorWord_layouts | syn keyword factorWord_layouts contained (first-bignum) (fixnum-bits) (max-array-capacity) 32bit? 64bit? bootstrap-cell bootstrap-cell-bits bootstrap-cells bootstrap-first-bignum bootstrap-fixnum-bits bootstrap-max-array-capacity bootstrap-most-negative-fixnum bootstrap-most-positive-fixnum cell cell-bits cells data-alignment first-bignum fixnum-bits hashcode-shift header-bits immediate immediate? leaf-stack-frame-size max-array-capacity mega-cache-size most-negative-fixnum most-positive-fixnum num-types tag-bits tag-fixnum tag-header tag-mask type-number type-numbers untag-fixnum
SynKeywordFactorWord factorWord_make | syn keyword factorWord_make contained % %% , ,+ ,, building make