Listing: 1 MODULE D; 2 (* 3 * REPERTOIRE 4 * Release 1.6 5 * By Charles Bradford and Cole Brecheen 6 * (c) Copyright 1985-1990 PMI 7 * Green Bay Wisconsin 8 * All rights reserved 9 * (414) 468-6040 10 * 11 * $Header: D:/logfiles/demos/d.mov 1.2 03 Dec 1990 07:01:24 coleb $ 12 * 13 *) 14 15 16 17 (* 18 Directory Management With D.MOD 19 20 D.MOD is a sample director manager. Its purpose is 21 to illustrate the use of Repertoire's Drectory module. 22 See section 7.10. It makes more convenient the four most 23 frequently performed operations in the PC/MS-DOS 24 operating system: listing, deleting, renaming, and 25 copying files. It lists directories using both the left 26 and right sides of the screen; it allows prompted file 27 erasure; it allows prompted renaming and directory- 28 shifting of files; and it allows prompted file copying 29 and moving with safety checks to prevent accidental 30 erasures. 31 32 33 Listing Directories. 34 35 To list the entire current directory of the default 36 drive using both sides of the screen, enter "d" and 37 press . If the screen fills, the program 38 suspends the listing until you press a key. Unlike the 39 MS-DOS DIR /W (wide) command, which lists only file 40 names, D provides complete information about each file. 41 42 To list the entire current directory of a drive 43 other than the default drive (say, the A: drive), type 44 "d a" and press . Notice that D does not 45 require a trailing colon to specify a drive letter--it 46 assumes that any single-character program parameter is 47 a drive letter. To list all files with extensions of 48 .ltr in the subdirectory \letters, enter "d \letters\*.ltr" 49 or "d letters\*.ltr". If \letters is not on the 50 default drive, enter "d a:letters\*.ltr" or 51 "d a:\letters\*.ltr". To list all the files in the 52 \letters subdirectory, enter "d letters\". The 53 trailing slash tells D to list a subdirectory instead 54 of a file in the current directory named letters. 55 56 D expands the power of the asterisk as an expansion 57 character. For example, to list all files beginning 58 with the letter A, regardless of extension, you need 59 only enter "a*" as D's command-line parameter. 60 Entering "art*xt" would list all files beginning with 61 'art' and ending (in the extension part of the name) 62 with 'xt'. It would list ARTICLE.TXT, for example, or 63 ARTWORK.EXT. Multiple asterisks are allowed in a 64 single command. 65 66 67 Erasing Files. 68 69 Suppose you want to erase all documents in the 70 \letters subdirectory on drive B: that are more than a 71 year old. Using D, you can enter "d b:\letters\/e" and 72 press . The trailing /e tells D to invoke its 73 file-erasing function. D will display a full directory 74 entry for the first file in the \letters subdirectory, 75 followed by the prompt "Erase?" If the date indicates 76 that the file is more than a year old, you can press Y 77 to erase it. Press N to leave the file on the disk. D 78 will continue to display directory entries and ask for 79 permission to erase them until it can find no more 80 matching files or until you press Q, for quit. 81 82 83 Copying Files. 84 85 D allows you to decide both whether to copy each 86 matching file and whether to destroy any files of the 87 same name on the destination disk. Suppose, for 88 example, you want to make sure that two disks each have 89 the same 30-file set of implementation modules for a 90 large program you're developing. For each of the 30 91 files, you have to determine which disk has either the 92 larger or the more recent version of the file. 93 94 On the DOS command line, enter "d a:*imp/c". The 95 trailing /c tells D that it is to COPY matching files. 96 The program will ask, "Copy to what drive:\path?" 97 Enter "b" and press . No trailing colon is 98 required. You can copy to the current drive by merely 99 pressing . For each of the 30 implementation 100 modules on drive A:, D will display complete directory 101 information and ask, "Copy?" Press Y to copy the file, 102 N to skip it, and Q to terminate the program. 103 104 If you press Y, D will determine whether the 105 destination disk contains a file of the same name. If 106 it does, D will display complete directory information 107 for that file and ask, "Destroy?" You can look at the 108 date and, if the file on the destination disk is less 109 recent than the file on the source disk, press Y. If 110 you press N, D will prompt you to "Enter new name, or 111 to skip." To copy the file to the destination 112 disk under a different name, type in the new name and 113 press . D will again determine whether the 114 destination disk contains a file of the same name. If 115 it doesn't, D will copy the file. If you only press 116 when prompted for a new name, D will not copy 117 the file on the source disk, and will go to the next 118 matching file. 119 120 After you've answered yes or no to D's prompts on 121 each of the 30 .MOD files on drive A:, reverse the 122 process by entering "d b:*.MOD/c" and entering "a" when 123 asked "Copy to what drive:\path?" Each time D asks 124 whether you want to destroy a file on drive A:, press N 125 if the file is identical. At the end of the process 126 you'll have the most recent 30-file set of 127 implementation modules on each disk. 128 129 130 Renaming Files. 131 132 D allows you to rename files and move them between 133 directories without recopying them using much the same 134 syntax that you employ with its other functions. For 135 example, to move selected files with .LTR extensions 136 from the root directory of your hard disk to the \LTRS 137 subdirectory, enter: 138 139 140 C>d *ltr \ltrs\*ltr/r 141 142 D will respond as follows: 143 144 F1.LTR 50950 2-02-86 8:04p |Rename \ltrs\F1.ltr? no 145 F3.LTR 23557 2-02-86 1:31p |Rename \ltrs\F3.ltr? yes 146 F2.LTR 34821 2-02-86 2:59p |Rename \ltrs\F2.ltr? no 147 148 C>_ 149 150 151 The trailing /r is the command that tells D to 152 rename the files that match its first command-line 153 parameter. D renames the files in accordance with the 154 same rules used in the DOS RENAME operation, with the 155 exception that D does not require separate asterisks on 156 each side of the period. 157 158 159 Moving Files 160 161 A trailing /m modifies both the renaming and the 162 copying operations. A trailing /m causes D first to 163 determine whether the two file specifications are on 164 different drives. If they are, D copies files to the 165 destination drive just as it does when you use the /c 166 command, but it also erases from the source drive any 167 files that are successfully copied. If the files are on 168 the same drive, a trailing /m causes D to erase any 169 conflicting file names from the destination directory; 170 the rename operation normally aborts if a file of the 171 same name is in the destination directory. 172 173 174 Batch Mode 175 176 A trailing /b causes any yes/no prompt automatically 177 to be answered Yes. 178 179 *) 180 181 IMPORT BigSets; 182 IMPORT Drectory; 183 IMPORT EnvironUtils; 184 IMPORT ErrorManager; 185 IMPORT ErrStrgs; 186 IMPORT KbdInput; 187 IMPORT LowLevel; 188 IMPORT M2Strings; 189 IMPORT Numbers; 190 IMPORT HandleIO; 191 IMPORT FAPI; 192 IMPORT PosUtils; 193 IMPORT StrConv; 194 IMPORT StrEdit; 195 IMPORT StringIO; 196 IMPORT SYSTEM; 197 198 IMPORT InitCompilerMods; 199 200 201 CONST 202 blank = ' '; 203 null = ''; 204 VAR 205 SecondStr, DirMask: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 206 FileInfo: Drectory.FileInfoRec; ***** ^ not supported yet 207 BatchMode, exiting, moving, renaming, copying, deleting, 208 OnTheLeft : BOOLEAN; 209 SavedMessage : CARDINAL; 210 TheDrive : CHAR; 211 BytesPerSector, SectorsPerCluster, 212 ClustersOnDisk: CARDINAL; 213 KindOfDisk : Drectory.DiskTypes; ***** ^ not supported yet 214 ClusterSize : LONGINT; 215 216 PROCEDURE yes() : BOOLEAN; 217 VAR 218 choice : CARDINAL; 219 BEGIN 220 (*yes*) 221 IF BatchMode THEN 222 StringIO.WriteStr(StringIO.outp, 'yes'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 223 RETURN TRUE; 224 END; 225 choice := KbdInput.KeyHit( KbdInput.YorN ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 226 IF KbdInput.CAPkey(choice) = ORD('Y') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 227 StringIO.WriteStr(StringIO.outp, 'yes'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 228 RETURN TRUE; 229 ELSE 230 StringIO.WriteStr(StringIO.outp, 'no'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 231 IF KbdInput.CAPkey(choice) = ORD('Q') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 232 exiting := TRUE; 233 END; 234 RETURN FALSE; 235 END; 236 END yes; ***** ^ not supported yet 237 238 PROCEDURE IsDriveLetter( TheStr: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 239 BEGIN 240 RETURN (M2Strings.Length(TheStr) = 1) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 241 AND ( (CAP(TheStr[0]) >= 'A') AND (CAP(TheStr[0]) <= 'Z')); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 242 END IsDriveLetter; ***** ^ not supported yet 243 244 245 PROCEDURE Punctuate( VAR TheStr: ARRAY OF CHAR ); ***** ^ not supported yet 246 VAR 247 index, PlaceCount: CARDINAL; 248 BEGIN 249 index := M2Strings.Length( TheStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 250 IF index > 0 THEN 251 DEC( index ); ***** ^ undeclared identifier ***** ^ not supported yet 252 PlaceCount := 2; 253 REPEAT 254 IF PlaceCount > 0 THEN 255 IF index > 0 THEN 256 DEC( index ); ***** ^ undeclared identifier ***** ^ not supported yet 257 END; 258 DEC( PlaceCount ); ***** ^ undeclared identifier ***** ^ not supported yet 259 ELSE 260 PlaceCount := 2; 261 M2Strings.Insert( ',', TheStr, index ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 262 DEC( index ); ***** ^ undeclared identifier ***** ^ not supported yet 263 END; 264 UNTIL (index = 0) OR (NOT PosUtils.IsNumericChar(TheStr[index])); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 265 END; 266 END Punctuate; ***** ^ not supported yet 267 268 269 PROCEDURE DifferentDrives( str1, str2: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 270 VAR 271 DriveChar1, DriveChar2: CHAR; 272 BEGIN 273 IF IsDriveLetter(str1) OR (str1[1] = ':') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 274 DriveChar1 := CAP(str1[0]); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 275 ELSE 276 DriveChar1 := CAP(Drectory.GetDefaultDrive()); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 277 END; 278 IF IsDriveLetter(str2) OR (str2[1] = ':') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 279 DriveChar2 := CAP(str2[0]); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 280 ELSE 281 DriveChar2 := CAP(Drectory.GetDefaultDrive()); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 282 END; 283 RETURN DriveChar1 # DriveChar2; 284 END DifferentDrives; ***** ^ not supported yet 285 286 287 PROCEDURE MakeInfoStr( FileInfo: Drectory.FileInfoRec; VAR TheStr: ARRAY ***** ^ not supported yet 288 OF CHAR ); ***** ^ not supported yet 289 VAR 290 dumstr: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 291 BEGIN 292 StrEdit.AssignStr( FileInfo.name, TheStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 293 WHILE M2Strings.Length(TheStr) < 12 DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 294 StrEdit.Append( TheStr, ' ' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 295 END; 296 IF Drectory.SubdirectoryFile IN FileInfo.attribute THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 297 StrEdit.Append( TheStr, ' ' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 298 ELSE 299 StrConv.LongIntegerToStr( FileInfo.size, 0, dumstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 300 IF FileInfo.size < 1000000 THEN ***** ^ not supported yet ***** ^ not supported yet 301 (* No room for commas if the string is longer than 6 chars. *) 302 Punctuate( dumstr ); ***** ^ not supported yet ***** ^ not supported yet 303 END; 304 StrEdit.RightJustify( dumstr, 8 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 305 StrEdit.Append( TheStr, dumstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 306 END; 307 StrConv.DateToStr( FileInfo.month, FileInfo.day, FileInfo.year, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 308 dumstr ); ***** ^ not supported yet 309 StrEdit.Append( TheStr, ' ' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 310 StrEdit.Append( TheStr, dumstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 311 StrConv.TimeToStr( FileInfo.hour, FileInfo.minute, FileInfo.second, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 312 FileInfo.second, dumstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 313 M2Strings.Delete( dumstr, M2Strings.Length(dumstr) - 7, 6 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 314 StrEdit.Append( TheStr, ' ' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 315 StrEdit.Append( TheStr, dumstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 316 END MakeInfoStr; ***** ^ not supported yet 317 318 PROCEDURE SayNotFound(); 319 VAR 320 BytesFree : LONGINT; 321 label, BytesFreeStr : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 322 BEGIN 323 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 324 Drectory.FreeDiskSpace(TheDrive,BytesFree) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 325 StrConv.LongIntegerToStr(BytesFree, 1, BytesFreeStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 326 Punctuate( BytesFreeStr ); ***** ^ not supported yet ***** ^ not supported yet 327 Drectory.VolumeLabel(TheDrive, label); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 328 StringIO.WriteStr(StringIO.outp, 'File not found on '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 329 StringIO.WriteStr(StringIO.outp, label); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 330 StringIO.WriteStr(StringIO.outp, '; '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 331 StringIO.WriteStr(StringIO.outp, BytesFreeStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 332 StringIO.WriteEol(StringIO.outp, ' bytes free.'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 333 END SayNotFound; ***** ^ not supported yet 334 335 PROCEDURE WriteBarAndPrompt( FileInfoStr, ActionProposed, 336 NewName: ARRAY OF CHAR ); ***** ^ not supported yet 337 VAR 338 tmpstr: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 339 BEGIN 340 StrEdit.AssignStr( FileInfoStr, tmpstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 341 StrEdit.Append( tmpstr, blank ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 342 StrEdit.Append( tmpstr, CHR(186) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 343 StrEdit.Append( tmpstr, blank ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 344 StrEdit.Append( tmpstr, ActionProposed ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 345 IF M2Strings.Length(NewName) > 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 346 StrEdit.Append( tmpstr, blank ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 347 StrEdit.Append( tmpstr, NewName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 348 END; 349 StrEdit.Append( tmpstr, '? ' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 350 StringIO.WriteStr( StringIO.outp, tmpstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 351 END WriteBarAndPrompt; ***** ^ not supported yet 352 353 PROCEDURE ExpandAsterisk(VAR TheMask : ARRAY OF CHAR); ***** ^ not supported yet 354 VAR 355 base, spot, indx : CARDINAL; 356 357 BEGIN 358 (*ExpandAsterisk*) 359 indx := M2Strings.Pos('*',TheMask); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 360 WHILE indx<=HIGH(TheMask) DO ***** ^ undeclared identifier ***** ^ not supported yet 361 TheMask[indx] := '?'; ***** ^ not supported yet ***** ^ not supported yet 362 base := indx; 363 WHILE (base > 0) 364 AND NOT (M2Strings.Pos( TheMask[base-1], ':\/' ) <= 2) DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 365 DEC(base); ***** ^ undeclared identifier ***** ^ not supported yet 366 END; 367 spot := PosUtils.Positn( '.', TheMask, base ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 368 IF (spot>HIGH(TheMask)) THEN ***** ^ undeclared identifier ***** ^ not supported yet 369 (*There's no period.*) 370 StrEdit.InsertTimes('?', TheMask, indx, 12 - (M2Strings.Length(TheMask) - base) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 371 TheMask[ base + 8 ] := '.'; ***** ^ not supported yet ***** ^ not supported yet 372 ELSIF (spot>indx) THEN 373 (*Asterisk was in the filename part, not extension part.*) 374 StrEdit.InsertTimes('?', TheMask, indx, 8 - (spot - base) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 375 ELSE 376 (*Asterisk was in the extension part.*) 377 StrEdit.InsertTimes('?', TheMask, indx, 4 - (M2Strings.Length(TheMask) - spot) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 378 END; 379 indx := M2Strings.Pos('*',TheMask); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 380 END; 381 END ExpandAsterisk; ***** ^ not supported yet 382 383 PROCEDURE PrepareDirMask(VAR TheStr : ARRAY OF CHAR); ***** ^ not supported yet 384 VAR 385 spot : CARDINAL; 386 BEGIN 387 TheDrive := 'z'; 388 (*for default*) 389 deleting := FALSE; 390 copying := FALSE; 391 renaming := FALSE; 392 moving := FALSE; 393 StrEdit.CrunchBlanks(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 394 IF (M2Strings.Length(TheStr)>=2) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 395 IF TheStr[M2Strings.Length(TheStr)-2]='/' THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 396 IF CAP( TheStr[M2Strings.Length(TheStr)-1] ) = 'B' THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 397 M2Strings.Delete(TheStr, M2Strings.Length(TheStr)-2, 2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 398 StrEdit.CutTrailingChars(blank, TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 399 BatchMode := TRUE; 400 ELSE 401 BatchMode := FALSE; 402 END; 403 deleting := CAP( TheStr[M2Strings.Length(TheStr)-1] ) = 'E'; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 404 copying := CAP( TheStr[M2Strings.Length(TheStr)-1] ) = 'C'; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 405 renaming := CAP( TheStr[M2Strings.Length(TheStr)-1] ) = 'R'; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 406 moving := CAP( TheStr[M2Strings.Length(TheStr)-1] ) = 'M'; ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 407 M2Strings.Delete(TheStr, M2Strings.Length(TheStr)-2, 2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 408 StrEdit.CutTrailingChars(blank, TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 409 END; 410 END; 411 spot := M2Strings.Pos(blank,TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 412 IF spot<=HIGH(TheStr) THEN ***** ^ undeclared identifier ***** ^ not supported yet 413 M2Strings.Copy(TheStr, spot+1, M2Strings.Length(TheStr)-1-spot, SecondStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 414 M2Strings.Delete(TheStr, spot, M2Strings.Length(SecondStr)+1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 415 ELSE 416 SecondStr := null; ***** ^ not supported yet ***** ^ incompatible assignment 417 END; 418 IF M2Strings.Length(TheStr) = 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 419 StrEdit.AssignStr( '*.*',TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 420 ExpandAsterisk( TheStr ); ***** ^ not supported yet ***** ^ not supported yet 421 RETURN; 422 END; 423 IF M2Strings.Pos( '..', TheStr ) = ( HIGH(TheStr) - 1 ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 424 StrEdit.Append(TheStr, '\*.*'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 425 END; 426 IF ((TheStr[M2Strings.Length(TheStr)-1]='\') OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 427 (TheStr[M2Strings.Length(TheStr)-1]='/')) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 428 StrEdit.Append(TheStr, '*.*'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 429 ELSIF IsDriveLetter(TheStr) THEN ***** ^ not supported yet ***** ^ not supported yet 430 StrEdit.Append(TheStr, ':*.*'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 431 END; 432 IF TheStr[1]=':' THEN ***** ^ not supported yet ***** ^ not supported yet 433 TheDrive := TheStr[0]; ***** ^ not supported yet ***** ^ not supported yet 434 IF M2Strings.Length(TheStr)=2 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 435 StrEdit.Append(TheStr, '*.*'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 436 END; 437 END; 438 ExpandAsterisk( TheStr ); ***** ^ not supported yet ***** ^ not supported yet 439 END PrepareDirMask; ***** ^ not supported yet 440 441 PROCEDURE SplitPathName(VAR PathName, TheMask : ARRAY OF CHAR); ***** ^ not supported yet 442 VAR 443 TmpStr : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 444 spot : CARDINAL; 445 BEGIN 446 (*SplitPathName*) 447 IF IsDriveLetter(TheMask) THEN ***** ^ not supported yet ***** ^ not supported yet 448 StrEdit.AssignStr( TheMask, PathName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 449 StrEdit.Append( PathName, ':' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 450 StrEdit.AssignStr( null, TheMask ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 451 RETURN; 452 END; 453 StrEdit.AssignStr( null, PathName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 454 spot := 0; 455 WHILE spot+1<=M2Strings.Length(TheMask) DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 456 IF ((TheMask[spot]='\') OR (TheMask[spot]='/' ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 457 ) OR (TheMask[spot]=':')) THEN ***** ^ not supported yet ***** ^ not supported yet 458 M2Strings.Copy(TheMask, 0, spot+1, TmpStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 459 StrEdit.Append(PathName, TmpStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 460 M2Strings.Delete(TheMask, 0, 1+spot); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 461 spot := 0; 462 ELSE 463 INC(spot); ***** ^ undeclared identifier ***** ^ not supported yet 464 END; 465 END; 466 END SplitPathName; ***** ^ not supported yet 467 468 PROCEDURE EraseOneFile( PathName, FileName: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 469 VAR 470 Fname : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 471 BEGIN 472 StrEdit.AssignStr( FileName, Fname ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 473 M2Strings.Insert(PathName, Fname, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 474 IF Drectory.DeleteFile(Fname) = StringIO.NoError THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 475 RETURN TRUE; 476 ELSE 477 RETURN FALSE; 478 END; 479 END EraseOneFile; ***** ^ not supported yet 480 481 PROCEDURE EraseFiles(); 482 VAR 483 PathName, Fname, TmpStr : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 484 DirHandle: CARDINAL; 485 BEGIN 486 (*EraseFiles*) 487 DirHandle := 0FFFFH; 488 SavedMessage := Drectory.FindFirstFile( DirMask, DirHandle, FileInfo ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 489 IF SavedMessage # StringIO.NoError THEN ***** ^ not supported yet ***** ^ not supported yet 490 SayNotFound(); ***** ^ not supported yet ***** ^ not supported yet 491 RETURN; 492 END; 493 SplitPathName(PathName, DirMask); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 494 REPEAT 495 MakeInfoStr( FileInfo, TmpStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 496 IF NOT (Drectory.SubdirectoryFile IN FileInfo.attribute) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 497 WriteBarAndPrompt( TmpStr, 'Erase', '' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 498 IF yes() THEN ***** ^ not supported yet ***** ^ not supported yet 499 IF NOT EraseOneFile( PathName, FileInfo.name ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 500 END; 501 END; 502 StringIO.WriteEol(StringIO.outp, null); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 503 END; 504 SavedMessage := Drectory.FindNextFile( DirHandle, FileInfo ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 505 UNTIL (SavedMessage#StringIO.NoError) OR exiting; ***** ^ not supported yet ***** ^ not supported yet 506 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 507 END EraseFiles; ***** ^ not supported yet 508 509 510 PROCEDURE CopyFiles(); 511 VAR 512 PathName1, PathName2 : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 513 OldHandle, DirHandle : CARDINAL; 514 OldHandleOpen : BOOLEAN; 515 SavedMessage : CARDINAL; 516 SavedFileMode : BITSET; ***** ^ undeclared identifier 517 TmpStr1, NewFullName, OldFullName : ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 518 519 PROCEDURE CheckDest( VAR PathName, FileName: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 520 VAR 521 TmpStr, NewFileName: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 522 FinishedChecking : BOOLEAN; 523 TmpFileInfo: Drectory.FileInfoRec; ***** ^ not supported yet 524 DirHandle: CARDINAL; 525 BEGIN 526 DirHandle := 0FFFFH; 527 REPEAT 528 FinishedChecking := TRUE; 529 M2Strings.Concat(PathName, FileName, NewFileName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 530 SavedMessage := Drectory.FindFirstFile(NewFileName, DirHandle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 531 TmpFileInfo); ***** ^ not supported yet 532 IF NOT ((SavedMessage = StringIO.FileNotFound) OR (SavedMessage= ***** ^ not supported yet ***** ^ not supported yet 533 StringIO.NoMoreFiles)) THEN ***** ^ not supported yet ***** ^ not supported yet 534 IF SavedMessage # StringIO.NoError THEN ***** ^ not supported yet ***** ^ not supported yet 535 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 536 SavedMessage ); ***** ^ not supported yet 537 ELSE 538 MakeInfoStr( TmpFileInfo, TmpStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 539 StringIO.WriteEol(StringIO.outp, null); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 540 WriteBarAndPrompt( TmpStr, 'Destroy', '' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 541 IF NOT yes() THEN ***** ^ not supported yet ***** ^ not supported yet 542 StringIO.WriteEol(StringIO.outp, null); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 543 StringIO.WriteStr(StringIO.outp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 544 'Enter new name, or to skip: '); ***** ^ not supported yet 545 StringIO.ReadStr(StringIO.inp, FileName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 546 IF M2Strings.Length(FileName)=0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 547 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 548 RETURN FALSE; 549 ELSE 550 SplitPathName( PathName, FileName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 551 FinishedChecking := FALSE; 552 END; 553 END; 554 END; 555 END; 556 UNTIL FinishedChecking OR exiting; 557 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 558 RETURN TRUE; 559 END CheckDest; ***** ^ not supported yet 560 561 BEGIN 562 (*CopyFiles*) 563 DirHandle := 0FFFFH; 564 IF Drectory.FindFirstFile( DirMask, DirHandle, FileInfo ) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 565 # StringIO.NoError THEN ***** ^ not supported yet ***** ^ not supported yet 566 SayNotFound(); ***** ^ not supported yet ***** ^ not supported yet 567 RETURN; 568 END; 569 IF M2Strings.Length(SecondStr)=0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 570 StringIO.WriteStr(StringIO.outp, ' Copy to what drive:\path? '); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 571 StringIO.ReadStr(StringIO.inp, SecondStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 572 END; 573 SplitPathName( PathName2, SecondStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 574 SplitPathName( PathName1, DirMask ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 575 REPEAT 576 MakeInfoStr( FileInfo, TmpStr1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 577 IF NOT (Drectory.SubdirectoryFile IN FileInfo.attribute) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 578 WriteBarAndPrompt( TmpStr1, 'Copy', '' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 579 IF yes() THEN ***** ^ not supported yet ***** ^ not supported yet 580 M2Strings.Concat(PathName1, FileInfo.name, OldFullName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 581 582 SavedFileMode := HandleIO.DefaultFileMode; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 583 HandleIO.DefaultFileMode := BITSET{ 5 }; ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 584 (* Read-only access; deny no other access *) 585 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 586 HandleIO.OpenFile(OldHandle, OldFullName) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 587 OldHandleOpen := TRUE; 588 HandleIO.DefaultFileMode := SavedFileMode; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 589 590 IF M2Strings.Length(SecondStr) = 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 591 StrEdit.AssignStr( FileInfo.name, TmpStr1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 592 ELSE 593 StrEdit.AssignStr( SecondStr, TmpStr1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 594 END; 595 IF CheckDest( PathName2, TmpStr1 ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 596 M2Strings.Concat(PathName2, TmpStr1, NewFullName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 597 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 598 Drectory.CopyFile(OldHandle, NewFullName)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 599 IF moving THEN 600 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 601 HandleIO.CloseHandle(OldHandle)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 602 OldHandleOpen := FALSE; 603 IF NOT EraseOneFile( PathName1, FileInfo.name ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 604 HALT; ***** ^ undeclared identifier 605 END; 606 END; 607 END; 608 IF OldHandleOpen THEN 609 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 610 HandleIO.CloseHandle(OldHandle)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 611 OldHandleOpen := FALSE; 612 END; 613 END; ***** ^ ident expected 614 StringIO.WriteEol(StringIO.outp, null); 615 END; 616 SavedMessage := Drectory.FindNextFile( DirHandle, FileInfo ); 617 UNTIL (SavedMessage # StringIO.NoError) OR exiting; 618 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; 619 END CopyFiles; 620 621 622 PROCEDURE RenameFiles(); 623 VAR 624 mask2, path2, path1 : ARRAY [0..79] OF CHAR; 625 626 PROCEDURE GetNewName(VAR InfoStr, OldName, NewName : ARRAY OF CHAR); 627 VAR 628 TmpOld : ARRAY [0..79] OF CHAR; 629 ndx : CARDINAL; 630 BEGIN 631 (*GetNewName*) 632 StrEdit.AssignStr( null, NewName); 633 M2Strings.Copy(InfoStr, 0, M2Strings.Pos(blank,InfoStr), OldName); 634 StrEdit.AssignStr( OldName, TmpOld); 635 ndx := M2Strings.Pos('.',TmpOld); 636 IF ndx>HIGH(TmpOld) THEN 637 StrEdit.Append(TmpOld, '*'); 638 ExpandAsterisk(TmpOld); 639 ELSIF (ndx<8) THEN 640 M2Strings.Insert('*', TmpOld, ndx); 641 ExpandAsterisk(TmpOld); 642 END; 643 ndx := 0; 644 REPEAT 645 IF mask2[ndx]='?' THEN 646 IF TmpOld[ndx]#'?' THEN 647 StrEdit.Append(NewName, TmpOld[ndx]); 648 END; 649 ELSE 650 StrEdit.Append(NewName, mask2[ndx]); 651 END; 652 INC(ndx); 653 UNTIL (ndx>=M2Strings.Length(mask2)); 654 END GetNewName; 655 656 VAR 657 TmpStr1, TmpStr2, OldName, InfoStr, NewName : ARRAY [0..79] OF CHAR; 658 DirHandle: CARDINAL; 659 BEGIN 660 (*RenameFiles*) 661 DirHandle := 0FFFFH; 662 IF Drectory.FindFirstFile(DirMask, DirHandle, FileInfo) 663 # StringIO.NoError THEN 664 SayNotFound(); 665 RETURN; 666 END; 667 IF M2Strings.Length(SecondStr)=0 THEN 668 StringIO.WriteStr(StringIO.outp, ' New name: '); 669 StringIO.ReadStr(StringIO.inp, mask2); 670 ELSE 671 StrEdit.AssignStr( SecondStr, mask2); 672 END; 673 IF M2Strings.Length(mask2)=0 THEN 674 StrEdit.AssignStr( '\*.*', mask2); 675 END; 676 IF DifferentDrives( DirMask, mask2 ) THEN 677 copying := TRUE; 678 renaming := FALSE; 679 RETURN; 680 END; 681 SplitPathName(path2, mask2); 682 SplitPathName(path1, DirMask); 683 IF M2Strings.Length(path2)=0 THEN 684 StrEdit.AssignStr( path1, path2); 685 END; 686 ExpandAsterisk(mask2); 687 REPEAT 688 IF NOT (Drectory.SubdirectoryFile IN FileInfo.attribute) THEN 689 MakeInfoStr( FileInfo, InfoStr ); 690 GetNewName(InfoStr, OldName, NewName); 691 StrEdit.AssignStr( path2, TmpStr1); 692 StrEdit.Append(TmpStr1, NewName); 693 WriteBarAndPrompt( InfoStr, 'Rename', TmpStr1 ); 694 IF yes() THEN 695 M2Strings.Concat(path1, OldName, TmpStr1); 696 M2Strings.Concat(path2, NewName, TmpStr2); 697 IF moving THEN 698 IF Drectory.RenameFile(TmpStr1,TmpStr2) # StringIO.NoError THEN 699 IF NOT EraseOneFile( path2, NewName ) THEN 700 HALT; 701 ELSE 702 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, 703 Drectory.RenameFile(TmpStr1,TmpStr2)); 704 END; 705 END; 706 ELSE 707 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, 708 Drectory.RenameFile(TmpStr1,TmpStr2)); 709 END; 710 END; 711 StringIO.WriteEol(StringIO.outp, null); 712 ELSE 713 StringIO.WriteStr(StringIO.outp, "Can't rename '"); 714 StringIO.WriteStr(StringIO.outp, FileInfo.name); 715 StringIO.WriteEol(StringIO.outp, "' "); 716 END; 717 UNTIL (Drectory.FindNextFile(DirHandle, FileInfo) # StringIO.NoError) 718 OR exiting; 719 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; 720 END RenameFiles; 721 722 PROCEDURE UpToClusterSize(VAR TheRealSize : LONGINT); 723 VAR 724 clusters, NewSize : LONGINT; 725 BEGIN 726 clusters := TheRealSize DIV ClusterSize; 727 INC(clusters); 728 NewSize := ClusterSize * clusters; 729 IF (TheRealSize + ClusterSize) # NewSize THEN 730 TheRealSize := NewSize; 731 END; 732 END UpToClusterSize; 733 734 PROCEDURE ListFiles(); 735 VAR 736 choice : CARDINAL; 737 DirHandle, resultcode, linecnt : CARDINAL; 738 VolLabel, ListedBytes, BytesFreeStr : ARRAY [0..16] OF CHAR; 739 TmpStr, ThePath : ARRAY [0..79] OF CHAR; 740 TmpNum, ByteCnt, BytesFree : LONGINT; 741 dummy : BOOLEAN; 742 BEGIN 743 (*ListFiles*) 744 ByteCnt := Numbers.Lc( 0 ); 745 OnTheLeft := TRUE; 746 Drectory.VolumeLabel(TheDrive, VolLabel); 747 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, 748 Drectory.GetCurrentDir(TheDrive,ThePath)); 749 DirHandle := 0FFFFH; 750 SavedMessage := Drectory.FindFirstFile(DirMask, DirHandle, FileInfo); 751 IF SavedMessage # StringIO.NoError THEN 752 SayNotFound(); 753 RETURN; 754 END; 755 ErrStrgs.WriteErrToHandle( StringIO.ErrorOutp, 756 Drectory.FreeDiskSpace(TheDrive,BytesFree)); 757 linecnt := 1; 758 REPEAT 759 TmpNum := FileInfo.size; 760 UpToClusterSize(TmpNum); 761 ByteCnt := ByteCnt + TmpNum; 762 MakeInfoStr( FileInfo, TmpStr ); 763 IF OnTheLeft THEN 764 StringIO.WriteStr(StringIO.outp, TmpStr); 765 ELSE 766 M2Strings.Insert(' ', TmpStr, 0); 767 TmpStr[1] := CHR(186); 768 StringIO.WriteStr(StringIO.outp, TmpStr); 769 INC(linecnt); 770 IF linecnt=26 THEN 771 choice := KbdInput.KeyHit( KbdInput.AnyKeyNum ); 772 IF KbdInput.CAPkey(choice) = ORD('Q') THEN 773 ErrorManager.StraightToDOS(''); 774 END; 775 StringIO.WriteStr(StringIO.outp, '_'); 776 linecnt := 1; 777 ELSE 778 StringIO.WriteEol(StringIO.outp, null); 779 END; 780 END; 781 OnTheLeft := NOT (OnTheLeft); 782 SavedMessage := Drectory.FindNextFile( DirHandle, FileInfo ); 783 UNTIL SavedMessage # StringIO.NoError; 784 IF NOT OnTheLeft THEN 785 INC(linecnt); 786 IF linecnt>=25 THEN 787 choice := KbdInput.KeyHit( KbdInput.AnyKeyNum ); 788 IF KbdInput.CAPkey(choice) = ORD('Q') THEN 789 ErrorManager.StraightToDOS(''); 790 END; 791 END; 792 StringIO.WriteEol(StringIO.outp, null); 793 END; 794 StrConv.LongIntegerToStr(ByteCnt, 1, ListedBytes); 795 Punctuate( ListedBytes ); 796 StrConv.LongIntegerToStr(BytesFree, 1, BytesFreeStr); 797 Punctuate( BytesFreeStr ); 798 M2Strings.Insert(';', ThePath, 0); 799 M2Strings.Insert(VolLabel, ThePath, 0); 800 M2Strings.Insert(' ', ThePath, 0); 801 StrEdit.Append(ThePath, '; '); 802 StrEdit.Append(ThePath, BytesFreeStr); 803 StrEdit.Append(ThePath, ' free. Files above occupy '); 804 StrEdit.Append(ThePath, ListedBytes); 805 StrEdit.Append(ThePath, '.'); 806 StringIO.WriteStr(StringIO.outp, ThePath); 807 IF linecnt<=23 THEN 808 StringIO.WriteEol(StringIO.outp, null); 809 END; 810 IF 0 # FAPI.DOSFINDCLOSE( DirHandle ) THEN END; 811 END ListFiles; 812 813 814 BEGIN 815 (*D*) 816 exiting := FALSE; 817 BigSets.AppendSet( KbdInput.YorN, "{'q', 'Q'}" ); 818 EnvironUtils.GetProgParams(DirMask); 819 PrepareDirMask(DirMask); 820 Drectory.GetDiskInfo( TheDrive, BytesPerSector, SectorsPerCluster, 821 ClustersOnDisk, KindOfDisk ); 822 ClusterSize := Numbers.Lc( BytesPerSector * SectorsPerCluster ); 823 IF deleting THEN 824 EraseFiles(); 825 ELSIF moving OR renaming THEN 826 RenameFiles(); 827 IF copying THEN 828 (* We do this because we may have discovered differing drive names. *) 829 CopyFiles(); 830 END; 831 ELSIF copying THEN 832 CopyFiles(); 833 ELSE 834 ListFiles(); 835 END; 836 END D. 730 errors