home *** CD-ROM | disk | FTP | other *** search
- PROGRAM touch; {set matching files date/time}
-
- VAR
- search_name, path : STRING[127];
- regs : RECORD AX, BX, CX, DX, BP, SI, DI, DS, ES, FLAGS : Integer; END;
- dta : RECORD
- dosuse : ARRAY[1..21] OF Byte;
- attribute : Byte;
- time, date, lowsiz, highsiz : Integer;
- namext : ARRAY[1..13] OF Char; {terminated by a 0}
- restofdta : ARRAY[0..255] OF Byte;
- END;
- current_date, current_time, set_count : Integer;
- p : Byte;
-
- BEGIN
- IF ParamCount = 1 THEN
- BEGIN
- search_name := ParamStr(1)+#0;
- WITH regs DO
- BEGIN
- AX := $1A00; DS := DSeg; DX := Ofs(dta); MsDos(regs); {set dta}
- AX := $4E00; DS := DSeg; DX := Ofs(search_name[1]); {find first}
- CX := 7; {hidden file search}
- MsDos(regs);
- IF NOT Odd(flags) {test carry flag} THEN
- BEGIN
- AX := $2A00;
- MsDos(regs);
- current_date := (CX-1980) SHL 9 OR DX AND $F00 SHR 3 OR DX AND $1F;
-
- AX := $2C00;
- MsDos(regs);
- current_time := CX AND $1F00 SHL 3 OR CX AND $3F SHL 5 OR DX SHR 9;
-
- path := search_name;
- p := Length(path);
- WHILE (p > 0) AND NOT(path[p] IN [':', '\']) DO
- BEGIN Delete(path, p, 1); p := p-1; END;
-
- set_count := 0;
- REPEAT
- WITH dta DO
- BEGIN {touch file}
- AX := $3D00; {open file}
- DS := DSeg;
- search_name := path;
- p := 0;
- REPEAT
- p := p+1;
- search_name := search_name+namext[p];
- UNTIL namext[p] = #0;
- DX := Ofs(search_name[1]);
- MsDos(regs);
-
- BX := AX; {handle}
- AX := $5701; {set files date/time}
- DX := (current_date);
- CX := (current_time);
- MsDos(regs);
- IF Odd(flags) THEN WriteLn('Unable to set file')
- ELSE set_count := set_count+1;
-
- AX := $3E00; {close handle}
- MsDos(regs);
- END;
- AX := $4F00; {find next file}
- MsDos(regs);
- UNTIL AX = 18;
- WriteLn(set_count, ' file(s) set to current date and time');
- END
- ELSE WriteLn('No files found');
- END;
- END ELSE BEGIN
- WriteLn('Sets date and time stamp of all matching files to present:');
- WriteLn(' e.g. touch c:\turbo\t*.pas');
- END;
- END.
-