added handling of project file for first argument

This commit is contained in:
Basile Burg 2015-01-08 22:22:35 +01:00
parent 5e68e70ba6
commit 48f2d9c2bc
1 changed files with 22 additions and 10 deletions

View File

@ -333,23 +333,35 @@ end;
procedure TCEMainForm.getCMdParams; procedure TCEMainForm.getCMdParams;
var var
value: string; value: string;
str: TStringList; lst: TStringList;
hdl: THandle;
str: string;
begin begin
if application.ParamCount > 0 then if application.ParamCount > 0 then
begin begin
value := application.Params[1]; value := application.Params[1];
if value <> '' then if value <> '' then
begin begin
str := TStringList.Create; setLength(str, 6);
lst := TStringList.Create;
try try
str.DelimitedText := value; lst.DelimitedText := value;
for value in str do for value in lst do
begin begin
if fileExists(value) then if not fileExists(value) then
continue;
hdl := FileOpen(value, fmOpenRead);
if hdl = 0 then
continue;
FileRead(hdl, str[1], length(str));
FileClose(hdl);
if str = 'object' then
openProj(value)
else
openFile(value); openFile(value);
end; end;
finally finally
str.Free; lst.Free;
end; end;
end; end;
end; end;
@ -362,16 +374,16 @@ begin
value := application.GetOptionValue('f', 'files'); value := application.GetOptionValue('f', 'files');
if value <> '' then if value <> '' then
begin begin
str := TStringList.Create; lst := TStringList.Create;
try try
str.DelimitedText := value; lst.DelimitedText := value;
for value in str do for value in lst do
begin begin
if fileExists(value) then if fileExists(value) then
openFile(value); openFile(value);
end; end;
finally finally
str.Free; lst.Free;
end; end;
end; end;
end; end;