On Thu, 5 Dec 2013, Dennis Poon wrote:
I tried to read the mac address in the captioned file path.
In terminal, I can simply 'cat' and display the mac address.
In FPC, when I tried to use TFileStream to read it,
FS := TFileStream.Create('/sys/class/net/eth1/address',
fmOpenRead+fmShareDenyWrite);
it raised "stream read error"
home: >./t
00:1f:d0:a2:df:c4
home: >cat t.pp
{$mode objfpc}
{$H+}
uses sysutils, classes;
Var
S : String;
begin
SetLength(S,100);
with TFileStream.Create('/sys/class/net/eth1/address',
fmOpenRead+fmShareDenyWrite) do
try
SetLength(S,Read(S[1],100));
Writeln(S);
finally
free;
end;
end.
Works fine here. Permission problem on your machine maybe ?
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal