home *** CD-ROM | disk | FTP | other *** search
- { MS-DOS 2.xx File Attribute Editor, Version 2.04, by Rick Housh, 3/5/85.
- THIS PROGRAM WILL NOT WORK PROPERLY WITH A COMMAND LINE ARGUMENT UNTIL
- COMPILED TO A .COM FILE BECAUSE IT MUST SCAN THE MS-DOS COMMAND LINE AT
- THE SYSTEM LEVEL. My sincere apologies to Mr. Wirth for the "Goto".
- Written in TURBO PASCAL.
-
- N.B. Be very careful when using this program with directories, especially
- with hard disks. You can make your directory invisible to the normal oper-
- ating system commands.}
-
-
- Program Read_and_Set_File_Attributes;
-
- Const
- NowSet: Array [0..7] Of String[33]=
- ('Read only','Hidden','System','Volume label','Directory name',
- 'Not archived','Illegal Byte Value (2nd bit set)',
- 'Illegal Byte Value (1st bit set)');
- SetTo: Array [0..7] Of String[12]=
- ('Read only','Read/write','Hidden','Not hidden',
- 'System','Non-system','Not archived','Archived');
- Label
- Start_here;
-
- Type
- FileName=String[65];
- DataTransArea=Record
- ThrowAwayBytes: Array [0..20] Of Byte;
- AttribByte: Byte;
- TimeInt: Integer;
- DateInt: Integer;
- Size1Int: Integer;
- Size2Int: Integer;
- FNam: Array [0..12] Of Char;
- End;
- RegisterSet=Record Case Integer Of
- 1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
- 2: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
- End;
- Var
- DirAndOrPath,Mask,CurrentFile: FileName;
- CurDataTransArea: ^DataTransArea;
- Regs: RegisterSet;
- Finished,None,AttributeChanged,AnAttributeSet: Boolean;
- A,C,I,J,ERR: Integer;
- CommandLine: String[127] Absolute CSEG:$0080;
- Choice: String[2];
- Dummy: String[1];
- This: String[12];
- Run: File;
- Procedure Warble;
- Begin
- For A := 1 to 3 do
- Begin
- Sound(440);
- Delay(50);
- Sound(660);
- Delay(50);
- NoSound;
- End;
- End; {Procedure Warble}
-
- Procedure Beep;
- Begin
- Sound(440);
- Delay(100);
- NoSound;
- End; {Procedure Beep}
-
- {Introduction}
-
- Begin
- ClrScr;
- WriteLn('File attribute program, by T. A. Housh, Jr.');
- WriteLn;
- LowVideo;
- WriteLn('This program will allow you to view and change the attributes');
- WriteLn('of an MS-DOS 2.xx file.');
- WriteLn;
- WriteLn('You may use wild cards or not, as you choose.');
- WriteLn;
- WriteLn('If you wish to examine a whole directory or disk just specify the');
- WriteLn('drive or directory in the usual way, e.g. a: or b:\ or whatever.');
- WriteLn('You may specify this parameter in the command line.');
- WriteLn;
- WriteLn('The designation "(No exceptions)" indicates no special attributes set,');
- WriteLn('that is, the file is read/write, non-system, not hidden, and has been');
- WriteLn('archived.');
- WriteLn;
-
- {Look for some parameter in command line}
-
- Mask:=Copy(CommandLine,2,127);
- While KeyPressed Do
- Read(Kbd,Dummy);
- Write('Press any key to continue...');
- Read(Kbd,Dummy);
- WriteLn;
- If Mask='' Then
-
- Start_Here: {If file name not specified, or restart requested, ask for target}
-
- Begin
- WriteLn;
- Write('Enter file name: ');
- ReadLn(Mask);
- End;
-
- {START OF FILE SEARCH}
-
- {Parse file name, force to upper case, look for directories and paths.}
-
- For I:=1 To Length(Mask) Do Mask[I]:=UpCase(Mask[I]);
- I:=Pos('\',Mask);
- If Pos(':',Mask)<>0 Then I:=Pos(':',Mask);
- If I<>0 Then
- Repeat
- J:=Pos('\',Copy(Mask,I+1,64));
- I:=I+J;
- Until J=0;
- DirAndOrPath:=Copy(Mask,1,I);
-
- {If only directory or path, set wildcards for all files.}
-
- If DirAndOrPath=Mask Then Mask:=Mask+'*.*';
-
- {Go to disk directory, get first (or only) file.}
-
- Mask[Length(Mask)+1]:=Chr(0);
- With Regs Do
- Begin
- AH:=$2F; {Get Disk Transfer Address (DTA)}
- MsDos(Regs);
- CurDataTransArea:=Ptr(ES,BX);
- AH:=$4E; {Search for first}
- DS:=Seg(Mask[1]);
- DX:=Ofs(Mask[1]);
- CX:=$17;
- MsDos(Regs);
- Finished:=False;
- None:=True;
-
- {START OF MAIN PROGRAM LOOP}
-
- {If drive, directory, path, or file not found, display error and terminate.}
-
- Repeat
- This:='';
- WriteLn;
- If (Flags And 1)<>0 Then
- Begin
- Beep;
- HighVideo;
- (*For some reason the following I/O error detection does not work*)
- Case AX Of {Limited Error Return Detection}
- 2: Write('File not found');
- 3: Write('Directory or path not found');
- 5: Write('Access denied. Illegal device specified');
- 15: Write('Invalid drive specified');
- 18: If None Then Write('Specified file ',Mask,' not found');
- else Write('Undefined error ');
- End;
- LowVideo;
- WriteLn;
- Finished:=True;
- End
- Else
-
- {If no error, then get first file and show attribute data.}
-
- Begin
- ERR:=0;
- None:=False;
- CurrentFile:=DirAndOrPath+
- Copy(CurDataTransArea^.FNam,1,Pos(#0,CurDataTransArea^.FNam));
-
- {START OF RECYCLE LOOP}
-
- Repeat;
- ClrScr;
- LowVideo;
- Write('File Attribute Program. Looking at: ');
- TextBackGround(White);
- TextColor(Black);
- WriteLn(Mask);
- LowVideo;
- If ERR<>0 Then
- Begin
- GotoXY(1,3);
- Warble;
- TextColor(LightGray + Blink);
- Write('Input error - ');
- HighVideo;
- WriteLN(' Try again.');
- LowVideo;
- ERR:=0;
- End;
- GotoXY(1,5);
- Write('Current File -> ');
- TextColor(White + Blink);
- Write(Copy(CurrentFile,1,Length(CurrentFile)-1));
- If This <> '' Then
- Begin
- LowVideo;
- Write(' reset to ');
- HighVideo;
- Write(This,'.');
- Beep;
- LowVideo;
- End;
- WriteLn;
- LowVideo;
- AX:=$4300; {Read current file attribute byte}
- DS:=Seg(CurrentFile[1]);
- DX:=Ofs(CurrentFile[1]);
- MsDos(Regs);
- GotoXY(1,7);
- Write('Normal, except-> |');
- AnAttributeSet:=False;
- For I:=0 To 7 Do
- If CX And (1 Shl I)<>0 Then
- Begin
- If AnAttributeSet Then Write(': ');
- Write(NowSet[I]);
- AnAttributeSet:=True;
- End;
- If Not AnAttributeSet Then Write('No exceptions');
- WriteLn('|');
- AttributeChanged:=False;
- GotoXY(1,9);
- WriteLn;
- WriteLn('Reset to: 1:' ,SetTo[CX AND 1]);
- WriteLn(' 2:' ,SetTo[(CX AND 2) Shr 1+2]);
- WriteLn(' 3:' ,SetTo[(CX AND 4) Shr 2+4]);
- WriteLn(' 4:' ,SetTo[(CX AND 32) Shr 5+6]);
- WriteLn(' or');
- WriteLn;
- WriteLn('Proceed to: 5:Abort Program.');
- WriteLn(' 6:Restart Program. No further changes.');
- WriteLn(' 0:Next File. No further changes.');
- WriteLn;
- WriteLn;
-
- {Ask for changes or other instructions.}
-
- Write('Your choice? (Default = Next file)-> ');
- C:=0;
- ERR:=0;
- This:='';
- ReadLn(Choice);
- If Length(Choice) > 1 Then Choice := ('a'); {Set to illegal value}
- Val(Choice,C,ERR); {Convert string to number, check for error.}
- If ERR<>0 Then C:=7; {Enable error trap, if input out of range.}
- Choice:='';
- Case C Of
- 1: This:=SetTo[CX AND 1];
- 2: This:=SetTo[(CX AND 2) Shr 1+2];
- 3: This:=SetTo[(CX AND 4) Shr 2+4];
- 4: This:=SetTo[(CX AND 32) Shr 5+6];
- End;
- Case C Of
- 1: CX:=CX Xor 1;
- 2: CX:=CX Xor 2;
- 3: CX:=CX Xor 4;
- 4: CX:=CX Xor 32;
- End;
- If C In [1..4] Then AttributeChanged:=True;
- If C=5 then Finished:=True;
- If C=6 Then Goto Start_here;
- If C=5 then C :=0;
- If C>7 Then C:=7; {Error Trap}
- If C=7 Then AttributeChanged:=True;
-
- {Not really, but doesn't matter, input error. Change nothing,
- set error flag, beep, redisplay, with error message.}
-
- If C = 7 Then ERR:=1;
-
- {If change requested, make it.}
-
- If AttributeChanged Then {Reset attribute Byte}
- Begin
- AX:=$4301;
- DS:=Seg(CurrentFile[1]);
- DX:=Ofs(CurrentFile[1]);
- CX:=CX And $FFE7;
- MsDos(Regs);
- End;
-
- {Loop back to same file, unless no change requested and no error on input.}
-
- Until C=0;
- AH:=$4F; {Search for next}
- MsDos(Regs);
- End;
-
- {Loop back to start of main program, get next file, unless end of requested
- files, or end of directory.}
-
- Until Finished;
-
- {Termination sequence.}
-
- WriteLn('End of specified files or end of directory.');
- WriteLn('End of program.');
- End;
-
- End. {Of Read_And_Set_File_Attributes}