[gforth] / gforth / fixpath.fs  

gforth: gforth/fixpath.fs


1 : pazsan 1.5 \ fix path in gforth*.exe
2 :    
3 : anton 1.9 \ Copyright (C) 2000,2003,2006 Free Software Foundation, Inc.
4 : pazsan 1.5
5 :     \ This file is part of Gforth.
6 :    
7 :     \ Gforth is free software; you can redistribute it and/or
8 :     \ modify it under the terms of the GNU General Public License
9 :     \ as published by the Free Software Foundation; either version 2
10 :     \ of the License, or (at your option) any later version.
11 :    
12 :     \ This program is distributed in the hope that it will be useful,
13 :     \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     \ GNU General Public License for more details.
16 :    
17 :     \ You should have received a copy of the GNU General Public License
18 :     \ along with this program; if not, write to the Free Software
19 :     \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
20 :    
21 : pazsan 1.8 ." Fixing " 2 arg type ." with " 1 arg type cr
22 : pazsan 1.5
23 : pazsan 1.8 : "search s" .:/usr/local" ;
24 : pazsan 1.5
25 :     include string.fs
26 :    
27 : pazsan 1.8 Variable path$ 1 arg path$ $!
28 :     Variable pathes$ 1 arg pathes$ $!
29 : pazsan 1.5 Variable exe$
30 :    
31 : pazsan 1.8 pathes$ 1 1 $del s" /cygdrive/" pathes$ 0 $ins
32 :     : fixpathes ( addr u -- )
33 :     bounds ?DO I c@ '\ = IF '/ I c! THEN LOOP ;
34 :     pathes$ $@ fixpathes
35 :     s" .:" pathes$ 0 $ins
36 :    
37 :     0 Value #size
38 :     0 Value #file
39 :     : fix-exe ( addr u -- )
40 :     path$ $@ exe$ $! s" /" exe$ $+! exe$ $+!
41 : pazsan 1.5 exe$ $@ r/w bin open-file throw >r
42 : pazsan 1.8 r@ file-size throw drop to #size
43 :     #size allocate throw to #file
44 :     #file #size r@ read-file throw drop
45 :     #file #size "search search 2drop #file -
46 : pazsan 1.5 0 r@ reposition-file throw
47 :     pathes$ $@ 2dup + 0 swap c! 1+ r@ write-file throw
48 :     r> close-file throw ;
49 :    
50 : pazsan 1.8 2 arg fix-exe
51 : pazsan 1.5
52 :     bye

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help