mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 08:27:02 +02:00
+ few changes/cleanups here and there, untested
git-svn-id: trunk@2571 -
This commit is contained in:
parent
fbc08c229d
commit
08aa0b4755
@ -118,58 +118,59 @@ begin
|
|||||||
IsLeapYear:=False;
|
IsLeapYear:=False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure Amiga2DateStamp(Date : LongInt; Var TotalDays,Minutes,Ticks: longint);
|
procedure Amiga2DateStamp(Date : LongInt; var TotalDays,Minutes,Ticks: longint);
|
||||||
{ Converts a value in seconds past 1978 to a value in AMIGA DateStamp format }
|
{ Converts a value in seconds past 1978 to a value in AMIGA DateStamp format }
|
||||||
{ Taken from SWAG and modified to work with the Amiga format - CEC }
|
{ Taken from SWAG and modified to work with the Amiga format - CEC }
|
||||||
Var
|
var
|
||||||
LocalDate : LongInt; Done : Boolean; TotDays : Integer;
|
LocalDate : LongInt;
|
||||||
|
Done : Boolean;
|
||||||
|
TotDays : Integer;
|
||||||
Y: Word;
|
Y: Word;
|
||||||
H: Word;
|
H: Word;
|
||||||
Min: Word;
|
Min: Word;
|
||||||
S : Word;
|
S : Word;
|
||||||
Begin
|
begin
|
||||||
Y := 1978; H := 0; Min := 0; S := 0;
|
Y := 1978; H := 0; Min := 0; S := 0;
|
||||||
TotalDays := 0;
|
TotalDays := 0;
|
||||||
Minutes := 0;
|
Minutes := 0;
|
||||||
Ticks := 0;
|
Ticks := 0;
|
||||||
LocalDate := Date;
|
LocalDate := Date;
|
||||||
Done := False;
|
Done := false;
|
||||||
While Not Done Do
|
while not Done do
|
||||||
Begin
|
begin
|
||||||
If LocalDate >= SecsPerYear Then
|
if LocalDate >= SecsPerYear then
|
||||||
Begin
|
begin
|
||||||
Inc(Y,1);
|
Inc(Y,1);
|
||||||
Dec(LocalDate,SecsPerYear);
|
Dec(LocalDate,SecsPerYear);
|
||||||
Inc(TotalDays,DaysPerYear[12]);
|
Inc(TotalDays,DaysPerYear[12]);
|
||||||
End
|
end else
|
||||||
Else
|
Done := true;
|
||||||
Done := True;
|
if (IsLeapYear(Y+1)) and (LocalDate >= SecsPerLeapYear) and
|
||||||
If (IsLeapYear(Y+1)) And (LocalDate >= SecsPerLeapYear) And
|
(Not Done) then
|
||||||
(Not Done) Then
|
begin
|
||||||
Begin
|
|
||||||
Inc(Y,1);
|
Inc(Y,1);
|
||||||
Dec(LocalDate,SecsPerLeapYear);
|
Dec(LocalDate,SecsPerLeapYear);
|
||||||
Inc(TotalDays,DaysPerLeapYear[12]);
|
Inc(TotalDays,DaysPerLeapYear[12]);
|
||||||
End;
|
end;
|
||||||
End; { END WHILE }
|
end; { END WHILE }
|
||||||
Done := False;
|
|
||||||
TotDays := LocalDate Div SecsPerDay;
|
TotDays := LocalDate Div SecsPerDay;
|
||||||
{ Total number of days }
|
{ Total number of days }
|
||||||
TotalDays := TotalDays + TotDays;
|
TotalDays := TotalDays + TotDays;
|
||||||
Dec(LocalDate,TotDays*SecsPerDay);
|
Dec(LocalDate,TotDays*SecsPerDay);
|
||||||
{ Absolute hours since start of day }
|
{ Absolute hours since start of day }
|
||||||
H := LocalDate Div SecsPerHour;
|
H := LocalDate Div SecsPerHour;
|
||||||
{ Convert to minutes }
|
{ Convert to minutes }
|
||||||
Minutes := H*60;
|
Minutes := H*60;
|
||||||
Dec(LocalDate,(H * SecsPerHour));
|
Dec(LocalDate,(H * SecsPerHour));
|
||||||
{ Find the remaining minutes to add }
|
{ Find the remaining minutes to add }
|
||||||
Min := LocalDate Div SecsPerMinute;
|
Min := LocalDate Div SecsPerMinute;
|
||||||
Dec(LocalDate,(Min * SecsPerMinute));
|
Dec(LocalDate,(Min * SecsPerMinute));
|
||||||
Minutes:=Minutes+Min;
|
Minutes:=Minutes+Min;
|
||||||
{ Find the number of seconds and convert to ticks }
|
{ Find the number of seconds and convert to ticks }
|
||||||
S := LocalDate;
|
S := LocalDate;
|
||||||
Ticks:=TICKSPERSECOND*S;
|
Ticks:=TICKSPERSECOND*S;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function dosSetProtection(const name: string; mask:longint): Boolean;
|
function dosSetProtection(const name: string; mask:longint): Boolean;
|
||||||
@ -182,7 +183,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function dosSetFileDate(name: string; p : PDateStamp): Boolean;
|
function dosSetFileDate(name: string; p : PDateStamp): Boolean;
|
||||||
var buffer : array[0..255] of Char;
|
var
|
||||||
|
buffer : array[0..255] of Char;
|
||||||
begin
|
begin
|
||||||
move(name[1],buffer,length(name));
|
move(name[1],buffer,length(name));
|
||||||
buffer[length(name)]:=#0;
|
buffer[length(name)]:=#0;
|
||||||
@ -204,17 +206,16 @@ end;
|
|||||||
{ Here are a lot of stuff just for setdate and settime }
|
{ Here are a lot of stuff just for setdate and settime }
|
||||||
|
|
||||||
var
|
var
|
||||||
TimerBase : Pointer;
|
TimerBase : Pointer;
|
||||||
|
|
||||||
|
|
||||||
procedure NewList (list: pList);
|
procedure NewList (list: pList);
|
||||||
begin
|
begin
|
||||||
with list^ do
|
with list^ do begin
|
||||||
begin
|
lh_Head := pNode(@lh_Tail);
|
||||||
lh_Head := pNode(@lh_Tail);
|
lh_Tail := NIL;
|
||||||
lh_Tail := NIL;
|
lh_TailPred := pNode(@lh_Head)
|
||||||
lh_TailPred := pNode(@lh_Head)
|
end;
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateExtIO (port: pMsgPort; size: Longint): pIORequest;
|
function CreateExtIO (port: pMsgPort; size: Longint): pIORequest;
|
||||||
@ -288,7 +289,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function Create_Timer(theUnit : longint) : pTimeRequest;
|
function Create_Timer(theUnit : longint) : pTimeRequest;
|
||||||
var
|
var
|
||||||
Error : longint;
|
Error : longint;
|
||||||
TimerPort : pMsgPort;
|
TimerPort : pMsgPort;
|
||||||
@ -363,26 +364,26 @@ begin
|
|||||||
get_sys_time := 0;
|
get_sys_time := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure GetDate(Var Year, Month, MDay, WDay: Word);
|
procedure GetDate(Var Year, Month, MDay, WDay: Word);
|
||||||
Var
|
var
|
||||||
cd : pClockData;
|
cd : pClockData;
|
||||||
oldtime : ttimeval;
|
oldtime : ttimeval;
|
||||||
begin
|
begin
|
||||||
New(cd);
|
new(cd);
|
||||||
get_sys_time(@oldtime);
|
get_sys_time(@oldtime);
|
||||||
Amiga2Date(oldtime.tv_secs,cd);
|
Amiga2Date(oldtime.tv_secs,cd);
|
||||||
Year := cd^.year;
|
Year := cd^.year;
|
||||||
Month := cd^.month;
|
Month := cd^.month;
|
||||||
MDay := cd^.mday;
|
MDay := cd^.mday;
|
||||||
WDay := cd^.wday;
|
WDay := cd^.wday;
|
||||||
Dispose(cd);
|
dispose(cd);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure SetDate(Year, Month, Day: Word);
|
[rocedure SetDate(Year, Month, Day: Word);
|
||||||
var
|
var
|
||||||
cd : pClockData;
|
cd : pClockData;
|
||||||
oldtime : ttimeval;
|
oldtime : ttimeval;
|
||||||
Begin
|
begin
|
||||||
new(cd);
|
new(cd);
|
||||||
get_sys_time(@oldtime);
|
get_sys_time(@oldtime);
|
||||||
Amiga2Date(oldtime.tv_secs,cd);
|
Amiga2Date(oldtime.tv_secs,cd);
|
||||||
@ -391,29 +392,29 @@ Begin
|
|||||||
cd^.mday := Day;
|
cd^.mday := Day;
|
||||||
set_new_time(Date2Amiga(cd),0);
|
set_new_time(Date2Amiga(cd),0);
|
||||||
dispose(cd);
|
dispose(cd);
|
||||||
End;
|
end;
|
||||||
|
|
||||||
Procedure GetTime(Var Hour, Minute, Second, Sec100: Word);
|
procedure GetTime(Var Hour, Minute, Second, Sec100: Word);
|
||||||
Var
|
var
|
||||||
cd : pClockData;
|
cd : pClockData;
|
||||||
oldtime : ttimeval;
|
oldtime : ttimeval;
|
||||||
begin
|
begin
|
||||||
New(cd);
|
new(cd);
|
||||||
get_sys_time(@oldtime);
|
get_sys_time(@oldtime);
|
||||||
Amiga2Date(oldtime.tv_secs,cd);
|
Amiga2Date(oldtime.tv_secs,cd);
|
||||||
Hour := cd^.hour;
|
Hour := cd^.hour;
|
||||||
Minute := cd^.min;
|
Minute := cd^.min;
|
||||||
Second := cd^.sec;
|
Second := cd^.sec;
|
||||||
Sec100 := oldtime.tv_micro div 10000;
|
Sec100 := oldtime.tv_micro div 10000;
|
||||||
Dispose(cd);
|
dispose(cd);
|
||||||
END;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure SetTime(Hour, Minute, Second, Sec100: Word);
|
Procedure SetTime(Hour, Minute, Second, Sec100: Word);
|
||||||
var
|
var
|
||||||
cd : pClockData;
|
cd : pClockData;
|
||||||
oldtime : ttimeval;
|
oldtime : ttimeval;
|
||||||
Begin
|
begin
|
||||||
new(cd);
|
new(cd);
|
||||||
get_sys_time(@oldtime);
|
get_sys_time(@oldtime);
|
||||||
Amiga2Date(oldtime.tv_secs,cd);
|
Amiga2Date(oldtime.tv_secs,cd);
|
||||||
@ -422,7 +423,7 @@ Begin
|
|||||||
cd^.sec := Second;
|
cd^.sec := Second;
|
||||||
set_new_time(Date2Amiga(cd), Sec100 * 10000);
|
set_new_time(Date2Amiga(cd), Sec100 * 10000);
|
||||||
dispose(cd);
|
dispose(cd);
|
||||||
End;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetMsCount: int64;
|
function GetMsCount: int64;
|
||||||
@ -438,55 +439,50 @@ end;
|
|||||||
******************************************************************************}
|
******************************************************************************}
|
||||||
|
|
||||||
|
|
||||||
Procedure Exec (Const Path: PathStr; Const ComLine: ComStr);
|
procedure Exec(const Path: PathStr; const ComLine: ComStr);
|
||||||
var
|
var
|
||||||
p : string;
|
tmpPath: array[0..255] of char;
|
||||||
buf: array[0..255] of char;
|
result : longint;
|
||||||
result : longint;
|
MyLock : longint;
|
||||||
MyLock : longint;
|
begin
|
||||||
i : Integer;
|
DosError := 0;
|
||||||
Begin
|
LastDosExitCode := 0;
|
||||||
DosError := 0;
|
tmpPath:=PathConv(Path+' '+ComLine);
|
||||||
LastdosExitCode := 0;
|
Move(p[1],buf,length(p));
|
||||||
p:=Path+' '+ComLine;
|
buf[Length(p)]:=#0;
|
||||||
{ allow backslash as slash }
|
|
||||||
for i:=1 to length(p) do
|
{ Here we must first check if the command we wish to execute }
|
||||||
if p[i]='\' then p[i]:='/';
|
{ actually exists, because this is NOT handled by the }
|
||||||
Move(p[1],buf,length(p));
|
{ _SystemTagList call (program will abort!!) }
|
||||||
buf[Length(p)]:=#0;
|
|
||||||
{ Here we must first check if the command we wish to execute }
|
|
||||||
{ actually exists, because this is NOT handled by the }
|
|
||||||
{ _SystemTagList call (program will abort!!) }
|
|
||||||
|
|
||||||
{ Try to open with shared lock }
|
{ Try to open with shared lock }
|
||||||
MyLock:=dosLock(Path,SHARED_LOCK);
|
MyLock:=dosLock(Path,SHARED_LOCK);
|
||||||
if MyLock <> 0 then
|
if MyLock <> 0 then
|
||||||
Begin
|
begin
|
||||||
{ File exists - therefore unlock it }
|
{ File exists - therefore unlock it }
|
||||||
Unlock(MyLock);
|
Unlock(MyLock);
|
||||||
result:=SystemTagList(buf,nil);
|
result:=SystemTagList(buf,nil);
|
||||||
{ on return of -1 the shell could not be executed }
|
{ on return of -1 the shell could not be executed }
|
||||||
{ probably because there was not enough memory }
|
{ probably because there was not enough memory }
|
||||||
if result = -1 then
|
if result = -1 then
|
||||||
DosError:=8
|
DosError:=8
|
||||||
else
|
else
|
||||||
LastDosExitCode:=word(result);
|
LastDosExitCode:=word(result);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
DosError:=3;
|
DosError:=3;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure GetCBreak(Var BreakValue: Boolean);
|
procedure GetCBreak(Var BreakValue: Boolean);
|
||||||
Begin
|
begin
|
||||||
breakvalue := system.BreakOn;
|
breakvalue := system.BreakOn;
|
||||||
End;
|
end;
|
||||||
|
|
||||||
|
procedure SetCBreak(BreakValue: Boolean);
|
||||||
Procedure SetCBreak(BreakValue: Boolean);
|
begin
|
||||||
Begin
|
system.Breakon := BreakValue;
|
||||||
system.Breakon := BreakValue;
|
end;
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
||||||
{******************************************************************************
|
{******************************************************************************
|
||||||
@ -785,14 +781,14 @@ end;
|
|||||||
if assigned(DateStamp) then Dispose(DateStamp);
|
if assigned(DateStamp) then Dispose(DateStamp);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure getfattr(var f; var attr : word);
|
procedure getfattr(var f; var attr : word);
|
||||||
var
|
var
|
||||||
info : pFileInfoBlock;
|
info : pFileInfoBlock;
|
||||||
MyLock : Longint;
|
MyLock : Longint;
|
||||||
flags: word;
|
flags: word;
|
||||||
Str: String;
|
Str: String;
|
||||||
i: integer;
|
i: integer;
|
||||||
Begin
|
begin
|
||||||
DosError:=0;
|
DosError:=0;
|
||||||
flags:=0;
|
flags:=0;
|
||||||
New(info);
|
New(info);
|
||||||
@ -830,37 +826,29 @@ end;
|
|||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
||||||
Procedure setfattr (var f;attr : word);
|
procedure setfattr(var f; attr : word);
|
||||||
var
|
var
|
||||||
flags: longint;
|
flags: longint;
|
||||||
MyLock : longint;
|
tmpLock : longint;
|
||||||
str: string;
|
begin
|
||||||
i: integer;
|
DosError:=0;
|
||||||
Begin
|
flags:=FIBF_WRITE;
|
||||||
DosError:=0;
|
|
||||||
flags:=FIBF_WRITE;
|
|
||||||
{ open with shared lock }
|
|
||||||
Str := StrPas(filerec(f).name);
|
|
||||||
for i:=1 to length(Str) do
|
|
||||||
if str[i]='\' then str[i]:='/';
|
|
||||||
|
|
||||||
MyLock:=dosLock(Str,SHARED_LOCK);
|
{ no need for path conversion here, because file opening already }
|
||||||
|
{ converts the path (KB) }
|
||||||
|
|
||||||
{ By default files are read-write }
|
{ create a shared lock on the file }
|
||||||
if attr AND ReadOnly <> 0 then
|
tmpLock:=Lock(filerec(f).name,SHARED_LOCK);
|
||||||
{ Clear the Fibf_write flags }
|
|
||||||
flags:=FIBF_READ;
|
|
||||||
|
|
||||||
|
{ By default files are read-write }
|
||||||
|
if attr and ReadOnly <> 0 then flags:=FIBF_READ; { Clear the Fibf_write flags }
|
||||||
|
|
||||||
if MyLock <> 0 then
|
if MyLock <> 0 then begin
|
||||||
Begin
|
Unlock(MyLock);
|
||||||
Unlock(MyLock);
|
if not SetProtection(filerec(f).name,flags) then DosError:=5;
|
||||||
if Not dosSetProtection(Str,flags) then
|
end else
|
||||||
DosError:=5;
|
DosError:=3;
|
||||||
end
|
end;
|
||||||
else
|
|
||||||
DosError:=3;
|
|
||||||
End;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -868,8 +856,8 @@ Procedure setfattr (var f;attr : word);
|
|||||||
--- Environment ---
|
--- Environment ---
|
||||||
******************************************************************************}
|
******************************************************************************}
|
||||||
|
|
||||||
var
|
var
|
||||||
StrofPaths : string[255];
|
strofpaths : string[255];
|
||||||
|
|
||||||
function getpathstring: string;
|
function getpathstring: string;
|
||||||
var
|
var
|
||||||
@ -995,9 +983,9 @@ begin
|
|||||||
UnLockDosList(LDF_DEVICES or LDF_READ );
|
UnLockDosList(LDF_DEVICES or LDF_READ );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Begin
|
begin
|
||||||
DosError:=0;
|
DosError:=0;
|
||||||
numberofdevices := 0;
|
numberofdevices := 0;
|
||||||
StrOfPaths := '';
|
StrOfPaths := '';
|
||||||
ReadInDevices;
|
ReadInDevices;
|
||||||
End.
|
end.
|
||||||
|
@ -125,7 +125,7 @@ begin
|
|||||||
delete(path,tmppos,2);
|
delete(path,tmppos,2);
|
||||||
tmppos:=pos('./',path);
|
tmppos:=pos('./',path);
|
||||||
end;
|
end;
|
||||||
{ convert wildstart to #? }
|
{ convert wildstar to #? }
|
||||||
tmppos:=pos('*',path);
|
tmppos:=pos('*',path);
|
||||||
while tmppos<>0 do begin
|
while tmppos<>0 do begin
|
||||||
delete(path,tmppos,1);
|
delete(path,tmppos,1);
|
||||||
|
Loading…
Reference in New Issue
Block a user