summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e84d42d)
raw | patch | inline | side by side (parent: e84d42d)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 31 Jul 2022 11:03:16 +0000 (14:03 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 31 Jul 2022 11:03:16 +0000 (14:03 +0300) |
src/editor/Editor.lpi | patch | blob | history | |
src/editor/g_resources.pas | patch | blob | history |
diff --git a/src/editor/Editor.lpi b/src/editor/Editor.lpi
index f01210375595d4c169dffa7fc9368aeba44a7a00..ad2ecd7a66559ba01f9768d07e6efe1041eb9924 100644 (file)
--- a/src/editor/Editor.lpi
+++ b/src/editor/Editor.lpi
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi"/>
+ <IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
- <OptimizationLevel Value="3"/>
+ <OptimizationLevel Value="2"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
- <GenerateDebugInfo Value="False"/>
+ <GenerateDebugInfo Value="True"/>
<DebugInfoType Value="dsDwarf2Set"/>
- <UseValgrind Value="True"/>
- <StripSymbols Value="True"/>
+ <UseValgrind Value="False"/>
+ <StripSymbols Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
- <TrashVariables Value="True"/>
- <UseValgrind Value="True"/>
+ <TrashVariables Value="False"/>
+ <UseValgrind Value="False"/>
</Debugging>
<Options>
<Win32>
index bcb7da293ab8dfda54a19c0c3142d53e657302d7..85a78356f67bd3e6794c5394d075320b4a011f82 100644 (file)
+{$ASSERTIONS ON}
unit g_resources;
interface
(**
g_GetResourceSection
Parse path in form 'path/to/file.wad:some/section/resouce' to
- wad = 'path/to/file.wa', section = 'some/section', name = 'resource'
+ wad = 'path/to/file.wad', section = 'some/section', name = 'resource'
g_DeleteFile
Delete file if it exists. Make backup if enabled.
+ return true when file not exists.
g_ReadResource
Read whole file from wad
Backup: Boolean;
procedure g_GetResourceSection (path: String; out wad, section, name: String);
- procedure g_DeleteFile(wad: String; backupPostfix: String = '.bak');
+ function g_DeleteFile(wad: String; backupPostfix: String = '.bak'): Boolean;
procedure g_ReadResource (wad, section, name: String; out data: PByte; out len: Integer);
procedure g_ReadSubResource (wad, section0, name0, section1, name1: String; out data: PByte; out len: Integer);
wad := Copy(path, 1, i - 1);
end;
- procedure g_DeleteFile (wad: String; backupPostfix: String = '.bak');
- var newwad: String;
+ function g_DeleteFile (wad: String; backupPostfix: String = '.bak'): Boolean;
+ var newwad: String; ok: Boolean;
begin
SFSGCCollect;
SFSGCCollect;
SFSGCCollect;
- if Backup then
+ ok := true;
+ if FileExists(wad) then
begin
- if FileExists(wad) then
+ if Backup then
begin
newwad := wad + backupPostfix;
- if FileExists(newwad) then
- ASSERT(DeleteFile(newwad), 'Can''t delete file ' + newwad);
- ASSERT(RenameFile(wad, newwad), 'Can''t rename file ' + wad + ' -> ' + newwad)
+ if FileExists(newwad) then ok := DeleteFile(newwad);
+ if ok then ok := RenameFile(wad, newwad);
end
- end
- else
- begin
- if FileExists(wad) then
- ASSERT(DeleteFile(wad), 'Can''t delete file ' + newwad)
- end
+ else
+ ok := DeleteFile(wad);
+ end;
+ result := ok;
end;
procedure g_AddResourceToDFWAD (wad, section, name: String; const data: PByte; len: Integer; out res: Integer);
tmp, path: String;
ts: TFileStream;
dir: array of TFileInfo;
+ ok: Boolean;
procedure Add (name: String; data: PByte; len: Integer);
var ds: TSFSMemoryChunkStream;
dfzip.writeCentralDir(ts, dir);
ts.Free;
- g_DeleteFile(wad);
- ASSERT(RenameFile(tmp, wad), 'Can''t rename file ' + tmp + ' -> ' + wad);
- res := 0
+ ok := g_DeleteFile(wad);
+ if not ok then e_WriteLog('Cant delete older wad [' + wad + ']', TRecordCategory.MSG_WARNING);
+ ok := RenameFile(tmp, wad);
+ if not ok then e_WriteLog('ERROR: Cant rename [' + tmp + '] -> [' + wad + ']', TRecordCategory.MSG_WARNING);
+ if ok then res := 0 else res := 2;
end;
procedure g_AddResource (wad, section, name: String; const data: PByte; len: Integer; out res: Integer);
tmp, path: String;
ts: TFileStream;
dir: array of TFileInfo;
+ ok: Boolean;
procedure Add (name: String; data: PByte; len: Integer);
var ds: TSFSMemoryChunkStream;
dfzip.writeCentralDir(ts, dir);
ts.Free;
- g_DeleteFile(wad);
- ASSERT(RenameFile(tmp, wad), 'Can''t rename file ' + tmp + ' -> ' + wad);
- res := 0
+ ok := g_DeleteFile(wad);
+ if not ok then e_WriteLog('Cant delete older wad [' + wad + ']', TRecordCategory.MSG_WARNING);
+ ok := RenameFile(tmp, wad);
+ if not ok then e_WriteLog('ERROR: Cant rename [' + tmp + '] -> [' + wad + ']', TRecordCategory.MSG_WARNING);
+ if ok then res := 0 else res := 2;
end;
procedure g_DeleteResource (wad, section, name: String; out res: Integer);