iphonelazext: fix info.plist detection of xml format

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4585 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2016-03-23 13:17:53 +00:00
parent 312917e49c
commit 5598f9414b

View File

@ -142,21 +142,25 @@ function LoadFromFile(const fn: string; plist: TPListFile): Boolean;
var var
st : TFileStream; st : TFileStream;
buf : string[5]; buf : string[5];
res : integer;
{$ifdef darwin}
xs : string; xs : string;
err : LongWord; err : LongWord;
m : TStringStream; m : TStringStream;
doc : TXMLDocument; doc : TXMLDocument;
{$endif}
begin begin
//todo: detect plist type and convert is necessary //todo: detect plist type and convert is necessary
st:=TFileSTream.Create(fn, fmOpenRead or fmShareDenyNone); st:=TFileSTream.Create(fn, fmOpenRead or fmShareDenyNone);
try try
st.Read(buf, 5); SetLength(buf, 5);
res:=st.Read(buf[1], 5);
finally finally
st.Free; st.Free;
end; end;
if buf='<?xml' then if (res=5) and (buf='<?xml') then begin
Result:=LoadFromXML(fn, plist) Result:=LoadFromXML(fn, plist)
else begin end else begin
{$ifdef darwin} {$ifdef darwin}
// the utility is not available anywhere else but OSX // the utility is not available anywhere else but OSX
if not RunCommand('plutil', ['-convert','xml1','-o' ,'-', fn], xs) then begin if not RunCommand('plutil', ['-convert','xml1','-o' ,'-', fn], xs) then begin
@ -561,8 +565,6 @@ begin
end; end;
procedure TPListValue.Delete(idx: Integer); procedure TPListValue.Delete(idx: Integer);
var
i : integer;
begin begin
if (idx<0) or (idx>=count) then Exit; if (idx<0) or (idx>=count) then Exit;
items[idx].Free; items[idx].Free;