mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 10:49:27 +02:00
* fixed for unix
This commit is contained in:
parent
f12310a9f5
commit
b372bfe991
@ -2,6 +2,7 @@ uses
|
|||||||
{$ifdef ver1_0}
|
{$ifdef ver1_0}
|
||||||
linux,
|
linux,
|
||||||
{$else}
|
{$else}
|
||||||
|
baseunix,
|
||||||
unix,
|
unix,
|
||||||
{$endif}
|
{$endif}
|
||||||
lincd;
|
lincd;
|
||||||
@ -14,13 +15,17 @@ Var
|
|||||||
tocentry : tcdrom_tocentry;
|
tocentry : tcdrom_tocentry;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
drive:=fdopen(Device, Open_RDONLY or Open_NONBLOCK);
|
drive:={$ifdef ver1_0}fdopen{$else}fpOpen{$endif}(Device, Open_RDONLY or Open_NONBLOCK);
|
||||||
if drive<0 then
|
if drive<0 then
|
||||||
begin
|
begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
{$Ifdef ver1_0}
|
||||||
if not ioctl(drive, CDROMREADTOCHDR, @tochdr) then
|
if not ioctl(drive, CDROMREADTOCHDR, @tochdr) then
|
||||||
|
{$else}
|
||||||
|
if fpioctl(drive, CDROMREADTOCHDR, @tochdr)<>0 then
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
Exit;
|
Exit;
|
||||||
@ -34,7 +39,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
tocentry.cdte_track := i;
|
tocentry.cdte_track := i;
|
||||||
tocentry.cdte_format := CDROM_MSF;
|
tocentry.cdte_format := CDROM_MSF;
|
||||||
ioctl(drive, CDROMREADTOCENTRY, @tocentry);
|
{$ifdef ver1_0}ioctl{$else}fpIOCtl{$endif}(drive, CDROMREADTOCENTRY, @tocentry);
|
||||||
// We should do some error checking here actually.
|
// We should do some error checking here actually.
|
||||||
With cdtoc[result] do
|
With cdtoc[result] do
|
||||||
begin
|
begin
|
||||||
@ -48,7 +53,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
tocentry.cdte_track := $AA;
|
tocentry.cdte_track := $AA;
|
||||||
tocentry.cdte_format := CDROM_MSF;
|
tocentry.cdte_format := CDROM_MSF;
|
||||||
ioctl(drive, CDROMREADTOCENTRY, @tocentry);
|
{$ifdef ver1_0}ioctl{$else}fpIOCtl{$endif}(drive, CDROMREADTOCENTRY, @tocentry);
|
||||||
With cdtoc[Result] do
|
With cdtoc[Result] do
|
||||||
begin
|
begin
|
||||||
Min := tocentry.cdte_addr.msf.minute;
|
Min := tocentry.cdte_addr.msf.minute;
|
||||||
@ -58,7 +63,7 @@ begin
|
|||||||
inc(frame, sec*75);
|
inc(frame, sec*75);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
fdclose(drive);
|
{$ifdef ver1_0}fdclose{$else}fpClose{$endif}(drive);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
|
@ -22,6 +22,7 @@ uses
|
|||||||
{$ifdef ver1_0}
|
{$ifdef ver1_0}
|
||||||
linux
|
linux
|
||||||
{$else}
|
{$else}
|
||||||
|
baseunix,
|
||||||
unix
|
unix
|
||||||
{$endif}
|
{$endif}
|
||||||
;
|
;
|
||||||
@ -1155,14 +1156,23 @@ begin
|
|||||||
Writeln('Testing device : ',Device);
|
Writeln('Testing device : ',Device);
|
||||||
{$endif}
|
{$endif}
|
||||||
Result:=False;
|
Result:=False;
|
||||||
|
{$ifdef ver1_0}
|
||||||
If not fstat(device,info) then
|
If not fstat(device,info) then
|
||||||
|
{$else}
|
||||||
|
If fpstat(device,info)<>0 then
|
||||||
|
{$endif}
|
||||||
exit;
|
exit;
|
||||||
if not (S_ISCHR(info.mode) or S_ISBLK(info.mode)) then
|
if not ({$ifdef ver1_0}S_ISCHR{$else}fpS_ISCHR{$endif}(info.mode) or
|
||||||
|
{$Ifdef ver1_0}S_ISBLK{$else}fpS_ISBLK{$endif}(info.mode)) then
|
||||||
exit;
|
exit;
|
||||||
S:=ReadLink(Device);
|
S:={$ifdef ver1_0}ReadLink{$else}fpReadLink{$endif}(Device);
|
||||||
If (S<>'') then
|
If (S<>'') then
|
||||||
Device:=S;
|
Device:=S;
|
||||||
|
{$ifdef ver1_0}
|
||||||
If Not FStat(Device,info) then
|
If Not FStat(Device,info) then
|
||||||
|
{$else}
|
||||||
|
If fpStat(Device,info)<>0 then
|
||||||
|
{$endif}
|
||||||
exit;
|
exit;
|
||||||
DeviceMajor:=info.rdev shr 8;
|
DeviceMajor:=info.rdev shr 8;
|
||||||
If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
|
If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
|
||||||
@ -1176,10 +1186,10 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
F:=fdOpen(Device,OPEN_RDONLY or OPEN_NONBLOCK);
|
F:={$ifdef ver1_0}fdOpen{$else}fpOpen{$endif}(Device,OPEN_RDONLY or OPEN_NONBLOCK);
|
||||||
Result:=(F>=0);
|
Result:=(F>=0);
|
||||||
If Result then
|
If Result then
|
||||||
fdClose(F);
|
{$ifdef ver1_0}fdClose{$else}fpClose{$endif}(F);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1195,11 +1205,15 @@ begin
|
|||||||
Writeln('Testing for ATAPI');
|
Writeln('Testing for ATAPI');
|
||||||
{$endif}
|
{$endif}
|
||||||
Result:=False;
|
Result:=False;
|
||||||
f:=fdOpen(device,OPEN_RDONLY or OPEN_NONBLOCK);
|
f:={$ifdef ver1_0}fdOpen{$else}fpOpen{$endif}(device,OPEN_RDONLY or OPEN_NONBLOCK);
|
||||||
If (f<0) then
|
If (f<0) then
|
||||||
exit;
|
exit;
|
||||||
|
{$ifdef ver1_0}
|
||||||
Result:=ioctl(f,CDROMVOLREAD,@info);
|
Result:=ioctl(f,CDROMVOLREAD,@info);
|
||||||
fdClose(f);
|
{$else}
|
||||||
|
Result:=(fpIOCtl(f,CDROMVOLREAD,@info)=0);
|
||||||
|
{$endif}
|
||||||
|
{$ifdef ver1_0}fdClose{$else}fpClose{$endif}(f);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user