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 -- )
[ 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 -- )

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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

View File

@ -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" <sqlite-db> ;
: run-calculator ( -- )
<calculator>
calculator-db <alloy>
main-responder set-global
8080 httpd drop ;
[
<calculator>
calculator-db <alloy>
main-responder set-global
8080 httpd drop
] with-resource-directory ;
MAIN: run-calculator