From: Doug Coleman Date: Tue, 24 Sep 2013 20:13:39 +0000 (-0700) Subject: io.directories: Add with-resource-directory word and use it. X-Git-Tag: 0.97~1084 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=e407981e12f16dbd2217548c89d30a896658b872 io.directories: Add with-resource-directory word and use it. --- diff --git a/basis/io/directories/directories.factor b/basis/io/directories/directories.factor index eb656be6b4..91401515f5 100644 --- a/basis/io/directories/directories.factor +++ b/basis/io/directories/directories.factor @@ -11,6 +11,9 @@ IN: io.directories : with-directory ( path quot -- ) [ absolute-path current-directory ] dip with-variable ; inline +: with-resource-directory ( quot -- ) + [ "resource:" ] dip with-directory ; inline + ! Creating directories HOOK: make-directory io-backend ( path -- ) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index ab35070ac6..6b06dd0c08 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -74,7 +74,7 @@ IN: tools.deploy.macosx [ % "/Contents/Resources/" % % ".image" % ] "" make ; : deploy-app-bundle ( vocab -- ) - "resource:" [ + [ dup deploy-config [ bundle-name dup exists? [ delete-tree ] [ drop ] if [ bundle-name create-app-dir ] keep @@ -85,7 +85,7 @@ IN: tools.deploy.macosx [ "Contents/Frameworks" copy-libraries ] 2bi bundle-name show-in-finder ] with-variables - ] with-directory ; + ] with-resource-directory ; : deploy-app-bundle? ( vocab -- ? ) deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ; diff --git a/basis/tools/deploy/test/test.factor b/basis/tools/deploy/test/test.factor index b04abe7d7e..db016f15c3 100644 --- a/basis/tools/deploy/test/test.factor +++ b/basis/tools/deploy/test/test.factor @@ -9,10 +9,10 @@ IN: tools.deploy.test : shake-and-bake ( vocab -- ) [ test-image temp-file delete-file ] ignore-errors - "resource:" [ + [ [ vm test-image temp-file ] dip dup deploy-config make-deploy-image drop - ] with-directory ; + ] with-resource-directory ; ERROR: image-too-big actual-size max-size ; diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index 0b4b58ee66..7b3ffb05a0 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -14,7 +14,7 @@ IN: tools.deploy.unix deploy-name get ; M: unix deploy* ( vocab -- ) - "resource:" [ + [ dup deploy-config [ [ bundle-name create-app-dir ] keep [ deployed-image-name ] keep @@ -23,4 +23,4 @@ M: unix deploy* ( vocab -- ) bundle-name normalize-path "Binary deployed to " "." surround print bundle-name webbrowser:open-file ] with-variables - ] with-directory ; + ] with-resource-directory ; diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index 8de593c1fb..31b7f9fde2 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -29,7 +29,7 @@ CONSTANT: app-icon-resource-id "APPICON" [ 2drop ] if ; M: windows deploy* - "resource:" [ + [ dup deploy-config [ deploy-name get { @@ -41,4 +41,4 @@ M: windows deploy* [ nip open-in-explorer ] } 2cleave ] with-variables - ] with-directory ; + ] with-resource-directory ; diff --git a/extra/mason/release/tidy/tidy-tests.factor b/extra/mason/release/tidy/tidy-tests.factor index 01475f026b..76d0e0ed19 100644 --- a/extra/mason/release/tidy/tidy-tests.factor +++ b/extra/mason/release/tidy/tidy-tests.factor @@ -6,7 +6,7 @@ IN: mason.release.tidy.tests ! of the build directory, and they look for a file named ! build-support/cleanup there. Use with-directory here to ! ensure we use the file from the current source tree instead. -"resource:" [ +[ [ f ] [ macosx target-os [ "Factor.app" useless-files member? @@ -18,4 +18,4 @@ IN: mason.release.tidy.tests "Factor.app" useless-files member? ] with-variable ] unit-test -] with-directory +] with-resource-directory diff --git a/extra/webapps/calculator/calculator.factor b/extra/webapps/calculator/calculator.factor index 95f48109b1..b1ffb0bf90 100644 --- a/extra/webapps/calculator/calculator.factor +++ b/extra/webapps/calculator/calculator.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: furnace furnace.actions furnace.redirection http.server.dispatchers html.forms validators urls accessors -math kernel ; +math kernel io.directories ; IN: webapps.calculator TUPLE: calculator < dispatcher ; @@ -36,9 +36,11 @@ USING: db.sqlite furnace.alloy namespaces http.server ; : calculator-db ( -- db ) "calculator.db" ; : run-calculator ( -- ) - - calculator-db - main-responder set-global - 8080 httpd drop ; + [ + + calculator-db + main-responder set-global + 8080 httpd drop + ] with-resource-directory ; MAIN: run-calculator