From 48f2d9c2bc3bf0ee693868e1732831a58ca4839f Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 8 Jan 2015 22:22:35 +0100 Subject: [PATCH] added handling of project file for first argument --- src/ce_main.pas | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ce_main.pas b/src/ce_main.pas index 2bca47ac..b839661c 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -333,23 +333,35 @@ end; procedure TCEMainForm.getCMdParams; var value: string; - str: TStringList; + lst: TStringList; + hdl: THandle; + str: string; begin if application.ParamCount > 0 then begin value := application.Params[1]; if value <> '' then begin - str := TStringList.Create; + setLength(str, 6); + lst := TStringList.Create; try - str.DelimitedText := value; - for value in str do + lst.DelimitedText := value; + for value in lst do 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); end; finally - str.Free; + lst.Free; end; end; end; @@ -362,16 +374,16 @@ begin value := application.GetOptionValue('f', 'files'); if value <> '' then begin - str := TStringList.Create; + lst := TStringList.Create; try - str.DelimitedText := value; - for value in str do + lst.DelimitedText := value; + for value in lst do begin if fileExists(value) then openFile(value); end; finally - str.Free; + lst.Free; end; end; end;