How to open and read "/proc/cpuinfo" on Android device in Delphi -
could advise me how open , read "/proc/cpuinfo" on android device in delphi?
original code:
var i: integer; fs: tfilestream; lbuffer: tbytes; begin if fileexists('/proc/cpuinfo') begin fs:= tfilestream.create('/proc/cpuinfo', fmopenread); try setlength(lbuffer, fs.size); fs.readbuffer(pointer(lbuffer)^, length(lbuffer)); i:= 0 length(lbuffer) - 1 memo1.lines.add(lbuffer[i]); fs.free; end; end; end;
the problem size of fs -1 , therefore not read ...
the answer simple (tested):
var fs: tfilestream; ch: char; rawline: system.unicodestring; begin if fileexists('/proc/cpuinfo') begin try rawline:= ''; ch := #0; fs:= tfilestream.create('/proc/cpuinfo', fmopenread); while (fs.read( ch, 1) = 1) , (ch <> #13) begin rawline := rawline + ch end; memo1.lines.append(rawline); fs.free; end; end; end;
enjoy testing ;)
Comments
Post a Comment