forked from Mirrors/openclonk
Replace raw CRT file access API calls with StdFile equivalents
parent
c5b92bba26
commit
b2e83c3cb2
|
@ -546,13 +546,7 @@ void C4GroupEntry::Set(const DirectoryIterator &iter, const char * path)
|
|||
ZeroMem(this,sizeof(C4GroupEntry));
|
||||
SCopy(GetFilename(*iter),FileName,_MAX_FNAME);
|
||||
SCopy(*iter, DiskPath, _MAX_PATH-1);
|
||||
struct stat buf;
|
||||
if (!stat(DiskPath, &buf))
|
||||
{
|
||||
Size = buf.st_size;
|
||||
}
|
||||
else
|
||||
Size = 0;
|
||||
Size = FileSize(*iter);
|
||||
//SCopy(path,DiskPath,_MAX_PATH-1); AppendBackslash(DiskPath); SAppend(FileName,DiskPath,_MAX_PATH);
|
||||
Status=C4GRES_OnDisk;
|
||||
Packed=false;
|
||||
|
|
|
@ -701,7 +701,7 @@ bool C4UpdatePackage::MakeUpdate(const char *strFile1, const char *strFile2, con
|
|||
if (!fSuccess)
|
||||
{
|
||||
WriteLog("Update package not created.\n");
|
||||
remove(strUpdateFile);
|
||||
EraseItem(strUpdateFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -790,8 +790,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
|
|||
else
|
||||
// delete group (do not remove groups that existed before!)
|
||||
if (strTempGroupName[0])
|
||||
if (remove(strTempGroupName))
|
||||
if (rmdir(strTempGroupName))
|
||||
if (!EraseItem(strTempGroupName))
|
||||
{ WriteLog("Error: could not delete temporary directory\n"); return false; }
|
||||
delete pChildGrp1;
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, b
|
|||
|
||||
// do optimizations (delete unneeded entries)
|
||||
if (!OptimizeStandalone(fSilent))
|
||||
{ if (!SEqual(szFile, szStandalone)) remove(szStandalone); szStandalone[0] = '\0'; return false; }
|
||||
{ if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone); szStandalone[0] = '\0'; return false; }
|
||||
|
||||
// get file size
|
||||
size_t iSize = FileSize(szStandalone);
|
||||
|
@ -649,7 +649,7 @@ bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, b
|
|||
if (!fSetOfficial && iSize != Core.getFileSize())
|
||||
{
|
||||
// remove file
|
||||
if (!SEqual(szFile, szStandalone)) remove(szStandalone); szStandalone[0] = '\0';
|
||||
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone); szStandalone[0] = '\0';
|
||||
// sorry, this version isn't good enough :(
|
||||
return false;
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, b
|
|||
if (!fSetOfficial && iCRC32 != Core.getFileCRC())
|
||||
{
|
||||
// remove file, return
|
||||
if (!SEqual(szFile, szStandalone)) remove(szStandalone); szStandalone[0] = '\0';
|
||||
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone); szStandalone[0] = '\0';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -981,12 +981,12 @@ void C4Network2Res::Clear()
|
|||
// delete files
|
||||
if (fTempFile)
|
||||
if (FileExists(szFile))
|
||||
if (remove(szFile))
|
||||
if (!EraseFile(szFile))
|
||||
//Log(_strerror("Network: Could not delete temporary ressource file"));
|
||||
LogSilentF("Network: Could not delete temporary resource file (%s)", strerror(errno));
|
||||
if (szStandalone[0] && !SEqual(szFile, szStandalone))
|
||||
if (FileExists(szStandalone))
|
||||
if (remove(szStandalone))
|
||||
if (!EraseFile(szStandalone))
|
||||
//Log(_strerror("Network: Could not delete temporary ressource file"));
|
||||
LogSilentF("Network: Could not delete temporary resource file (%s)", strerror(errno));
|
||||
szFile[0] = szStandalone[0] = '\0';
|
||||
|
@ -1700,20 +1700,12 @@ bool C4Network2ResList::CreateNetworkFolder()
|
|||
// but make sure that the configured path has one
|
||||
AppendBackslash(Config.Network.WorkPath);
|
||||
// does not exist?
|
||||
if (access(szNetworkPath, 00))
|
||||
if (!DirectoryExists(szNetworkPath))
|
||||
{
|
||||
if (!CreatePath(szNetworkPath))
|
||||
{ LogFatal("Network: could not create network path!"); return false; }
|
||||
return true;
|
||||
}
|
||||
// stat
|
||||
struct stat s;
|
||||
if (stat(szNetworkPath, &s))
|
||||
{ LogFatal("Network: could not stat network path!"); return false; }
|
||||
// not a subdir?
|
||||
if (!(s.st_mode & S_IFDIR))
|
||||
{ LogFatal("Network: could not create network path: blocked by a file!"); return false; }
|
||||
// ok
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1740,7 +1732,7 @@ bool C4Network2ResList::FindTempResFileName(const char *szFilename, char *pTarge
|
|||
// create temporary file
|
||||
SCopy(Config.AtNetworkPath(GetFilename(szFilename)), pTarget, _MAX_PATH);
|
||||
// file name is free?
|
||||
if (access(pTarget, F_OK)) return true;
|
||||
if (!ItemExists(pTarget)) return true;
|
||||
// find another file name
|
||||
char szFileMask[_MAX_PATH+1];
|
||||
SCopy(pTarget, szFileMask, GetExtension(pTarget)-1-pTarget);
|
||||
|
@ -1750,7 +1742,7 @@ bool C4Network2ResList::FindTempResFileName(const char *szFilename, char *pTarge
|
|||
{
|
||||
snprintf(pTarget, _MAX_PATH, szFileMask, i);
|
||||
// doesn't exist?
|
||||
if (access(pTarget, F_OK))
|
||||
if (!ItemExists(pTarget))
|
||||
return true;
|
||||
}
|
||||
// not found
|
||||
|
|
|
@ -48,7 +48,7 @@ bool C4MusicFile::RemTempFile()
|
|||
{
|
||||
if (!SongExtracted) return true;
|
||||
// delete it
|
||||
remove(Config.AtTempPath(C4CFN_TempMusic2));
|
||||
EraseFile(Config.AtTempPath(C4CFN_TempMusic2));
|
||||
SongExtracted = false;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue