From: Ketmar Dark Date: Sun, 17 Apr 2016 05:57:16 +0000 (+0300) Subject: network: it should find correct files on POSIX now (and substitute extensions too) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=41d480b02f4d0257f13a87810c0053b8b0df3b13;p=d2df-sdl.git network: it should find correct files on POSIX now (and substitute extensions too) --- diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index 9547335..fc815da 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -9,7 +9,7 @@ function g_Res_DownloadWAD(const FileName: string): string; implementation -uses g_language; +uses g_language, sfs, WADEDITOR; const DOWNLOAD_DIR = 'downloads'; @@ -23,15 +23,14 @@ begin repeat if (searchResult.Attr and faDirectory) = 0 then begin - if searchResult.Name = filename then + if SFSStrEqu(searchResult.Name, filename) then begin files.Add(dirName+'/'+filename); Exit; end; end else if (searchResult.Name <> '.') and (searchResult.Name <> '..') then - FindFiles(IncludeTrailingPathDelimiter(dirName)+searchResult.Name, - filename, files); + FindFiles(IncludeTrailingPathDelimiter(dirName)+searchResult.Name, filename, files); until FindNext(searchResult) <> 0; finally FindClose(searchResult); @@ -42,14 +41,21 @@ end; function CompareFileHash(const filename: string; const resMd5: TMD5Digest): Boolean; var gResHash: TMD5Digest; + fname: string; begin - gResHash := MD5File(filename); + fname := findDiskWad(filename); + if length(fname) = 0 then begin result := false; exit; end; + gResHash := MD5File(fname); Result := MD5Match(gResHash, resMd5); end; function CheckFileHash(const path, filename: string; const resMd5: TMD5Digest): Boolean; +var + fname: string; begin - Result := FileExists(path + filename) and CompareFileHash(path + filename, resMd5); + fname := findDiskWad(path+filename); + if length(fname) = 0 then begin result := false; exit; end; + Result := FileExists(fname) and CompareFileHash(fname, resMd5); end; function g_Res_SearchSameWAD(const path, filename: string; const resMd5: TMD5Digest): string; diff --git a/src/sfs/sfs.pas b/src/sfs/sfs.pas index 7e466ce..69e4368 100644 --- a/src/sfs/sfs.pas +++ b/src/sfs/sfs.pas @@ -244,9 +244,6 @@ function WildMatch (pattern, text: TSFSString): Boolean; function WildListMatch (wildList, text: TSFSString; delimChar: AnsiChar=':'): Integer; function HasWildcards (const pattern: TSFSString): Boolean; -// this will compare only last path element from sfspath -function SFSDFPathEqu (sfspath: string; path: string): Boolean; - function SFSUpCase (ch: Char): Char; function utf8to1251 (s: TSFSString): TSFSString; @@ -691,27 +688,6 @@ begin result := true; end; -// this will compare only last path element from sfspath -function SFSDFPathEqu (sfspath: string; path: string): Boolean; -{var - i: Integer;} -begin - result := SFSStrEqu(sfspath, path); -(* - if not result and (length(sfspath) > 1) then - begin - i := length(sfspath); - while i > 1 do - begin - while (i > 1) and (sfspath[i-1] <> '/') do Dec(i); - if i <= 1 then exit; - writeln('{', sfspath, '} [', Copy(sfspath, i, length(sfspath)), '] : [', path, ']'); - result := SFSStrEqu(Copy(sfspath, i, length(sfspath)), path); - end; - end; -*) -end; - // adds '/' too function normalizePath (fn: string): string; var diff --git a/src/shared/WADEDITOR.pas b/src/shared/WADEDITOR.pas index 4434e45..d41acfa 100644 --- a/src/shared/WADEDITOR.pas +++ b/src/shared/WADEDITOR.pas @@ -208,7 +208,7 @@ begin fi := fIter.Files[f]; if fi = nil then continue; //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s]', [Section, Resource, fFileName, fi.path, fi.name]), MSG_NOTIFY); - if {SFSStrEqu}SFSDFPathEqu(fi.path, Section) and SFSStrEqu(removeExt(fi.name), Resource) then + if SFSStrEqu(fi.path, Section) and SFSStrEqu(removeExt(fi.name), Resource) then begin // i found her! //fn := fFileName+'::'+fi.path+fi.name; @@ -263,7 +263,7 @@ begin fi := fIter.Files[f]; if fi = nil then continue; if length(fi.name) = 0 then continue; - if {SFSStrEqu}SFSDFPathEqu(fi.path, Section) then + if SFSStrEqu(fi.path, Section) then begin SetLength(result, Length(result)+1); result[high(result)] := removeExt(fi.name);