remove ?resource-path and resource-exists?

db4
erg 2008-03-26 23:47:51 -05:00
parent 5bab5de16d
commit 15c68a23f8
14 changed files with 36 additions and 38 deletions

View File

@ -39,7 +39,7 @@ vocabs.loader system debugger continuations ;
[
"resource:core/bootstrap/stage2.factor"
dup resource-exists? [
dup exists? [
[ run-file ]
[
:c

View File

@ -20,9 +20,6 @@ ARTICLE: "pathnames" "Pathname manipulation"
{ $subsection file-name }
{ $subsection last-path-separator }
{ $subsection append-path }
"Pathnames relative to Factor's install directory:"
{ $subsection resource-path }
{ $subsection ?resource-path }
"Pathnames relative to Factor's temporary files directory:"
{ $subsection temp-directory }
{ $subsection temp-file }
@ -248,12 +245,6 @@ HELP: resource-path
{ $values { "path" "a pathname string" } { "newpath" "a pathname string" } }
{ $description "Resolve a path relative to the Factor source code location. This first checks if the " { $link resource-path } " variable is set to a path, and if not, uses the parent directory of the current image." } ;
HELP: ?resource-path
{ $values { "path" "a pathname string" } { "newpath" "a string" } }
{ $description "If the path is prefixed with " { $snippet "\"resource:\"" } ", prepends the resource path." } ;
{ resource-path ?resource-path } related-words
HELP: pathname
{ $class-description "Class of pathname presentations. Path name presentations can be created by calling " { $link <pathname> } ". Instances can be passed to " { $link write-object } " to output a clickable pathname." } ;

View File

@ -205,3 +205,7 @@ io.encodings.utf8 ;
[ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test
[ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test
[ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test
[ t ] [ "resource:core" absolute-path? ] unit-test
[ t ] [ "/foo" absolute-path? ] unit-test
[ f ] [ "" absolute-path? ] unit-test

View File

@ -99,7 +99,12 @@ ERROR: no-parent-directory path ;
PRIVATE>
: absolute-path? ( path -- ? )
dup empty? [ drop f ] [ first path-separator? ] if ;
{
{ [ dup empty? ] [ f ] }
{ [ dup "resource:" head? ] [ t ] }
{ [ dup first path-separator? ] [ t ] }
{ [ t ] [ f ] }
} cond nip ;
: append-path ( str1 str2 -- str )
{
@ -258,12 +263,6 @@ DEFER: copy-tree-into
"resource-path" get [ image parent-directory ] unless*
prepend-path ;
: ?resource-path ( path -- newpath )
"resource:" ?head [ left-trim-separators resource-path ] when ;
: resource-exists? ( path -- ? )
?resource-path exists? ;
: temp-directory ( -- path )
"temp" resource-path
dup exists? not
@ -273,7 +272,12 @@ DEFER: copy-tree-into
: temp-file ( name -- path ) temp-directory prepend-path ;
M: object normalize-pathname ( path -- path' )
current-directory get prepend-path ;
"resource:" ?head [
left-trim-separators resource-path
normalize-pathname
] [
current-directory get prepend-path
] if ;
! Pathname presentations
TUPLE: pathname string ;

View File

@ -520,7 +520,7 @@ SYMBOL: interactive-vocabs
[
[
[ parsing-file ] keep
[ ?resource-path utf8 <file-reader> ] keep
[ utf8 <file-reader> ] keep
parse-stream
] with-compiler-errors
] [
@ -532,7 +532,7 @@ SYMBOL: interactive-vocabs
[ dup parse-file call ] assert-depth drop ;
: ?run-file ( path -- )
dup resource-exists? [ run-file ] [ drop ] if ;
dup exists? [ run-file ] [ drop ] if ;
: bootstrap-file ( path -- )
[ parse-file % ] [ run-file ] if-bootstrapping ;

View File

@ -48,7 +48,7 @@ uses definitions ;
: reset-checksums ( -- )
source-files get [
swap ?resource-path dup exists? [
swap dup exists? [
utf8 file-lines swap record-checksum
] [ 2drop ] if
] assoc-each ;

View File

@ -25,7 +25,7 @@ V{
: vocab-dir? ( root name -- ? )
over [
".factor" vocab-dir+ append-path resource-exists?
".factor" vocab-dir+ append-path exists?
] [
2drop f
] if ;

View File

@ -26,7 +26,7 @@ SYMBOL: edit-hook
: edit-location ( file line -- )
edit-hook get [
>r >r ?resource-path r> r> call
call
] [
no-edit-hook edit-location
] if* ;
@ -39,7 +39,7 @@ SYMBOL: edit-hook
: :edit ( -- )
error get delegates [ parse-error? ] find-last nip [
dup parse-error-file source-file-path ?resource-path
dup parse-error-file source-file-path
swap parse-error-line edit-location
] when* ;

View File

@ -9,7 +9,7 @@ IN: http.server.templating.fhtml.tests
[
".fhtml" append [ run-template ] with-string-writer
] keep
".html" append ?resource-path utf8 file-contents = ;
".html" append utf8 file-contents = ;
[ t ] [ "example" test-template ] unit-test
[ t ] [ "bug" test-template ] unit-test

View File

@ -83,7 +83,7 @@ DEFER: <% delimiter
templating-vocab use+
! so that reload works properly
dup source-file file set
?resource-path utf8 file-contents
utf8 file-contents
[ eval-template ] [ html-error. drop ] recover
] with-file-vocabs
] assert-depth ;

View File

@ -31,7 +31,7 @@ IN: project-euler
: solution-path ( n -- str/f )
number>euler "project-euler." prepend
vocab where dup [ first ?resource-path ] when ;
vocab where dup [ first ] when ;
PRIVATE>

View File

@ -3,6 +3,6 @@ USING: io.encodings.ascii io.files kernel ;
: deploy-test-3
"resource:extra/tools/deploy/test/3/3.factor"
?resource-path ascii file-contents drop ;
ascii file-contents drop ;
MAIN: deploy-test-3

View File

@ -8,12 +8,12 @@ IN: tools.vocabs
: vocab-tests-file ( vocab -- path )
dup "-tests.factor" vocab-dir+ vocab-append-path dup
[ dup resource-exists? [ drop f ] unless ] [ drop f ] if ;
[ dup exists? [ drop f ] unless ] [ drop f ] if ;
: vocab-tests-dir ( vocab -- paths )
dup vocab-dir "tests" append-path vocab-append-path dup [
dup resource-exists? [
dup ?resource-path directory keys
dup exists? [
dup directory keys
[ ".factor" tail? ] subset
[ append-path ] with map
] [ drop f ] if
@ -34,7 +34,7 @@ IN: tools.vocabs
: source-modified? ( path -- ? )
dup source-files get at [
dup source-file-path ?resource-path
dup source-file-path
dup exists? [
utf8 file-lines lines-crc32
swap source-file-checksum = not
@ -42,7 +42,7 @@ IN: tools.vocabs
2drop f
] if
] [
resource-exists?
exists?
] ?if ;
: modified ( seq quot -- seq )
@ -104,15 +104,14 @@ SYMBOL: sources-changed?
"" refresh f sources-changed? set-global ;
MEMO: (vocab-file-contents) ( path -- lines )
?resource-path dup exists?
[ utf8 file-lines ] [ drop f ] if ;
dup exists? [ utf8 file-lines ] [ drop f ] if ;
: vocab-file-contents ( vocab name -- seq )
vocab-append-path dup [ (vocab-file-contents) ] when ;
: set-vocab-file-contents ( seq vocab name -- )
dupd vocab-append-path [
?resource-path utf8 set-file-lines
utf8 set-file-lines
\ (vocab-file-contents) reset-memoized
] [
"The " swap vocab-name
@ -171,7 +170,7 @@ M: vocab-link summary vocab-summary ;
directory [ second ] subset keys natural-sort ;
: (all-child-vocabs) ( root name -- vocabs )
[ vocab-dir append-path ?resource-path subdirs ] keep
[ vocab-dir append-path subdirs ] keep
dup empty? [
drop
] [

View File

@ -62,7 +62,7 @@ M: freetype-renderer free-fonts ( world -- )
} at ;
: ttf-path ( name -- string )
"resource:fonts/" swap ".ttf" 3append ?resource-path ;
"resource:fonts/" swap ".ttf" 3append ;
: (open-face) ( path length -- face )
#! We use FT_New_Memory_Face, not FT_New_Face, since