DEADSOFTWARE

do not use TFileStream directly, use `openDiskFileRO()` and `createDiskFile()` from...
authorKetmar Dark <ketmar@ketmar.no-ip.org>
Mon, 18 Apr 2016 07:28:30 +0000 (10:28 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Mon, 18 Apr 2016 07:28:30 +0000 (10:28 +0300)
also, use `findFileCI()` from "utils.pas" to find correct disk path/filename.
those calls will automatically do case-insensitive search on POSIX systems.

src/game/g_netmsg.pas
src/game/g_res_downloader.pas

index 44135d789b46439e6216fdd08c879d2d2b66298e..9df97c1c1a39a33341cea5e18dc1b812dba9211f 100644 (file)
@@ -256,8 +256,7 @@ uses
   Math, ENet, e_input, e_fixedbuffer, e_graphics, e_log,
   g_textures, g_gfx, g_sound, g_console, g_basic, g_options, g_main,
   g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
-  g_language, g_monsters, g_netmaster, sfs,
-  wadreader, MAPDEF;
+  g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
 
 const
   NET_KEY_LEFT     = 1;
@@ -2845,7 +2844,7 @@ end;
 
 function ReadFile(const FileName: TFileName): AByte;
 var
-  FileStream : TFileStream;
+  FileStream : TStream;
   fname: string;
 begin
   e_WriteLog(Format('NETWORK: looking for file "%s"', [FileName]), MSG_NOTIFY);
@@ -2858,7 +2857,7 @@ begin
   end;
   e_WriteLog(Format('NETWORK: found file "%s"', [fname]), MSG_NOTIFY);
   Result := nil;
-  FileStream:= TFileStream.Create(fname, fmOpenRead or {fmShareDenyWrite}fmShareDenyNone);
+  FileStream := openDiskFileRO(fname);
   try
     if FileStream.Size > 0 then
     begin
index cd0a3608617ea588d29fe6c6187bb8fadfdde913..77db011c0c546aa9358fba72bf7b3cccfb0a4257 100644 (file)
@@ -90,15 +90,14 @@ end;
 
 function SaveWAD(const path, filename: string; const data: array of Byte): string;
 var
-  resFile: TFileStream;
+  resFile: TStream;
+  dpt: string;
 begin
   try
-    Result := path + DOWNLOAD_DIR + '/' + filename;
-    if not DirectoryExists(path + DOWNLOAD_DIR) then
-    begin
-      CreateDir(path + DOWNLOAD_DIR);
-    end;
-    resFile := TFileStream.Create(Result, fmCreate);
+    result := path+DOWNLOAD_DIR+'/'+filename;
+    dpt := path+DOWNLOAD_DIR;
+    if not findFileCI(dpt, true) then CreateDir(dpt);
+    resFile := createDiskFile(result);
     resFile.WriteBuffer(data[0], Length(data));
     resFile.Free
   except
@@ -109,7 +108,7 @@ end;
 function g_Res_DownloadWAD(const FileName: string): string;
 var
   msgStream: TMemoryStream;
-  resStream: TFileStream;
+  resStream: TStream;
   mapData: TMapDataMsg;
   i: Integer;
   resData: TResDataMsg;
@@ -141,9 +140,7 @@ begin
       msgStream := g_Net_Wait_Event(NET_MSG_RES_RESPONSE);
       resData := ResDataFromMsgStream(msgStream);
 
-      resStream := TFileStream.Create(GameDir+'/wads/'+
-                                      mapData.ExternalResources[i].Name,
-                                      fmCreate);
+      resStream := createDiskFile(GameDir+'/wads/'+mapData.ExternalResources[i].Name);
       resStream.WriteBuffer(resData.FileData[0], resData.FileSize);
 
       resData.FileData := nil;