index cd0a3608617ea588d29fe6c6187bb8fadfdde913..c24e6f89bcb426b36c9cc9e8508e8b0a147ef6a2 100644 (file)
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
unit g_res_downloader;
interface
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
function g_Res_DownloadWAD(const FileName: string): string;
var
msgStream: TMemoryStream;
- resStream: TFileStream;
+ resStream: TStream;
mapData: TMapDataMsg;
i: Integer;
resData: TResDataMsg;
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;