From: Ketmar Dark Date: Mon, 18 Apr 2016 07:28:30 +0000 (+0300) Subject: do not use TFileStream directly, use `openDiskFileRO()` and `createDiskFile()` from... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=423556f23c02a18964bd2c1e125516c0c902ca46;p=d2df-sdl.git do not use TFileStream directly, use `openDiskFileRO()` and `createDiskFile()` from "utils.pas" also, use `findFileCI()` from "utils.pas" to find correct disk path/filename. those calls will automatically do case-insensitive search on POSIX systems. --- diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 44135d7..9df97c1 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -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 diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index cd0a360..77db011 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -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;