Home » Archimedes archive » Acorn User » AU 1997-03 B.adf » Extras » PD/!StrongHlp/Utilities/CleanCopy

PD/!StrongHlp/Utilities/CleanCopy

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1997-03 B.adf » Extras
Filename: PD/!StrongHlp/Utilities/CleanCopy
Read OK:
File size: 0FB0 bytes
Load address: 0000
Exec address: 0000
File contents
    1REM  >CleanCopy
    2  
    3  REM We dummy-define these variables so that PROC_Error will know them
    4  REM if we should crash before they are actually defined
    5
    6  del% = FALSE
    7  A$   = ""
    8  B$   = ""
    9
   10  ON ERROR PROC_Error
   11
   12  DIM wrk% 255, wrk2% 255
   13
   14  SYS "Hourglass_On"
   15
   16  REM Find parameters
   17
   18  SYS "OS_GetEnv" TO env$
   19
   20  A$ = FN_GetArg(env$,2)
   21  B$ = FN_GetArg(env$,3)
   22
   23REM PRINT "env = ";env$
   24REM PRINT "A = ";A$
   25REM PRINT "B = ";B$
   26
   27  IF A$ = "" THEN ERROR -1,"Needs Manual name"
   28  IF B$ = "" THEN
   29
   30    REM First test whether Wimp$Scrap exists
   31    SYS "XOS_ReadVarVal","Wimp$Scrap",,-1,0,0 TO ,,R2%
   32    IF R2%>=0 THEN ERROR 0,"Wimp$Scrap isn't defined"
   33
   34    REM Remove any old Wimp$Scrap
   35    SYS "OS_File",17,"<Wimp$Scrap>" TO R0%
   36    IF R0% <> 0 THEN OSCLI "Delete <Wimp$Scrap>"
   37
   38    B$ = A$
   39    A$ = "<Wimp$Scrap>"
   40    OSCLI "Copy "+B$+" "+A$ +" D~C~V"
   41    del% = TRUE
   42
   43  ELSE
   44    del% = FALSE
   45  ENDIF
   46
   47  REM We create the new "Manual"
   48
   49  A% = FN_DirSize(A$)
   50  OSCLI "StrongCreate "+B$+" "+STR$ A%
   51
   52  REM Now recursively copy everything
   53
   54  PROC_CopyDir(A$,B$)
   55
   56  REM If we used Wimp$Scrap, we now delete it.
   57
   58  IF del% THEN
   59    OSCLI "Delete "+A$
   60  ENDIF
   61
   62  REM Force Close of new version
   63  REM (So that we don't have to quit !StrongHelp (which closes all) to be safe)
   64
   65  OSCLI "Rename "+B$+" "+B$
   66
   67  SYS "Hourglass_Off"
   68
   69END
   70
   71
   72DEF PROC_CopyDir(From$,To$)
   73LOCAL offset%,read%,x%,A%,F$,T$,S%,strlen%
   74  offset% = 0
   75  REPEAT
   76    SYS "OS_GBPB",10,From$,wrk%,1,offset%,255,"*" TO ,,,read%,offset%
   77    IF read% > 0 THEN
   78      x% = wrk%
   79      FOR A% = 1 TO read%
   80        strlen% = FN_StrLen(x%+20)
   81        ?(x%+20+strlen%) = 13
   82
   83        F$ = From$ + "." + $(x%+20)
   84        T$ = To$   + "." + $(x%+20)
   85        CASE x%!16 OF
   86          WHEN 1 : REM PRINT "Copy ";F$
   87                   SYS "OS_FSControl",26,F$,T$,0
   88          WHEN 2 : S% = FN_DirSize(F$)
   89                   REM PRINT "Create ";T$,S%
   90                   OSCLI "Cdir "+T$+" "+STR$ S%
   91                   PROC_CopyDir(F$,T$)
   92        ENDCASE
   93
   94        x%     += ((strlen%+4) ANDNOT 3) + 20
   95      NEXT
   96    ENDIF
   97  UNTIL offset% = -1
   98
   99ENDPROC
  100
  101DEF FN_DirSize(dir$)
  102LOCAL tot%,offset%,strlen%,A%,x%
  103
  104  REM This routine calculates the size of all the entries in a directory,
  105  REM and all heading info for the dir.
  106  REM The size of heading info is
  107  REM    4 (offset into dir of 1st unused pos)
  108  REM The size of one entry is
  109  REM   24 (offset in image, load, exec, size, flags, compressed size)
  110  REM + word aligned length of name (incl \0)
  111
  112  REM (The 'compressed size' is there for possible future use)
  113
  114  tot% = 4
  115  offset% = 0
  116  REPEAT
  117    SYS "OS_GBPB",10,dir$,wrk2%,255,offset%,255,"*" TO ,,,read%,offset%
  118    IF read% > 0 THEN
  119      x% = wrk2%
  120      FOR A% = 1 TO read%
  121        strlen% = ( FN_StrLen(x%+20) + 4 ) ANDNOT 3
  122        tot%   += strlen% + 24
  123        x%     += strlen% + 20
  124      NEXT
  125    ENDIF
  126  UNTIL offset% = -1
  127= tot%
  128
  129DEF FN_StrLen(A%)
  130LOCAL L%
  131  L% = A%
  132  WHILE ?A% >= 32
  133    A% += 1
  134  ENDWHILE
  135= A% - L%
  136
  137DEF FN_GetArg(arg$,no%)
  138LOCAL a%,b%,x%
  139
  140  REM Find start of the given part
  141  a% = 1
  142  x% = 0
  143  REPEAT
  144    a% = INSTR(arg$," ",a%)
  145    IF a% = 0 THEN
  146      = ""
  147    ENDIF
  148    a% += 1
  149    WHILE (MID$(arg$,a%,1) = " ")
  150      a% += 1
  151    ENDWHILE
  152
  153    IF MID$(arg$,a%,1) = "-" OR MID$(arg$,a%,1) = "@" THEN
  154      no% +=1
  155    ENDIF
  156
  157    x% += 1
  158  UNTIL x% >= no%
  159
  160  REM Find end of the given part
  161
  162  b% = INSTR(arg$," ",a%)
  163  IF b% = 0 THEN
  164    = MID$(arg$,a%)
  165  ELSE
  166    = MID$(arg$,a%,b%-a%)
  167  ENDIF
  168= 0
  169
  170DEF PROC_Error
  171  ON ERROR OFF
  172  SYS "Hourglass_Off"
  173
  174  REM If we have renamed original file to Wimp$Scrap, then we should move
  175  REM it back..
  176
  177  IF del% THEN
  178
  179    REM 1st delete new file (if it exists..)
  180    SYS "OS_File",17,B$ TO R0%
  181    IF R0% <> 0 THEN OSCLI "Delete "+B$
  182
  183    REM Move original file back
  184    OSCLI "Rename "+A$+" "+B$
  185
  186  ENDIF
  187
  188  PRINT REPORT$;" at ";ERL
  189  END
  190ENDPROC
�  >CleanCopy
  
I  � 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%
$,    � R0% <> 0 � � "Delete <Wimp$Scrap>"
%
&    B$ = A$
'    A$ = "<Wimp$Scrap>"
(%    � "Copy "+B$+" "+A$ +" D~C~V"
)    del% = �
*
+  �
,    del% = �
-  �
.
/"  � We create the new "Manual"
0
1  A% = �_DirSize(A$)
2#  � "StrongCreate "+B$+" "+� A%
3
4'  � Now recursively copy everything
5
6  �_CopyDir(A$,B$)
7
80  � If we used Wimp$Scrap, we now delete it.
9
:  � del% �
;    � "Delete "+A$
<  �
=
>"  � Force Close of new version
?Q  � (So that we don't have to quit !StrongHelp (which closes all) to be safe)
@
A  � "Rename "+B$+" "+B$
B
C  ș "Hourglass_Off"
D
E�
F
G
H� �_CopyDir(From$,To$)
I*� offset%,read%,x%,A%,F$,T$,S%,strlen%
J  offset% = 0
K  �
LG    ș "OS_GBPB",10,From$,wrk%,1,offset%,255,"*" � ,,,read%,offset%
M    � read% > 0 �
N      x% = wrk%
O      � A% = 1 � read%
P%        strlen% = �_StrLen(x%+20)
Q!        ?(x%+20+strlen%) = 13
R
S'        F$ = From$ + "." + $(x%+20)
T'        T$ = To$   + "." + $(x%+20)
U        Ȏ 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$+" "+� S%
['                   �_CopyDir(F$,T$)
\
        �
]
^-        x%     += ((strlen%+4) �� 3) + 20
_      �
`	    �
a  � offset% = -1
b
c�
d
e� �_DirSize(dir$)
f � tot%,offset%,strlen%,A%,x%
g
hK  � This routine calculates the size of all the entries in a directory,
i)  � and all heading info for the dir.
j#  � The size of heading info is
k0  �    4 (offset into dir of 1st unused pos)
l   � The size of one entry is
mH  �   24 (offset in image, load, exec, size, flags, compressed size)
n/  � + word aligned length of name (incl \0)
o
p@  � (The 'compressed size' is there for possible future use)
q
r  tot% = 4
s  offset% = 0
t  �
uI    ș "OS_GBPB",10,dir$,wrk2%,255,offset%,255,"*" � ,,,read%,offset%
v    � read% > 0 �
w      x% = wrk2%
x      � A% = 1 � read%
y2        strlen% = ( �_StrLen(x%+20) + 4 ) �� 3
z"        tot%   += strlen% + 24
{"        x%     += strlen% + 20
|      �
}	    �
~  � offset% = -1

= tot%
�
�� �_StrLen(A%)
�� L%
�
  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%)
�  �
�= 0
�
�
� �_Error
�  � � �
�  ș "Hourglass_Off"
�
�K  � 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%
�#    � R0% <> 0 � � "Delete "+B$
�
�!    � Move original file back
�    � "Rename "+A$+" "+B$
�
�  �
�
�  � �$;" at ";�
�  �
��
�
00000000  0d 00 01 11 f4 20 20 3e  43 6c 65 61 6e 43 6f 70  |.....  >CleanCop|
00000010  79 0d 00 02 06 20 20 0d  00 03 49 20 20 f4 20 57  |y....  ...I  . W|
00000020  65 20 64 75 6d 6d 79 2d  64 65 66 69 6e 65 20 74  |e dummy-define t|
00000030  68 65 73 65 20 76 61 72  69 61 62 6c 65 73 20 73  |hese variables s|
00000040  6f 20 74 68 61 74 20 50  52 4f 43 5f 45 72 72 6f  |o that PROC_Erro|
00000050  72 20 77 69 6c 6c 20 6b  6e 6f 77 20 74 68 65 6d  |r will know them|
00000060  0d 00 04 3b 20 20 f4 20  69 66 20 77 65 20 73 68  |...;  . if we sh|
00000070  6f 75 6c 64 20 63 72 61  73 68 20 62 65 66 6f 72  |ould crash befor|
00000080  65 20 74 68 65 79 20 61  72 65 20 61 63 74 75 61  |e they are actua|
00000090  6c 6c 79 20 64 65 66 69  6e 65 64 0d 00 05 04 0d  |lly defined.....|
000000a0  00 06 0e 20 20 64 65 6c  25 20 3d 20 a3 0d 00 07  |...  del% = ....|
000000b0  0f 20 20 41 24 20 20 20  3d 20 22 22 0d 00 08 0f  |.  A$   = ""....|
000000c0  20 20 42 24 20 20 20 3d  20 22 22 0d 00 09 04 0d  |  B$   = "".....|
000000d0  00 0a 11 20 20 ee 20 85  20 f2 5f 45 72 72 6f 72  |...  . . ._Error|
000000e0  0d 00 0b 04 0d 00 0c 1b  20 20 de 20 77 72 6b 25  |........  . wrk%|
000000f0  20 32 35 35 2c 20 77 72  6b 32 25 20 32 35 35 0d  | 255, wrk2% 255.|
00000100  00 0d 04 0d 00 0e 17 20  20 c8 99 20 22 48 6f 75  |.......  .. "Hou|
00000110  72 67 6c 61 73 73 5f 4f  6e 22 0d 00 0f 04 0d 00  |rglass_On"......|
00000120  10 17 20 20 f4 20 46 69  6e 64 20 70 61 72 61 6d  |..  . Find param|
00000130  65 74 65 72 73 0d 00 11  04 0d 00 12 1b 20 20 c8  |eters........  .|
00000140  99 20 22 4f 53 5f 47 65  74 45 6e 76 22 20 b8 20  |. "OS_GetEnv" . |
00000150  65 6e 76 24 0d 00 13 04  0d 00 14 1b 20 20 41 24  |env$........  A$|
00000160  20 3d 20 a4 5f 47 65 74  41 72 67 28 65 6e 76 24  | = ._GetArg(env$|
00000170  2c 32 29 0d 00 15 1b 20  20 42 24 20 3d 20 a4 5f  |,2)....  B$ = ._|
00000180  47 65 74 41 72 67 28 65  6e 76 24 2c 33 29 0d 00  |GetArg(env$,3)..|
00000190  16 04 0d 00 17 19 f4 20  50 52 49 4e 54 20 22 65  |....... PRINT "e|
000001a0  6e 76 20 3d 20 22 3b 65  6e 76 24 0d 00 18 15 f4  |nv = ";env$.....|
000001b0  20 50 52 49 4e 54 20 22  41 20 3d 20 22 3b 41 24  | PRINT "A = ";A$|
000001c0  0d 00 19 15 f4 20 50 52  49 4e 54 20 22 42 20 3d  |..... PRINT "B =|
000001d0  20 22 3b 42 24 0d 00 1a  04 0d 00 1b 2a 20 20 e7  | ";B$.......*  .|
000001e0  20 41 24 20 3d 20 22 22  20 8c 20 85 20 2d 31 2c  | A$ = "" . . -1,|
000001f0  22 4e 65 65 64 73 20 4d  61 6e 75 61 6c 20 6e 61  |"Needs Manual na|
00000200  6d 65 22 0d 00 1c 11 20  20 e7 20 42 24 20 3d 20  |me"....  . B$ = |
00000210  22 22 20 8c 0d 00 1d 04  0d 00 1e 2e 20 20 20 20  |"" .........    |
00000220  f4 20 46 69 72 73 74 20  74 65 73 74 20 77 68 65  |. First test whe|
00000230  74 68 65 72 20 57 69 6d  70 24 53 63 72 61 70 20  |ther Wimp$Scrap |
00000240  65 78 69 73 74 73 0d 00  1f 38 20 20 20 20 c8 99  |exists...8    ..|
00000250  20 22 58 4f 53 5f 52 65  61 64 56 61 72 56 61 6c  | "XOS_ReadVarVal|
00000260  22 2c 22 57 69 6d 70 24  53 63 72 61 70 22 2c 2c  |","Wimp$Scrap",,|
00000270  2d 31 2c 30 2c 30 20 b8  20 2c 2c 52 32 25 0d 00  |-1,0,0 . ,,R2%..|
00000280  20 31 20 20 20 20 e7 20  52 32 25 3e 3d 30 20 8c  | 1    . R2%>=0 .|
00000290  20 85 20 30 2c 22 57 69  6d 70 24 53 63 72 61 70  | . 0,"Wimp$Scrap|
000002a0  20 69 73 6e 27 74 20 64  65 66 69 6e 65 64 22 0d  | isn't defined".|
000002b0  00 21 04 0d 00 22 23 20  20 20 20 f4 20 52 65 6d  |.!..."#    . Rem|
000002c0  6f 76 65 20 61 6e 79 20  6f 6c 64 20 57 69 6d 70  |ove any old Wimp|
000002d0  24 53 63 72 61 70 0d 00  23 2c 20 20 20 20 c8 99  |$Scrap..#,    ..|
000002e0  20 22 4f 53 5f 46 69 6c  65 22 2c 31 37 2c 22 3c  | "OS_File",17,"<|
000002f0  57 69 6d 70 24 53 63 72  61 70 3e 22 20 b8 20 52  |Wimp$Scrap>" . R|
00000300  30 25 0d 00 24 2c 20 20  20 20 e7 20 52 30 25 20  |0%..$,    . R0% |
00000310  3c 3e 20 30 20 8c 20 ff  20 22 44 65 6c 65 74 65  |<> 0 . . "Delete|
00000320  20 3c 57 69 6d 70 24 53  63 72 61 70 3e 22 0d 00  | <Wimp$Scrap>"..|
00000330  25 04 0d 00 26 0f 20 20  20 20 42 24 20 3d 20 41  |%...&.    B$ = A|
00000340  24 0d 00 27 1b 20 20 20  20 41 24 20 3d 20 22 3c  |$..'.    A$ = "<|
00000350  57 69 6d 70 24 53 63 72  61 70 3e 22 0d 00 28 25  |Wimp$Scrap>"..(%|
00000360  20 20 20 20 ff 20 22 43  6f 70 79 20 22 2b 42 24  |    . "Copy "+B$|
00000370  2b 22 20 22 2b 41 24 20  2b 22 20 44 7e 43 7e 56  |+" "+A$ +" D~C~V|
00000380  22 0d 00 29 10 20 20 20  20 64 65 6c 25 20 3d 20  |"..).    del% = |
00000390  b9 0d 00 2a 04 0d 00 2b  07 20 20 cc 0d 00 2c 10  |...*...+.  ...,.|
000003a0  20 20 20 20 64 65 6c 25  20 3d 20 a3 0d 00 2d 07  |    del% = ...-.|
000003b0  20 20 cd 0d 00 2e 04 0d  00 2f 22 20 20 f4 20 57  |  ......./"  . W|
000003c0  65 20 63 72 65 61 74 65  20 74 68 65 20 6e 65 77  |e create the new|
000003d0  20 22 4d 61 6e 75 61 6c  22 0d 00 30 04 0d 00 31  | "Manual"..0...1|
000003e0  18 20 20 41 25 20 3d 20  a4 5f 44 69 72 53 69 7a  |.  A% = ._DirSiz|
000003f0  65 28 41 24 29 0d 00 32  23 20 20 ff 20 22 53 74  |e(A$)..2#  . "St|
00000400  72 6f 6e 67 43 72 65 61  74 65 20 22 2b 42 24 2b  |rongCreate "+B$+|
00000410  22 20 22 2b c3 20 41 25  0d 00 33 04 0d 00 34 27  |" "+. A%..3...4'|
00000420  20 20 f4 20 4e 6f 77 20  72 65 63 75 72 73 69 76  |  . Now recursiv|
00000430  65 6c 79 20 63 6f 70 79  20 65 76 65 72 79 74 68  |ely copy everyth|
00000440  69 6e 67 0d 00 35 04 0d  00 36 16 20 20 f2 5f 43  |ing..5...6.  ._C|
00000450  6f 70 79 44 69 72 28 41  24 2c 42 24 29 0d 00 37  |opyDir(A$,B$)..7|
00000460  04 0d 00 38 30 20 20 f4  20 49 66 20 77 65 20 75  |...80  . If we u|
00000470  73 65 64 20 57 69 6d 70  24 53 63 72 61 70 2c 20  |sed Wimp$Scrap, |
00000480  77 65 20 6e 6f 77 20 64  65 6c 65 74 65 20 69 74  |we now delete it|
00000490  2e 0d 00 39 04 0d 00 3a  0e 20 20 e7 20 64 65 6c  |...9...:.  . del|
000004a0  25 20 8c 0d 00 3b 16 20  20 20 20 ff 20 22 44 65  |% ...;.    . "De|
000004b0  6c 65 74 65 20 22 2b 41  24 0d 00 3c 07 20 20 cd  |lete "+A$..<.  .|
000004c0  0d 00 3d 04 0d 00 3e 22  20 20 f4 20 46 6f 72 63  |..=...>"  . Forc|
000004d0  65 20 43 6c 6f 73 65 20  6f 66 20 6e 65 77 20 76  |e Close of new v|
000004e0  65 72 73 69 6f 6e 0d 00  3f 51 20 20 f4 20 28 53  |ersion..?Q  . (S|
000004f0  6f 20 74 68 61 74 20 77  65 20 64 6f 6e 27 74 20  |o that we don't |
00000500  68 61 76 65 20 74 6f 20  71 75 69 74 20 21 53 74  |have to quit !St|
00000510  72 6f 6e 67 48 65 6c 70  20 28 77 68 69 63 68 20  |rongHelp (which |
00000520  63 6c 6f 73 65 73 20 61  6c 6c 29 20 74 6f 20 62  |closes all) to b|
00000530  65 20 73 61 66 65 29 0d  00 40 04 0d 00 41 1b 20  |e safe)..@...A. |
00000540  20 ff 20 22 52 65 6e 61  6d 65 20 22 2b 42 24 2b  | . "Rename "+B$+|
00000550  22 20 22 2b 42 24 0d 00  42 04 0d 00 43 18 20 20  |" "+B$..B...C.  |
00000560  c8 99 20 22 48 6f 75 72  67 6c 61 73 73 5f 4f 66  |.. "Hourglass_Of|
00000570  66 22 0d 00 44 04 0d 00  45 05 e0 0d 00 46 04 0d  |f"..D...E....F..|
00000580  00 47 04 0d 00 48 1a dd  20 f2 5f 43 6f 70 79 44  |.G...H.. ._CopyD|
00000590  69 72 28 46 72 6f 6d 24  2c 54 6f 24 29 0d 00 49  |ir(From$,To$)..I|
000005a0  2a ea 20 6f 66 66 73 65  74 25 2c 72 65 61 64 25  |*. offset%,read%|
000005b0  2c 78 25 2c 41 25 2c 46  24 2c 54 24 2c 53 25 2c  |,x%,A%,F$,T$,S%,|
000005c0  73 74 72 6c 65 6e 25 0d  00 4a 11 20 20 6f 66 66  |strlen%..J.  off|
000005d0  73 65 74 25 20 3d 20 30  0d 00 4b 07 20 20 f5 0d  |set% = 0..K.  ..|
000005e0  00 4c 47 20 20 20 20 c8  99 20 22 4f 53 5f 47 42  |.LG    .. "OS_GB|
000005f0  50 42 22 2c 31 30 2c 46  72 6f 6d 24 2c 77 72 6b  |PB",10,From$,wrk|
00000600  25 2c 31 2c 6f 66 66 73  65 74 25 2c 32 35 35 2c  |%,1,offset%,255,|
00000610  22 2a 22 20 b8 20 2c 2c  2c 72 65 61 64 25 2c 6f  |"*" . ,,,read%,o|
00000620  66 66 73 65 74 25 0d 00  4d 15 20 20 20 20 e7 20  |ffset%..M.    . |
00000630  72 65 61 64 25 20 3e 20  30 20 8c 0d 00 4e 13 20  |read% > 0 ...N. |
00000640  20 20 20 20 20 78 25 20  3d 20 77 72 6b 25 0d 00  |     x% = wrk%..|
00000650  4f 1a 20 20 20 20 20 20  e3 20 41 25 20 3d 20 31  |O.      . A% = 1|
00000660  20 b8 20 72 65 61 64 25  0d 00 50 25 20 20 20 20  | . read%..P%    |
00000670  20 20 20 20 73 74 72 6c  65 6e 25 20 3d 20 a4 5f  |    strlen% = ._|
00000680  53 74 72 4c 65 6e 28 78  25 2b 32 30 29 0d 00 51  |StrLen(x%+20)..Q|
00000690  21 20 20 20 20 20 20 20  20 3f 28 78 25 2b 32 30  |!        ?(x%+20|
000006a0  2b 73 74 72 6c 65 6e 25  29 20 3d 20 31 33 0d 00  |+strlen%) = 13..|
000006b0  52 04 0d 00 53 27 20 20  20 20 20 20 20 20 46 24  |R...S'        F$|
000006c0  20 3d 20 46 72 6f 6d 24  20 2b 20 22 2e 22 20 2b  | = From$ + "." +|
000006d0  20 24 28 78 25 2b 32 30  29 0d 00 54 27 20 20 20  | $(x%+20)..T'   |
000006e0  20 20 20 20 20 54 24 20  3d 20 54 6f 24 20 20 20  |     T$ = To$   |
000006f0  2b 20 22 2e 22 20 2b 20  24 28 78 25 2b 32 30 29  |+ "." + $(x%+20)|
00000700  0d 00 55 16 20 20 20 20  20 20 20 20 c8 8e 20 78  |..U.        .. x|
00000710  25 21 31 36 20 ca 0d 00  56 26 20 20 20 20 20 20  |%!16 ...V&      |
00000720  20 20 20 20 c9 20 31 20  3a 20 f4 20 50 52 49 4e  |    . 1 : . PRIN|
00000730  54 20 22 43 6f 70 79 20  22 3b 46 24 0d 00 57 33  |T "Copy ";F$..W3|
00000740  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000750  20 20 20 c8 99 20 22 4f  53 5f 46 53 43 6f 6e 74  |   .. "OS_FSCont|
00000760  72 6f 6c 22 2c 32 36 2c  46 24 2c 54 24 2c 30 0d  |rol",26,F$,T$,0.|
00000770  00 58 26 20 20 20 20 20  20 20 20 20 20 c9 20 32  |.X&          . 2|
00000780  20 3a 20 53 25 20 3d 20  a4 5f 44 69 72 53 69 7a  | : S% = ._DirSiz|
00000790  65 28 46 24 29 0d 00 59  2e 20 20 20 20 20 20 20  |e(F$)..Y.       |
000007a0  20 20 20 20 20 20 20 20  20 20 20 20 f4 20 50 52  |            . PR|
000007b0  49 4e 54 20 22 43 72 65  61 74 65 20 22 3b 54 24  |INT "Create ";T$|
000007c0  2c 53 25 0d 00 5a 2c 20  20 20 20 20 20 20 20 20  |,S%..Z,         |
000007d0  20 20 20 20 20 20 20 20  20 20 ff 20 22 43 64 69  |          . "Cdi|
000007e0  72 20 22 2b 54 24 2b 22  20 22 2b c3 20 53 25 0d  |r "+T$+" "+. S%.|
000007f0  00 5b 27 20 20 20 20 20  20 20 20 20 20 20 20 20  |.['             |
00000800  20 20 20 20 20 20 f2 5f  43 6f 70 79 44 69 72 28  |      ._CopyDir(|
00000810  46 24 2c 54 24 29 0d 00  5c 0d 20 20 20 20 20 20  |F$,T$)..\.      |
00000820  20 20 cb 0d 00 5d 04 0d  00 5e 2d 20 20 20 20 20  |  ...]...^-     |
00000830  20 20 20 78 25 20 20 20  20 20 2b 3d 20 28 28 73  |   x%     += ((s|
00000840  74 72 6c 65 6e 25 2b 34  29 20 80 ac 20 33 29 20  |trlen%+4) .. 3) |
00000850  2b 20 32 30 0d 00 5f 0b  20 20 20 20 20 20 ed 0d  |+ 20.._.      ..|
00000860  00 60 09 20 20 20 20 cd  0d 00 61 14 20 20 fd 20  |.`.    ...a.  . |
00000870  6f 66 66 73 65 74 25 20  3d 20 2d 31 0d 00 62 04  |offset% = -1..b.|
00000880  0d 00 63 05 e1 0d 00 64  04 0d 00 65 15 dd 20 a4  |..c....d...e.. .|
00000890  5f 44 69 72 53 69 7a 65  28 64 69 72 24 29 0d 00  |_DirSize(dir$)..|
000008a0  66 20 ea 20 74 6f 74 25  2c 6f 66 66 73 65 74 25  |f . tot%,offset%|
000008b0  2c 73 74 72 6c 65 6e 25  2c 41 25 2c 78 25 0d 00  |,strlen%,A%,x%..|
000008c0  67 04 0d 00 68 4b 20 20  f4 20 54 68 69 73 20 72  |g...hK  . This r|
000008d0  6f 75 74 69 6e 65 20 63  61 6c 63 75 6c 61 74 65  |outine calculate|
000008e0  73 20 74 68 65 20 73 69  7a 65 20 6f 66 20 61 6c  |s the size of al|
000008f0  6c 20 74 68 65 20 65 6e  74 72 69 65 73 20 69 6e  |l the entries in|
00000900  20 61 20 64 69 72 65 63  74 6f 72 79 2c 0d 00 69  | a directory,..i|
00000910  29 20 20 f4 20 61 6e 64  20 61 6c 6c 20 68 65 61  |)  . and all hea|
00000920  64 69 6e 67 20 69 6e 66  6f 20 66 6f 72 20 74 68  |ding info for th|
00000930  65 20 64 69 72 2e 0d 00  6a 23 20 20 f4 20 54 68  |e dir...j#  . Th|
00000940  65 20 73 69 7a 65 20 6f  66 20 68 65 61 64 69 6e  |e size of headin|
00000950  67 20 69 6e 66 6f 20 69  73 0d 00 6b 30 20 20 f4  |g info is..k0  .|
00000960  20 20 20 20 34 20 28 6f  66 66 73 65 74 20 69 6e  |    4 (offset in|
00000970  74 6f 20 64 69 72 20 6f  66 20 31 73 74 20 75 6e  |to dir of 1st un|
00000980  75 73 65 64 20 70 6f 73  29 0d 00 6c 20 20 20 f4  |used pos)..l   .|
00000990  20 54 68 65 20 73 69 7a  65 20 6f 66 20 6f 6e 65  | The size of one|
000009a0  20 65 6e 74 72 79 20 69  73 0d 00 6d 48 20 20 f4  | entry is..mH  .|
000009b0  20 20 20 32 34 20 28 6f  66 66 73 65 74 20 69 6e  |   24 (offset in|
000009c0  20 69 6d 61 67 65 2c 20  6c 6f 61 64 2c 20 65 78  | image, load, ex|
000009d0  65 63 2c 20 73 69 7a 65  2c 20 66 6c 61 67 73 2c  |ec, size, flags,|
000009e0  20 63 6f 6d 70 72 65 73  73 65 64 20 73 69 7a 65  | compressed size|
000009f0  29 0d 00 6e 2f 20 20 f4  20 2b 20 77 6f 72 64 20  |)..n/  . + word |
00000a00  61 6c 69 67 6e 65 64 20  6c 65 6e 67 74 68 20 6f  |aligned length o|
00000a10  66 20 6e 61 6d 65 20 28  69 6e 63 6c 20 5c 30 29  |f name (incl \0)|
00000a20  0d 00 6f 04 0d 00 70 40  20 20 f4 20 28 54 68 65  |..o...p@  . (The|
00000a30  20 27 63 6f 6d 70 72 65  73 73 65 64 20 73 69 7a  | 'compressed siz|
00000a40  65 27 20 69 73 20 74 68  65 72 65 20 66 6f 72 20  |e' is there for |
00000a50  70 6f 73 73 69 62 6c 65  20 66 75 74 75 72 65 20  |possible future |
00000a60  75 73 65 29 0d 00 71 04  0d 00 72 0e 20 20 74 6f  |use)..q...r.  to|
00000a70  74 25 20 3d 20 34 0d 00  73 11 20 20 6f 66 66 73  |t% = 4..s.  offs|
00000a80  65 74 25 20 3d 20 30 0d  00 74 07 20 20 f5 0d 00  |et% = 0..t.  ...|
00000a90  75 49 20 20 20 20 c8 99  20 22 4f 53 5f 47 42 50  |uI    .. "OS_GBP|
00000aa0  42 22 2c 31 30 2c 64 69  72 24 2c 77 72 6b 32 25  |B",10,dir$,wrk2%|
00000ab0  2c 32 35 35 2c 6f 66 66  73 65 74 25 2c 32 35 35  |,255,offset%,255|
00000ac0  2c 22 2a 22 20 b8 20 2c  2c 2c 72 65 61 64 25 2c  |,"*" . ,,,read%,|
00000ad0  6f 66 66 73 65 74 25 0d  00 76 15 20 20 20 20 e7  |offset%..v.    .|
00000ae0  20 72 65 61 64 25 20 3e  20 30 20 8c 0d 00 77 14  | read% > 0 ...w.|
00000af0  20 20 20 20 20 20 78 25  20 3d 20 77 72 6b 32 25  |      x% = wrk2%|
00000b00  0d 00 78 1a 20 20 20 20  20 20 e3 20 41 25 20 3d  |..x.      . A% =|
00000b10  20 31 20 b8 20 72 65 61  64 25 0d 00 79 32 20 20  | 1 . read%..y2  |
00000b20  20 20 20 20 20 20 73 74  72 6c 65 6e 25 20 3d 20  |      strlen% = |
00000b30  28 20 a4 5f 53 74 72 4c  65 6e 28 78 25 2b 32 30  |( ._StrLen(x%+20|
00000b40  29 20 2b 20 34 20 29 20  80 ac 20 33 0d 00 7a 22  |) + 4 ) .. 3..z"|
00000b50  20 20 20 20 20 20 20 20  74 6f 74 25 20 20 20 2b  |        tot%   +|
00000b60  3d 20 73 74 72 6c 65 6e  25 20 2b 20 32 34 0d 00  |= strlen% + 24..|
00000b70  7b 22 20 20 20 20 20 20  20 20 78 25 20 20 20 20  |{"        x%    |
00000b80  20 2b 3d 20 73 74 72 6c  65 6e 25 20 2b 20 32 30  | += strlen% + 20|
00000b90  0d 00 7c 0b 20 20 20 20  20 20 ed 0d 00 7d 09 20  |..|.      ...}. |
00000ba0  20 20 20 cd 0d 00 7e 14  20 20 fd 20 6f 66 66 73  |   ...~.  . offs|
00000bb0  65 74 25 20 3d 20 2d 31  0d 00 7f 0a 3d 20 74 6f  |et% = -1....= to|
00000bc0  74 25 0d 00 80 04 0d 00  81 12 dd 20 a4 5f 53 74  |t%......... ._St|
00000bd0  72 4c 65 6e 28 41 25 29  0d 00 82 08 ea 20 4c 25  |rLen(A%)..... L%|
00000be0  0d 00 83 0d 20 20 4c 25  20 3d 20 41 25 0d 00 84  |....  L% = A%...|
00000bf0  12 20 20 c8 95 20 3f 41  25 20 3e 3d 20 33 32 0d  |.  .. ?A% >= 32.|
00000c00  00 85 0f 20 20 20 20 41  25 20 2b 3d 20 31 0d 00  |...    A% += 1..|
00000c10  86 07 20 20 ce 0d 00 87  0d 3d 20 41 25 20 2d 20  |..  .....= A% - |
00000c20  4c 25 0d 00 88 04 0d 00  89 18 dd 20 a4 5f 47 65  |L%......... ._Ge|
00000c30  74 41 72 67 28 61 72 67  24 2c 6e 6f 25 29 0d 00  |tArg(arg$,no%)..|
00000c40  8a 0e ea 20 61 25 2c 62  25 2c 78 25 0d 00 8b 04  |... a%,b%,x%....|
00000c50  0d 00 8c 24 20 20 f4 20  46 69 6e 64 20 73 74 61  |...$  . Find sta|
00000c60  72 74 20 6f 66 20 74 68  65 20 67 69 76 65 6e 20  |rt of the given |
00000c70  70 61 72 74 0d 00 8d 0c  20 20 61 25 20 3d 20 31  |part....  a% = 1|
00000c80  0d 00 8e 0c 20 20 78 25  20 3d 20 30 0d 00 8f 07  |....  x% = 0....|
00000c90  20 20 f5 0d 00 90 1a 20  20 20 20 61 25 20 3d 20  |  .....    a% = |
00000ca0  a7 61 72 67 24 2c 22 20  22 2c 61 25 29 0d 00 91  |.arg$," ",a%)...|
00000cb0  12 20 20 20 20 e7 20 61  25 20 3d 20 30 20 8c 0d  |.    . a% = 0 ..|
00000cc0  00 92 0e 20 20 20 20 20  20 3d 20 22 22 0d 00 93  |...      = ""...|
00000cd0  09 20 20 20 20 cd 0d 00  94 0f 20 20 20 20 61 25  |.    .....    a%|
00000ce0  20 2b 3d 20 31 0d 00 95  1e 20 20 20 20 c8 95 20  | += 1....    .. |
00000cf0  28 c1 61 72 67 24 2c 61  25 2c 31 29 20 3d 20 22  |(.arg$,a%,1) = "|
00000d00  20 22 29 0d 00 96 11 20  20 20 20 20 20 61 25 20  | ")....      a% |
00000d10  2b 3d 20 31 0d 00 97 09  20 20 20 20 ce 0d 00 98  |+= 1....    ....|
00000d20  04 0d 00 99 31 20 20 20  20 e7 20 c1 61 72 67 24  |....1    . .arg$|
00000d30  2c 61 25 2c 31 29 20 3d  20 22 2d 22 20 84 20 c1  |,a%,1) = "-" . .|
00000d40  61 72 67 24 2c 61 25 2c  31 29 20 3d 20 22 40 22  |arg$,a%,1) = "@"|
00000d50  20 8c 0d 00 9a 11 20 20  20 20 20 20 6e 6f 25 20  | .....      no% |
00000d60  2b 3d 31 0d 00 9b 09 20  20 20 20 cd 0d 00 9c 04  |+=1....    .....|
00000d70  0d 00 9d 0f 20 20 20 20  78 25 20 2b 3d 20 31 0d  |....    x% += 1.|
00000d80  00 9e 11 20 20 fd 20 78  25 20 3e 3d 20 6e 6f 25  |...  . x% >= no%|
00000d90  0d 00 9f 04 0d 00 a0 22  20 20 f4 20 46 69 6e 64  |......."  . Find|
00000da0  20 65 6e 64 20 6f 66 20  74 68 65 20 67 69 76 65  | end of the give|
00000db0  6e 20 70 61 72 74 0d 00  a1 04 0d 00 a2 18 20 20  |n part........  |
00000dc0  62 25 20 3d 20 a7 61 72  67 24 2c 22 20 22 2c 61  |b% = .arg$," ",a|
00000dd0  25 29 0d 00 a3 10 20 20  e7 20 62 25 20 3d 20 30  |%)....  . b% = 0|
00000de0  20 8c 0d 00 a4 13 20 20  20 20 3d 20 c1 61 72 67  | .....    = .arg|
00000df0  24 2c 61 25 29 0d 00 a5  07 20 20 cc 0d 00 a6 19  |$,a%)....  .....|
00000e00  20 20 20 20 3d 20 c1 61  72 67 24 2c 61 25 2c 62  |    = .arg$,a%,b|
00000e10  25 2d 61 25 29 0d 00 a7  07 20 20 cd 0d 00 a8 07  |%-a%)....  .....|
00000e20  3d 20 30 0d 00 a9 04 0d  00 aa 0d dd 20 f2 5f 45  |= 0......... ._E|
00000e30  72 72 6f 72 0d 00 ab 0b  20 20 ee 20 85 20 87 0d  |rror....  . . ..|
00000e40  00 ac 18 20 20 c8 99 20  22 48 6f 75 72 67 6c 61  |...  .. "Hourgla|
00000e50  73 73 5f 4f 66 66 22 0d  00 ad 04 0d 00 ae 4b 20  |ss_Off".......K |
00000e60  20 f4 20 49 66 20 77 65  20 68 61 76 65 20 72 65  | . If we have re|
00000e70  6e 61 6d 65 64 20 6f 72  69 67 69 6e 61 6c 20 66  |named original f|
00000e80  69 6c 65 20 74 6f 20 57  69 6d 70 24 53 63 72 61  |ile to Wimp$Scra|
00000e90  70 2c 20 74 68 65 6e 20  77 65 20 73 68 6f 75 6c  |p, then we shoul|
00000ea0  64 20 6d 6f 76 65 0d 00  af 11 20 20 f4 20 69 74  |d move....  . it|
00000eb0  20 62 61 63 6b 2e 2e 0d  00 b0 04 0d 00 b1 0e 20  | back.......... |
00000ec0  20 e7 20 64 65 6c 25 20  8c 0d 00 b2 04 0d 00 b3  | . del% ........|
00000ed0  2e 20 20 20 20 f4 20 31  73 74 20 64 65 6c 65 74  |.    . 1st delet|
00000ee0  65 20 6e 65 77 20 66 69  6c 65 20 28 69 66 20 69  |e new file (if i|
00000ef0  74 20 65 78 69 73 74 73  2e 2e 29 0d 00 b4 20 20  |t exists..)...  |
00000f00  20 20 20 c8 99 20 22 4f  53 5f 46 69 6c 65 22 2c  |   .. "OS_File",|
00000f10  31 37 2c 42 24 20 b8 20  52 30 25 0d 00 b5 23 20  |17,B$ . R0%...# |
00000f20  20 20 20 e7 20 52 30 25  20 3c 3e 20 30 20 8c 20  |   . R0% <> 0 . |
00000f30  ff 20 22 44 65 6c 65 74  65 20 22 2b 42 24 0d 00  |. "Delete "+B$..|
00000f40  b6 04 0d 00 b7 21 20 20  20 20 f4 20 4d 6f 76 65  |.....!    . Move|
00000f50  20 6f 72 69 67 69 6e 61  6c 20 66 69 6c 65 20 62  | original file b|
00000f60  61 63 6b 0d 00 b8 1d 20  20 20 20 ff 20 22 52 65  |ack....    . "Re|
00000f70  6e 61 6d 65 20 22 2b 41  24 2b 22 20 22 2b 42 24  |name "+A$+" "+B$|
00000f80  0d 00 b9 04 0d 00 ba 07  20 20 cd 0d 00 bb 04 0d  |........  ......|
00000f90  00 bc 13 20 20 f1 20 f6  24 3b 22 20 61 74 20 22  |...  . .$;" at "|
00000fa0  3b 9e 0d 00 bd 07 20 20  e0 0d 00 be 05 e1 0d ff  |;.....  ........|
00000fb0