Hello,
we load all script files (project, script, form) from database. We have structured storage like directories and we have problem with managing events in TIDEEngine. There are two problems:
- IDEEngine tries to load project ini file from expanded path and next calll DoLoadFile
It's problem because code may accidentaly load some real file (it is security problem also)
function TIDEEngine.LoadProject: boolean;
var
MI: TMemIniFile;
ANewFile: TIDEProjectFile;
AFileName: string;
c, total: integer;
AMainUnitName: string;
SL: TStrings;
AFileContent: string;
AFileLanguage: integer;
begin
{Loads the list of files in the project, fill the files collection, and make all visible}
MI := TMemIniFile.Create(GetFullProjectFileName); --------------------------------------- HERE
try
{Load the text from file. Do it in two steps because we want to call OnLoadFile event
in case the file content is loaded from a blob or something like that}
SL := TStringList.Create;
try
AFileContent := '';
if DoLoadFile(iftProject, GetFullProjectFileName, AFileContent, nil) then
SL.Text := AFileContent
else
SL.LoadFromFile(GetFullProjectFileName);
{After loading file content, now set the content of memory ini file for retrieving information}
MI.SetStrings(SL);
finally
SL.Free;
end;
- Code still tries to expand filename using OS expand function for real files.
We can not load files from database, becuse we get wrong filename in OnLoadFile event. Here is a code snippet to demonstrate problem:
procedure TForm1.IDEEngine1CheckValidFile(Sender: TObject; IDEFileType: TIDEFileType; AFileName: string; var AValid: Boolean);
begin
//Here we check in database for validity
//
AValid:=true;
end;
procedure TForm1.IDEEngine1LoadFile(Sender: TObject; IDEFileType: TIDEFileType; AFileName: string; var AContent: string; AFile: TIDEProjectFile; var Handled: Boolean);
begin
// Here we need to load file from database, but filename is not valid = is expanded
ShowMessage(AFileName);
end;
procedure TForm1.IDEEngine1OpenDialog(Sender: TObject; IDEFileType: TIDEFileType; var AFileName: string; var ResultOk, Handled: Boolean);
begin
//here we have dialog for browse database structure
//
AFileName:='ProjA\project.ssproj';
ResultOk:=true;
handled:=true;
end;
Code should not intercept file names in this situation.
Thanks
Zdenek