home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ISV Strong Games
/
ISV_STRONG_GAMES.iso
/
arcade
/
rhft
/
Docs
/
!StrongHlp
/
Utilities
/
CleanCopy
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1995-05-25
|
4KB
|
172 lines
>CleanCopy
We dummy-define these variables so that PROC_Error will know them
if we should crash before they are actually defined
del% =
A$ = ""
B$ = ""
_Error
wrk% 255, wrk2% 255
"Hourglass_On"
Find parameters
"OS_GetEnv"
env$
A$ =
_GetArg(env$,2)
B$ =
_GetArg(env$,3)
PRINT "env = ";env$
PRINT "A = ";A$
PRINT "B = ";B$
A$ = ""
-1,"Needs Manual name"
B$ = ""
.
First test whether Wimp$Scrap exists
8
"XOS_ReadVarVal","Wimp$Scrap",,-1,0,0
,,R2%
1
R2%>=0
0,"Wimp$Scrap isn't defined"
"#
Remove any old Wimp$Scrap
#,
"OS_File",17,"<Wimp$Scrap>"
$,
R0% <> 0
"Delete <Wimp$Scrap>"
B$ = A$
A$ = "<Wimp$Scrap>"
"Rename "+B$+" "+A$
del% =
del% =
We create the new "Manual"
A% =
_DirSize(A$)
"StrongCreate "+B$+" "+
Now recursively copy everything
_CopyDir(A$,B$)
If we used Wimp$Scrap, we now delete it.
del%
"Delete "+A$
Force Close of new version
(So that we don't have to quit !StrongHelp (which closes all) to be safe)
"Rename "+B$+" "+B$
"Hourglass_Off"
_CopyDir(From$,To$)
offset%,read%,x%,A%,F$,T$,S%,strlen%
offset% = 0
LG
"OS_GBPB",10,From$,wrk%,1,offset%,255,"*"
,,,read%,offset%
read% > 0
x% = wrk%
A% = 1
read%
P% strlen% =
_StrLen(x%+20)
Q! ?(x%+20+strlen%) = 13
S' F$ = From$ + "." + $(x%+20)
T' T$ = To$ + "." + $(x%+20)
x%!16
V&
1 :
PRINT "Copy ";F$
W3
"OS_FSControl",26,F$,T$,0
X&
2 : S% =
_DirSize(F$)
Y.
PRINT "Create ";T$,S%
Z,
"Cdir "+T$+" "+
['
_CopyDir(F$,T$)
^- x% += ((strlen%+4)
3) + 20
`
offset% = -1
_DirSize(dir$)
tot%,offset%,strlen%,A%,x%
This routine calculates the size of all the entries in a directory,
and all heading info for the dir.
The size of heading info is
4 (offset into dir of 1st unused pos)
The size of one entry is
24 (offset in image, load, exec, size, flags, compressed size)
+ word aligned length of name (incl \0)
(The 'compressed size' is there for possible future use)
tot% = 4
offset% = 0
uI
"OS_GBPB",10,dir$,wrk2%,255,offset%,255,"*"
,,,read%,offset%
read% > 0
x% = wrk2%
A% = 1
read%
y2 strlen% = (
_StrLen(x%+20) + 4 )
z" tot% += strlen% + 24
{" x% += strlen% + 20
}
offset% = -1
= tot%
_StrLen(A%)
L% = A%
?A% >= 32
A% += 1
= A% - L%
_GetArg(arg$,no%)
a%,b%,x%
Find start of the given part
a% = 1
x% = 0
a% =
arg$," ",a%)
a% = 0
= ""
a% += 1
arg$,a%,1) = " ")
a% += 1
1
arg$,a%,1) = "-"
arg$,a%,1) = "@"
no% +=1
x% += 1
x% >= no%
Find end of the given part
b% =
arg$," ",a%)
b% = 0
=
arg$,a%)
=
arg$,a%,b%-a%)
_Error
"Hourglass_Off"
If we have renamed original file to Wimp$Scrap, then we should move
it back..
del%
.
1st delete new file (if it exists..)
"OS_File",17,B$
#
R0% <> 0
"Delete "+B$
!
Move original file back
"Rename "+A$+" "+B$
$;" at ";