mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-01 02:21:59 +08:00
Added NO_FS definition for std::ofstream usage
This commit is contained in:
parent
fbff1f45b5
commit
5e008af65d
12
tiny_gltf.h
12
tiny_gltf.h
@ -7207,6 +7207,7 @@ static void SerializeGltfBufferData(const std::vector<unsigned char> &data,
|
|||||||
|
|
||||||
static bool SerializeGltfBufferData(const std::vector<unsigned char> &data,
|
static bool SerializeGltfBufferData(const std::vector<unsigned char> &data,
|
||||||
const std::string &binFilename) {
|
const std::string &binFilename) {
|
||||||
|
#ifndef TINYGLTF_NO_FS
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(__GLIBCXX__) // mingw
|
#if defined(__GLIBCXX__) // mingw
|
||||||
int file_descriptor = _wopen(UTF8ToWchar(binFilename).c_str(),
|
int file_descriptor = _wopen(UTF8ToWchar(binFilename).c_str(),
|
||||||
@ -7235,6 +7236,9 @@ static bool SerializeGltfBufferData(const std::vector<unsigned char> &data,
|
|||||||
// write empty file.
|
// write empty file.
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // FIXME(syoyo): not used. will be removed in the future release.
|
#if 0 // FIXME(syoyo): not used. will be removed in the future release.
|
||||||
@ -8456,6 +8460,7 @@ static bool WriteGltfStream(std::ostream &stream, const std::string &content) {
|
|||||||
|
|
||||||
static bool WriteGltfFile(const std::string &output,
|
static bool WriteGltfFile(const std::string &output,
|
||||||
const std::string &content) {
|
const std::string &content) {
|
||||||
|
#ifndef TINYGLTF_NO_FS
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
std::ofstream gltfFile(UTF8ToWchar(output).c_str());
|
std::ofstream gltfFile(UTF8ToWchar(output).c_str());
|
||||||
@ -8475,6 +8480,9 @@ static bool WriteGltfFile(const std::string &output,
|
|||||||
if (!gltfFile.is_open()) return false;
|
if (!gltfFile.is_open()) return false;
|
||||||
#endif
|
#endif
|
||||||
return WriteGltfStream(gltfFile, content);
|
return WriteGltfStream(gltfFile, content);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool WriteBinaryGltfStream(std::ostream &stream,
|
static bool WriteBinaryGltfStream(std::ostream &stream,
|
||||||
@ -8541,6 +8549,7 @@ static bool WriteBinaryGltfStream(std::ostream &stream,
|
|||||||
static bool WriteBinaryGltfFile(const std::string &output,
|
static bool WriteBinaryGltfFile(const std::string &output,
|
||||||
const std::string &content,
|
const std::string &content,
|
||||||
const std::vector<unsigned char> &binBuffer) {
|
const std::vector<unsigned char> &binBuffer) {
|
||||||
|
#ifndef TINYGLTF_NO_FS
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary);
|
std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary);
|
||||||
@ -8557,6 +8566,9 @@ static bool WriteBinaryGltfFile(const std::string &output,
|
|||||||
std::ofstream gltfFile(output.c_str(), std::ios::binary);
|
std::ofstream gltfFile(output.c_str(), std::ios::binary);
|
||||||
#endif
|
#endif
|
||||||
return WriteBinaryGltfStream(gltfFile, content, binBuffer);
|
return WriteBinaryGltfStream(gltfFile, content, binBuffer);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TinyGLTF::WriteGltfSceneToStream(const Model *model, std::ostream &stream,
|
bool TinyGLTF::WriteGltfSceneToStream(const Model *model, std::ostream &stream,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user