diff --git a/Projects/RUTIS Wrappers/ruwa.lpi b/Projects/RUTIS Wrappers/ruwa.lpi index 24f3383..b30a17f 100644 --- a/Projects/RUTIS Wrappers/ruwa.lpi +++ b/Projects/RUTIS Wrappers/ruwa.lpi @@ -35,12 +35,12 @@ - + - + @@ -50,9 +50,9 @@ - - - + + + @@ -60,36 +60,36 @@ - + - + - + - + - + - + @@ -100,7 +100,7 @@ - + @@ -114,11 +114,11 @@ - + - + @@ -154,170 +154,188 @@ - - - + + + - + - + - + - + - - - + + + - + - + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - + - + @@ -344,7 +362,7 @@ - + @@ -354,6 +372,9 @@ + + + diff --git a/Projects/RUTIS Wrappers/wrapfiles.lfm b/Projects/RUTIS Wrappers/wrapfiles.lfm index 52da044..be0d188 100644 --- a/Projects/RUTIS Wrappers/wrapfiles.lfm +++ b/Projects/RUTIS Wrappers/wrapfiles.lfm @@ -65,6 +65,7 @@ object WrapFilesForm: TWrapFilesForm TabOrder = 4 end object FileDialog: TOpenDialog + Filter = 'Include files (*.inc)|*.inc|All files (*.*)|*.*' Options = [ofAllowMultiSelect, ofFileMustExist, ofEnableSizing, ofViewDetail] left = 32 top = 56 diff --git a/Projects/RUTIS Wrappers/wrapfiles.pas b/Projects/RUTIS Wrappers/wrapfiles.pas index 668a35c..e7ff5ba 100644 --- a/Projects/RUTIS Wrappers/wrapfiles.pas +++ b/Projects/RUTIS Wrappers/wrapfiles.pas @@ -45,6 +45,7 @@ procedure TWrapFilesForm.FileButtonClick(Sender: TObject); begin if FileDialog.Execute then begin + SaveDirEdit.Directory := ExtractFileDir(FileDialog.FileName); FileBox.Items.AddStrings(FileDialog.Files); end; end; @@ -61,21 +62,56 @@ procedure TWrapFilesForm.wrpBtnClick(Sender: TObject); var i : integer; - Input, Output : TFileStream; + Input, Output : TStringList; + NewFile : string; + YesToAll, NoToAll : boolean; begin + YesToAll:= false; + NoToAll:= false; if not DirectoryExists(SaveDirEdit.Directory) then begin - Writeln(format('Dir %s does not exist',[SaveDirEdit.Directory])); + dbg(format('Dir %s does not exist',[SaveDirEdit.Directory])); exit; end; - if not FileBox.Items.Count < 1 then + if FileBox.Items.Count < 1 then begin - Writeln('No files loaded'); + dbg('No files loaded'); exit; end; for i := 0 to FileBox.Items.Count - 1 do begin - + if not FileExists(filebox.items[i]) then + begin + dbg(format('File[%s] does not exist',[FileBox.items[i]])); + continue; + end; + NewFile := SaveDirEdit.Directory + DirectorySeparator + ExtractFileName(FileBox.Items[i]); + if not YesToAll and FileExists(NewFile) then + begin + if NoToAll then + Continue; + case MessageDlg('File already exists',Format('Do you want to overwrite the file %s',[NewFile]), + mtConfirmation,[mbYes,mbYesToAll,mbNo,mbNoToAll],0) of + mrNo : Continue; + mrNoToAll : begin + NoToAll:= True; + Continue; + end; + mrYesToAll : YesToAll:= true; + end; + end; + dbg(NewFile); + try + Input := TStringList.Create; + Input.LoadFromFile(filebox.items[i]); + Output := TStringList.Create; + ConvertRT(Input,dbgMemo.Lines,Output); + Output.SaveToFile(NewFile); + Input.free; + Output.free; + except + dbg('Something went wrong'); + end; end; end;