mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-28 17:15:57 +00:00
tvg format: code refactoring #5
replace from ofstream to FILE We know both have the same purpose, we always prefer the less binary size. So... this brings the binary size reduction. 1918496 => 1913528
This commit is contained in:
parent
bccb1d29e3
commit
5b2d10d97a
1 changed files with 9 additions and 8 deletions
|
@ -26,7 +26,7 @@
|
||||||
#include "tvgBinaryDesc.h"
|
#include "tvgBinaryDesc.h"
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fstream>
|
#include <stdio.h>
|
||||||
|
|
||||||
struct Saver::Impl
|
struct Saver::Impl
|
||||||
{
|
{
|
||||||
|
@ -47,13 +47,14 @@ struct Saver::Impl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveBufferToFile(const std::string& path)
|
bool bufferToFile(const std::string& path)
|
||||||
{
|
{
|
||||||
ofstream outFile;
|
FILE* fp = fopen(path.c_str(), "w+");
|
||||||
outFile.open(path, ios::out | ios::trunc | ios::binary);
|
if (!fp) return false;
|
||||||
if (!outFile.is_open()) return false;
|
|
||||||
outFile.write(buffer.data, buffer.count);
|
if (fwrite(buffer.data, sizeof(char), buffer.count, fp) == 0) return false;
|
||||||
outFile.close();
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -405,7 +406,7 @@ struct Saver::Impl
|
||||||
|
|
||||||
if (!writeHeader()) return false;
|
if (!writeHeader()) return false;
|
||||||
if (serialize(paint) == 0) return false;
|
if (serialize(paint) == 0) return false;
|
||||||
if (!saveBufferToFile(path)) return false;
|
if (!bufferToFile(path)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue