io.directories: Add with-resource-directory word and use it.

db4
Doug Coleman 2013-09-24 13:13:39 -07:00
parent 37f5f4b9de
commit e407981e12
7 changed files with 20 additions and 15 deletions

View File

@ -11,6 +11,9 @@ IN: io.directories
: with-directory ( path quot -- ) : with-directory ( path quot -- )
[ absolute-path current-directory ] dip with-variable ; inline [ absolute-path current-directory ] dip with-variable ; inline
: with-resource-directory ( quot -- )
[ "resource:" ] dip with-directory ; inline
! Creating directories ! Creating directories
HOOK: make-directory io-backend ( path -- ) HOOK: make-directory io-backend ( path -- )

View File

@ -74,7 +74,7 @@ IN: tools.deploy.macosx
[ % "/Contents/Resources/" % % ".image" % ] "" make ; [ % "/Contents/Resources/" % % ".image" % ] "" make ;
: deploy-app-bundle ( vocab -- ) : deploy-app-bundle ( vocab -- )
"resource:" [ [
dup deploy-config [ dup deploy-config [
bundle-name dup exists? [ delete-tree ] [ drop ] if bundle-name dup exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep [ bundle-name create-app-dir ] keep
@ -85,7 +85,7 @@ IN: tools.deploy.macosx
[ "Contents/Frameworks" copy-libraries ] 2bi [ "Contents/Frameworks" copy-libraries ] 2bi
bundle-name show-in-finder bundle-name show-in-finder
] with-variables ] with-variables
] with-directory ; ] with-resource-directory ;
: deploy-app-bundle? ( vocab -- ? ) : deploy-app-bundle? ( vocab -- ? )
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ; deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;

View File

@ -9,10 +9,10 @@ IN: tools.deploy.test
: shake-and-bake ( vocab -- ) : shake-and-bake ( vocab -- )
[ test-image temp-file delete-file ] ignore-errors [ test-image temp-file delete-file ] ignore-errors
"resource:" [ [
[ vm test-image temp-file ] dip [ vm test-image temp-file ] dip
dup deploy-config make-deploy-image drop dup deploy-config make-deploy-image drop
] with-directory ; ] with-resource-directory ;
ERROR: image-too-big actual-size max-size ; ERROR: image-too-big actual-size max-size ;

View File

@ -14,7 +14,7 @@ IN: tools.deploy.unix
deploy-name get ; deploy-name get ;
M: unix deploy* ( vocab -- ) M: unix deploy* ( vocab -- )
"resource:" [ [
dup deploy-config [ dup deploy-config [
[ bundle-name create-app-dir ] keep [ bundle-name create-app-dir ] keep
[ deployed-image-name ] keep [ deployed-image-name ] keep
@ -23,4 +23,4 @@ M: unix deploy* ( vocab -- )
bundle-name normalize-path "Binary deployed to " "." surround print bundle-name normalize-path "Binary deployed to " "." surround print
bundle-name webbrowser:open-file bundle-name webbrowser:open-file
] with-variables ] with-variables
] with-directory ; ] with-resource-directory ;

View File

@ -29,7 +29,7 @@ CONSTANT: app-icon-resource-id "APPICON"
[ 2drop ] if ; [ 2drop ] if ;
M: windows deploy* M: windows deploy*
"resource:" [ [
dup deploy-config [ dup deploy-config [
deploy-name get deploy-name get
{ {
@ -41,4 +41,4 @@ M: windows deploy*
[ nip open-in-explorer ] [ nip open-in-explorer ]
} 2cleave } 2cleave
] with-variables ] with-variables
] with-directory ; ] with-resource-directory ;

View File

@ -6,7 +6,7 @@ IN: mason.release.tidy.tests
! of the build directory, and they look for a file named ! of the build directory, and they look for a file named
! build-support/cleanup there. Use with-directory here to ! build-support/cleanup there. Use with-directory here to
! ensure we use the file from the current source tree instead. ! ensure we use the file from the current source tree instead.
"resource:" [ [
[ f ] [ [ f ] [
macosx target-os [ macosx target-os [
"Factor.app" useless-files member? "Factor.app" useless-files member?
@ -18,4 +18,4 @@ IN: mason.release.tidy.tests
"Factor.app" useless-files member? "Factor.app" useless-files member?
] with-variable ] with-variable
] unit-test ] unit-test
] with-directory ] with-resource-directory

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: furnace furnace.actions furnace.redirection USING: furnace furnace.actions furnace.redirection
http.server.dispatchers html.forms validators urls accessors http.server.dispatchers html.forms validators urls accessors
math kernel ; math kernel io.directories ;
IN: webapps.calculator IN: webapps.calculator
TUPLE: calculator < dispatcher ; TUPLE: calculator < dispatcher ;
@ -36,9 +36,11 @@ USING: db.sqlite furnace.alloy namespaces http.server ;
: calculator-db ( -- db ) "calculator.db" <sqlite-db> ; : calculator-db ( -- db ) "calculator.db" <sqlite-db> ;
: run-calculator ( -- ) : run-calculator ( -- )
[
<calculator> <calculator>
calculator-db <alloy> calculator-db <alloy>
main-responder set-global main-responder set-global
8080 httpd drop ; 8080 httpd drop
] with-resource-directory ;
MAIN: run-calculator MAIN: run-calculator