| 1870 | #ifndef NO_LIVECREATE |
| 1871 | |
| 1872 | static 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 |
no test coverage detected