For you who likes the simplicity, this solution should delight you.
When loading a new or recent VFS , if the actual is modified , there was nothing to ask saving before.
From now on it will exist in the future build.
procedure TmainFrm.Loadfilesystem1Click(Sender: TObject);
var
fn: string;
begin
if blockLoadSave() then exit;
if VFSModified then
case msgDlg('VFS has changed, save current file system before open new?',MB_ICONINFORMATION+MB_YESNOCANCEL) of
IDYES: begin
mainfrm.saveVFS(lastFileOpen);
if not VFSModified then msgDlg('The VFS was correctly saved,'#13#13'click on OK to continue', MB_ICONASTERISK);
end;
IDNO: ; // just go on
IDCANCEL: exit;
end;
fn:='';
if PromptForFileName(fn, 'VirtualFileSystem|*.vfs', 'vfs', 'Open VFS file') then
loadVFS(fn);
end;
............
procedure Tmainfrm.recentsClick(sender:Tobject);
var
i: integer;
begin
if blockLoadSave() then exit;
i:=strToInt((sender as Tmenuitem).Caption[3]);
if i > length(recentFiles) then exit;
dec(i); // convert to zero based
if FileExists(recentFiles) then
if vfsmodified then
case msgDlg('VFS has changed, save current file system before select new file?',MB_ICONINFORMATION+MB_YESNOCANCEL) of
IDYES: begin
mainfrm.saveVFS(lastFileOpen);
if not VFSModified then msgDlg('The VFS was correctly saved,'#13#13'click on OK to continue', MB_ICONASTERISK);
end;
IDNO: begin
loadVFS(recentFiles)
end;
IDCANCEL: exit;
end
else
loadVFS(recentFiles)
else
begin
msgDlg('The file does not exist anymore', MB_ICONERROR);
removeString(recentFiles, i);
updateRecentFilesMenu();
end;
end;