mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
[fnd] Implemented fnd::WriteFile()
This commit is contained in:
parent
18b5826bfb
commit
79e2ef5fd2
|
@ -40,5 +40,31 @@ void FileIO::ReadFile(const std::string& path, MemoryBlob & blob)
|
|||
|
||||
void FileIO::WriteFile(const std::string& path, const MemoryBlob & blob)
|
||||
{
|
||||
|
||||
WriteFile(blob.data(), blob.size());
|
||||
}
|
||||
|
||||
void fnd::FileIO::WriteFile(const std::string & path, const u8 * data, size_t len)
|
||||
{
|
||||
FILE* fp;
|
||||
size_t filesz, filepos;
|
||||
|
||||
if ((fp = fopen(path.c_str(), "wb")) == NULL)
|
||||
{
|
||||
throw Exception(kModuleName, "Failed to open \"" + path + "\"");
|
||||
}
|
||||
|
||||
filesz = len;
|
||||
|
||||
|
||||
for (filepos = 0; filesz > kBlockSize; filesz -= kBlockSize, filepos += kBlockSize)
|
||||
{
|
||||
fwrite(data + filepos, 1, kBlockSize, fp);
|
||||
}
|
||||
|
||||
if (filesz)
|
||||
{
|
||||
fwrite(blob.data() + filepos, 1, filesz, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace fnd
|
|||
static void ReadFile(const std::string& path, MemoryBlob& blob);
|
||||
//static void ReadFile(const char* path, MemoryBlob& blob, size_t offset, size_t size);
|
||||
static void WriteFile(const std::string& path, const MemoryBlob& blob);
|
||||
static void WriteFile(const std::string& path, const u8* data, size_t len);
|
||||
//static void WriteFile(const char* path, const MemoryBlob& blob, size_t offset, size_t size);
|
||||
private:
|
||||
|
||||
|
|
|
@ -92,8 +92,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>C:\Users\jkrca\Source\Repos\NXTools\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
|
|
Loading…
Reference in a new issue