MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / SubsituteFile

Function SubsituteFile

Code/CryEngine/CryAction/LevelSystem.cpp:1872–1912  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1870#ifndef NO_LIVECREATE
1871
1872static bool SubsituteFile(const string& srcPath, const string& destPath)
1873{
1874 FILE* src = gEnv->pCryPak->FOpen(srcPath.c_str(), "rb", ICryPak::FOPEN_ONDISK);
1875 if (!src)
1876 {
1877 CryLogAlways("SubsituteFile: Failed to open source file '%s'", srcPath.c_str());
1878 return false;
1879 }
1880
1881 FILE* dst = gEnv->pCryPak->FOpen(destPath.c_str(), "wb", ICryPak::FOPEN_ONDISK);
1882 if (!dst)
1883 {
1884 CryLogAlways("SubsituteFile: Failed to open destination file '%s'", destPath.c_str());
1885 gEnv->pCryPak->FClose(src);
1886 return false;
1887 }
1888
1889 const uint32 CHUNK_SIZE = 64 * 1024;
1890 char* buf = new char[CHUNK_SIZE];
1891 size_t readBytes = 0;
1892 size_t writtenBytes = 0;
1893 while (!gEnv->pCryPak->FEof(src))
1894 {
1895 readBytes = gEnv->pCryPak->FReadRaw(buf, sizeof(char), CHUNK_SIZE, src);
1896 writtenBytes = gEnv->pCryPak->FWrite(buf, sizeof(char), readBytes, dst);
1897
1898 if (readBytes != writtenBytes)
1899 {
1900 gEnv->pCryPak->FClose(src);
1901 gEnv->pCryPak->FClose(dst);
1902
1903 delete[] buf;
1904 return false;
1905 }
1906 }
1907
1908 delete[] buf;
1909 gEnv->pCryPak->FClose(src);
1910 gEnv->pCryPak->FClose(dst);
1911 return true;
1912}
1913
1914#endif
1915

Callers 1

OpenLevelPakMethod · 0.85

Calls 7

CryLogAlwaysFunction · 0.85
FOpenMethod · 0.45
c_strMethod · 0.45
FCloseMethod · 0.45
FEofMethod · 0.45
FReadRawMethod · 0.45
FWriteMethod · 0.45

Tested by

no test coverage detected