Change how resource-path works

slava 2006-03-28 03:20:42 +00:00
parent 7786c11eb2
commit 0568d50415
3 changed files with 27 additions and 11 deletions

View File

@ -63,9 +63,6 @@ xref-articles
0 exit
] set-boot
"Setting the resource path..." print
cwd "resource-path" set-global
[ compiled? ] word-subset length
number>string write " compiled words" print

View File

@ -15,11 +15,26 @@ sequences-internals strings vectors words ;
M: object like drop ;
: index ( obj seq -- n ) [ = ] find-with drop ; flushable
: index* ( obj i seq -- n ) [ = ] find-with* drop ; flushable
: member? ( obj seq -- ? ) [ = ] contains-with? ; flushable
: memq? ( obj seq -- ? ) [ eq? ] contains-with? ; flushable
: remove ( obj list -- list ) [ = not ] subset-with ; flushable
: index ( obj seq -- n )
[ = ] find-with drop ; flushable
: index* ( obj i seq -- n )
[ = ] find-with* drop ; flushable
: last-index ( obj seq -- n )
[ = ] find-last-with drop ; flushable
: last-index* ( obj i seq -- n )
[ = ] find-last-with* drop ; flushable
: member? ( obj seq -- ? )
[ = ] contains-with? ; flushable
: memq? ( obj seq -- ? )
[ eq? ] contains-with? ; flushable
: remove ( obj list -- list )
[ = not ] subset-with ; flushable
: (subst) ( newseq oldseq elt -- new/elt )
[ swap index ] keep

View File

@ -1,8 +1,8 @@
! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: io
USING: hashtables kernel lists math namespaces sequences strings
styles ;
USING: hashtables kernel lists math memory namespaces sequences
strings styles ;
! Words for accessing filesystem meta-data.
@ -19,8 +19,12 @@ styles ;
: file-length ( file -- length ) stat third ;
: parent-dir ( path -- path )
CHAR: / over last-index CHAR: \\ pick last-index max
dup -1 = [ 2drop "." ] [ swap head ] if ;
: resource-path ( path -- path )
"resource-path" get [ "." ] unless* swap path+ ;
image parent-dir swap path+ ;
: <resource-stream> ( path -- stream )
#! Open a file path relative to the Factor source code root.