diff --git a/DataSpec/DNACommon/CRSC.cpp b/DataSpec/DNACommon/CRSC.cpp index e4dbed107..31deac0b5 100644 --- a/DataSpec/DNACommon/CRSC.cpp +++ b/DataSpec/DNACommon/CRSC.cpp @@ -305,13 +305,12 @@ template struct CRSM; template bool ExtractCRSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { CRSM crsm; crsm.read(rs); - crsm.toYAMLFile(fp); - fclose(fp); + crsm.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/DGRP.cpp b/DataSpec/DNACommon/DGRP.cpp index 7b558e320..08cf76ac6 100644 --- a/DataSpec/DNACommon/DGRP.cpp +++ b/DataSpec/DNACommon/DGRP.cpp @@ -110,13 +110,12 @@ template struct DGRP; template bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { DGRP dgrp; dgrp.read(rs); - dgrp.toYAMLFile(fp); - fclose(fp); + dgrp.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index 2a5321acf..fc456e993 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -3,6 +3,8 @@ #include #include +#include +#include #include #include "hecl/hecl.hpp" #include "hecl/Database.hpp" diff --git a/DataSpec/DNACommon/DPSC.cpp b/DataSpec/DNACommon/DPSC.cpp index faa5ebf75..b2b8bfcc3 100644 --- a/DataSpec/DNACommon/DPSC.cpp +++ b/DataSpec/DNACommon/DPSC.cpp @@ -410,13 +410,12 @@ template struct DPSM; template bool ExtractDPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { DPSM dpsm; dpsm.read(rs); - dpsm.toYAMLFile(fp); - fclose(fp); + dpsm.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/ELSC.cpp b/DataSpec/DNACommon/ELSC.cpp index 26c69cb20..cb3852fd7 100644 --- a/DataSpec/DNACommon/ELSC.cpp +++ b/DataSpec/DNACommon/ELSC.cpp @@ -450,13 +450,12 @@ template struct ELSM; template bool ExtractELSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { ELSM elsm; elsm.read(rs); - elsm.toYAMLFile(fp); - fclose(fp); + elsm.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/FONT.cpp b/DataSpec/DNACommon/FONT.cpp index a89d7e246..7d1e35a7c 100644 --- a/DataSpec/DNACommon/FONT.cpp +++ b/DataSpec/DNACommon/FONT.cpp @@ -547,13 +547,12 @@ template struct FONT; template bool ExtractFONT(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { FONT font; font.read(rs); - font.toYAMLFile(fp); - fclose(fp); + font.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/FSM2.cpp b/DataSpec/DNACommon/FSM2.cpp index cc45b8e47..b4a7201aa 100644 --- a/DataSpec/DNACommon/FSM2.cpp +++ b/DataSpec/DNACommon/FSM2.cpp @@ -984,13 +984,12 @@ template struct FSM2; template bool ExtractFSM2(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { FSM2 fsm2; fsm2.read(rs); - fsm2.toYAMLFile(fp); - fclose(fp); + fsm2.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index e4c348635..a43757060 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -214,10 +214,8 @@ void PAKRouter::build(std::vector& bridges, std::functio intptr_t curBridgeIdx = reinterpret_cast(m_curBridgeIdx.get()); const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first; hecl::SystemString catalogPath = hecl::ProjectPath(pakPath, "catalog.yaml").getAbsolutePath(); - FILE* catalog = hecl::Fopen(catalogPath.c_str(), _S("w")); - yaml_emitter_set_output_file(catalogWriter.getEmitter(), catalog); - catalogWriter.finish(); - fclose(catalog); + athena::io::FileWriter writer(catalogPath); + catalogWriter.finish(&writer); } } diff --git a/DataSpec/DNACommon/PART.cpp b/DataSpec/DNACommon/PART.cpp index 945168d64..2c5c9d977 100644 --- a/DataSpec/DNACommon/PART.cpp +++ b/DataSpec/DNACommon/PART.cpp @@ -1538,13 +1538,12 @@ template struct GPSM; template bool ExtractGPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { GPSM gpsm; gpsm.read(rs); - gpsm.toYAMLFile(fp); - fclose(fp); + gpsm.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/SAVWCommon.hpp b/DataSpec/DNACommon/SAVWCommon.hpp index 978fe43fc..8325ec372 100644 --- a/DataSpec/DNACommon/SAVWCommon.hpp +++ b/DataSpec/DNACommon/SAVWCommon.hpp @@ -45,9 +45,8 @@ static bool ExtractSAVW(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath { SAVW savw; savw.read(rs); - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); - savw.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getAbsolutePath()); + savw.toYAMLStream(writer); return true; } diff --git a/DataSpec/DNACommon/SWHC.cpp b/DataSpec/DNACommon/SWHC.cpp index 9e550653a..6588c3fa7 100644 --- a/DataSpec/DNACommon/SWHC.cpp +++ b/DataSpec/DNACommon/SWHC.cpp @@ -544,13 +544,12 @@ template struct SWSH; template bool ExtractSWSH(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { SWSH swsh; swsh.read(rs); - swsh.toYAMLFile(fp); - fclose(fp); + swsh.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNACommon/WPSC.cpp b/DataSpec/DNACommon/WPSC.cpp index c115e4d82..1e87b7adc 100644 --- a/DataSpec/DNACommon/WPSC.cpp +++ b/DataSpec/DNACommon/WPSC.cpp @@ -725,13 +725,12 @@ template struct WPSM; template bool ExtractWPSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) { - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("w")); - if (fp) + athena::io::FileWriter writer(outPath.getAbsolutePath()); + if (writer.isOpen()) { WPSM wpsm; wpsm.read(rs); - wpsm.toYAMLFile(fp); - fclose(fp); + wpsm.toYAMLStream(writer); return true; } return false; diff --git a/DataSpec/DNAMP1/AFSM.hpp b/DataSpec/DNAMP1/AFSM.hpp index 88463278e..bca2c9b62 100644 --- a/DataSpec/DNAMP1/AFSM.hpp +++ b/DataSpec/DNAMP1/AFSM.hpp @@ -159,9 +159,8 @@ struct AFSM : public BigYAML { AFSM afsm; afsm.read(rs); - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); - afsm.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getAbsolutePath()); + afsm.toYAMLStream(writer); return true; } }; diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index 9d0e7a025..672a0d137 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -1031,9 +1031,8 @@ bool ANCS::Extract(const SpecBase& dataSpec, { if (force || yamlType == hecl::ProjectPath::Type::None) { - FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("w")); - ancs.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(yamlPath.getAbsolutePath()); + ancs.toYAMLStream(writer); } if (force || blendType == hecl::ProjectPath::Type::None) @@ -1062,9 +1061,8 @@ bool ANCS::Extract(const SpecBase& dataSpec, EVNT evnt; if (pakRouter.lookupAndReadDNA(res.second.evntId, evnt, true)) { - FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("w")); - evnt.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(evntYamlPath.getAbsolutePath()); + evnt.toYAMLStream(writer); } } } @@ -1085,25 +1083,23 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, Log.report(logvisor::Fatal, _S("'%s' not found as file"), yamlPath.getRelativePath().c_str()); - FILE* yamlFp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("r")); - if (!yamlFp) + athena::io::FileReader reader(yamlPath.getAbsolutePath()); + if (!reader.isOpen()) Log.report(logvisor::Fatal, _S("can't open '%s' for reading"), yamlPath.getRelativePath().c_str()); - if (!BigYAML::ValidateFromYAMLFile(yamlFp)) + if (!BigYAML::ValidateFromYAMLStream(reader)) { Log.report(logvisor::Fatal, _S("'%s' is not urde::DNAMP1::ANCS type"), yamlPath.getRelativePath().c_str()); } athena::io::YAMLDocReader yamlReader; - yaml_parser_set_input_file(yamlReader.getParser(), yamlFp); - if (!yamlReader.parse()) + if (!yamlReader.parse(&reader)) { Log.report(logvisor::Fatal, _S("unable to parse '%s'"), yamlPath.getRelativePath().c_str()); } - fclose(yamlFp); ANCS ancs; ancs.read(yamlReader); @@ -1263,12 +1259,11 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath, _S(".evnt.yaml")).c_str(), true); if (evntYamlPath.getPathType() == hecl::ProjectPath::Type::File) { - FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("r")); - if (fp) + athena::io::FileReader reader(evntYamlPath.getAbsolutePath()); + if (reader.isOpen()) { EVNT evnt; - evnt.fromYAMLFile(fp); - fclose(fp); + evnt.fromYAMLStream(reader); anim.m_anim->evnt = evntYamlPath; hecl::ProjectPath evntYamlOut = cookedOut.getWithExtension(_S(".evnt")); diff --git a/DataSpec/DNAMP1/EVNT.hpp b/DataSpec/DNAMP1/EVNT.hpp index 23edc4037..a680d9a5b 100644 --- a/DataSpec/DNAMP1/EVNT.hpp +++ b/DataSpec/DNAMP1/EVNT.hpp @@ -85,9 +85,8 @@ struct EVNT : BigYAML { EVNT evnt; evnt.read(rs); - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); - evnt.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getAbsolutePath()); + evnt.toYAMLStream(writer); return true; } }; diff --git a/DataSpec/DNAMP1/MLVL.hpp b/DataSpec/DNAMP1/MLVL.hpp index de221aafd..16224e016 100644 --- a/DataSpec/DNAMP1/MLVL.hpp +++ b/DataSpec/DNAMP1/MLVL.hpp @@ -117,9 +117,8 @@ struct MLVL : BigYAML { MLVL mlvl; mlvl.read(rs); - FILE* fp = hecl::Fopen(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath().c_str(), _S("w")); - mlvl.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getWithExtension(_S(".yaml"), true).getAbsolutePath()); + mlvl.toYAMLStream(writer); hecl::BlenderConnection& conn = btok.getBlenderConnection(); return DNAMLVL::ReadMLVLToBlender(conn, mlvl, outPath, pakRouter, entry, force, fileChanged); diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index 70825c98b..1ffd58751 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -341,23 +341,15 @@ bool MREA::PCCook(const hecl::ProjectPath& outPath, sclyData.version = 1; for (const hecl::ProjectPath& layer : layerScriptPaths) { - FILE* yamlFile = hecl::Fopen(layer.getAbsolutePath().c_str(), _S("r")); - if (!yamlFile) + athena::io::FileReader freader(layer.getAbsolutePath()); + if (!freader.isOpen()) continue; - if (!BigYAML::ValidateFromYAMLFile(yamlFile)) - { - fclose(yamlFile); + if (!BigYAML::ValidateFromYAMLStream(freader)) continue; - } athena::io::YAMLDocReader reader; - yaml_parser_set_input_file(reader.getParser(), yamlFile); - if (!reader.parse()) - { - fclose(yamlFile); + if (!reader.parse(&freader)) continue; - } - fclose(yamlFile); sclyData.layers.emplace_back(); sclyData.layers.back().read(reader); diff --git a/DataSpec/DNAMP1/SCAN.hpp b/DataSpec/DNAMP1/SCAN.hpp index ac79bb03d..47c377010 100644 --- a/DataSpec/DNAMP1/SCAN.hpp +++ b/DataSpec/DNAMP1/SCAN.hpp @@ -156,18 +156,16 @@ struct SCAN : BigYAML { SCAN scan; scan.read(rs); - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); - scan.toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getAbsolutePath()); + scan.toYAMLStream(writer); return true; } static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { SCAN scan; - FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb")); - scan.fromYAMLFile(fp); - fclose(fp); + athena::io::FileReader reader(inPath.getAbsolutePath()); + scan.fromYAMLStream(reader); athena::io::FileWriter ws(outPath.getAbsolutePath()); scan.write(ws); return true; diff --git a/DataSpec/DNAMP1/SCLY.cpp b/DataSpec/DNAMP1/SCLY.cpp index 8a04550b4..2d22d837f 100644 --- a/DataSpec/DNAMP1/SCLY.cpp +++ b/DataSpec/DNAMP1/SCLY.cpp @@ -54,9 +54,8 @@ void SCLY::exportToLayerDirectories(const PAK::Entry& entry, PAKRouter strg = LoadSTRG(rs); - FILE* fp = hecl::Fopen(outPath.getAbsolutePath().c_str(), _S("wb")); - strg->toYAMLFile(fp); - fclose(fp); + athena::io::FileWriter writer(outPath.getAbsolutePath()); + strg->toYAMLStream(writer); return true; } static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) { STRG strg; - FILE* fp = hecl::Fopen(inPath.getAbsolutePath().c_str(), _S("rb")); - strg.fromYAMLFile(fp); - fclose(fp); + athena::io::FileReader reader(inPath.getAbsolutePath()); + strg.fromYAMLStream(reader); athena::io::FileWriter ws(outPath.getAbsolutePath()); strg.write(ws); return true; diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 745d64fa4..9ada3e0a7 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -141,9 +141,8 @@ bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok) } else if (hecl::IsPathYAML(path)) { - FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("r")); - bool retval = validateYAMLDNAType(fp); - fclose(fp); + athena::io::FileReader reader(path.getAbsolutePath()); + bool retval = validateYAMLDNAType(reader); return retval; } return false; @@ -217,9 +216,8 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co } else if (hecl::IsPathYAML(path)) { - FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("r")); - cookYAML(cookedPath, path, fp, progress); - fclose(fp); + athena::io::FileReader reader(path.getAbsolutePath()); + cookYAML(cookedPath, path, reader, progress); } } diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index d81132187..b106c753a 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -49,7 +49,7 @@ struct SpecBase : hecl::Database::IDataSpec virtual bool checkPathPrefix(const hecl::ProjectPath& path)=0; /* Pre-cook handlers */ - virtual bool validateYAMLDNAType(FILE* fp) const=0; + virtual bool validateYAMLDNAType(athena::io::IStreamReader& fp) const=0; /* Cook handlers */ using BlendStream = hecl::BlenderConnection::DataStream; @@ -68,7 +68,7 @@ struct SpecBase : hecl::Database::IDataSpec BlendStream& ds, bool fast, hecl::BlenderToken& btok, FCookProgress progress)=0; virtual void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, - FILE* fin, FCookProgress progress)=0; + athena::io::IStreamReader& fin, FCookProgress progress)=0; const hecl::ProjectPath& getMasterShaderPath() const {return m_masterShader;} diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index b75c565b4..d2183a17e 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -320,10 +320,10 @@ struct SpecMP1 : SpecBase return path.getRelativePath().compare(0, 4, _S("MP1/")) == 0; } - bool validateYAMLDNAType(FILE* fp) const + bool validateYAMLDNAType(athena::io::IStreamReader& fp) const { athena::io::YAMLDocReader reader; - yaml_parser_set_input_file(reader.getParser(), fp); + yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)athena::io::YAMLAthenaReader, &fp); return reader.ClassTypeOperation([](const char* classType) { if (!strcmp(classType, DNAMP1::MLVL::DNAType())) @@ -422,11 +422,10 @@ struct SpecMP1 : SpecBase } void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, - FILE* fin, FCookProgress progress) + athena::io::IStreamReader& fin, FCookProgress progress) { athena::io::YAMLDocReader reader; - yaml_parser_set_input_file(reader.getParser(), fin); - if (reader.parse()) + if (reader.parse(&fin)) { std::string classStr = reader.readString("DNAType"); if (classStr.empty()) diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index 43155f408..62dc704e3 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -285,11 +285,11 @@ struct SpecMP2 : SpecBase return path.getRelativePath().compare(0, 4, _S("MP2/")) == 0; } - bool validateYAMLDNAType(FILE* fp) const + bool validateYAMLDNAType(athena::io::IStreamReader& fp) const { - if (BigYAML::ValidateFromYAMLFile(fp)) + if (BigYAML::ValidateFromYAMLStream(fp)) return true; - if (BigYAML::ValidateFromYAMLFile(fp)) + if (BigYAML::ValidateFromYAMLStream(fp)) return true; return false; } @@ -313,7 +313,7 @@ struct SpecMP2 : SpecBase } void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, - FILE* fin, FCookProgress progress) + athena::io::IStreamReader& fin, FCookProgress progress) { } }; diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index 270d8021d..0dd49439a 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -478,13 +478,13 @@ struct SpecMP3 : SpecBase return path.getRelativePath().compare(0, 4, _S("MP3/")) == 0; } - bool validateYAMLDNAType(FILE* fp) const + bool validateYAMLDNAType(athena::io::IStreamReader& fp) const { - if (BigYAML::ValidateFromYAMLFile(fp)) + if (BigYAML::ValidateFromYAMLStream(fp)) return true; - if (BigYAML::ValidateFromYAMLFile(fp)) + if (BigYAML::ValidateFromYAMLStream(fp)) return true; - if (BigYAML::ValidateFromYAMLFile(fp)) + if (BigYAML::ValidateFromYAMLStream(fp)) return true; return false; } @@ -508,7 +508,7 @@ struct SpecMP3 : SpecBase } void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, - FILE* fin, FCookProgress progress) + athena::io::IStreamReader& fin, FCookProgress progress) { } }; diff --git a/Editor/ProjectManager.cpp b/Editor/ProjectManager.cpp index 7b4bffa44..6b1ee57a9 100644 --- a/Editor/ProjectManager.cpp +++ b/Editor/ProjectManager.cpp @@ -96,34 +96,30 @@ bool ProjectManager::openProject(const hecl::SystemString& path) } hecl::ProjectPath urdeSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml")); - FILE* fp = hecl::Fopen(urdeSpacesPath.getAbsolutePath().c_str(), _S("r")); + athena::io::FileReader reader(urdeSpacesPath.getAbsolutePath()); bool needsSave = false; athena::io::YAMLDocReader r; - if (!fp) + if (!reader.isOpen()) { needsSave = true; goto makeProj; } - yaml_parser_set_input_file(r.getParser(), fp); + yaml_parser_set_input(r.getParser(), (yaml_read_handler_t*)athena::io::YAMLAthenaReader, &reader); if (!r.ValidateClassType("UrdeSpacesState")) { needsSave = true; - fclose(fp); goto makeProj; } r.reset(); - fseek(fp, 0, SEEK_SET); - yaml_parser_set_input_file(r.getParser(), fp); - if (!r.parse()) + reader.seek(0, athena::Begin); + if (!r.parse(&reader)) { needsSave = true; - fclose(fp); goto makeProj; } - fclose(fp); makeProj: m_vm.ProjectChanged(*m_proj); @@ -163,19 +159,14 @@ bool ProjectManager::saveProject() return false; hecl::ProjectPath oldSpacesPath(*m_proj, _S(".hecl/~urde_spaces.yaml")); - FILE* fp = hecl::Fopen(oldSpacesPath.getAbsolutePath().c_str(), _S("w")); - if (!fp) + athena::io::FileWriter writer(oldSpacesPath.getAbsolutePath()); + if (!writer.isOpen()) return false; athena::io::YAMLDocWriter w("UrdeSpacesState"); - yaml_emitter_set_output_file(w.getEmitter(), fp); m_vm.SaveEditorView(w); - if (!w.finish()) - { - fclose(fp); + if (!w.finish(&writer)) return false; - } - fclose(fp); hecl::ProjectPath newSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml")); diff --git a/Editor/ProjectResourceFactoryBase.cpp b/Editor/ProjectResourceFactoryBase.cpp index 8d1c51828..cf30525a9 100644 --- a/Editor/ProjectResourceFactoryBase.cpp +++ b/Editor/ProjectResourceFactoryBase.cpp @@ -16,14 +16,12 @@ void ProjectResourceFactoryBase::Clear() void ProjectResourceFactoryBase::ReadCatalog(const hecl::ProjectPath& catalogPath, athena::io::YAMLDocWriter& nameWriter) { - FILE* fp = hecl::Fopen(catalogPath.getAbsolutePath().c_str(), _S("r")); - if (!fp) + athena::io::FileReader freader(catalogPath.getAbsolutePath()); + if (!freader.isOpen()) return; athena::io::YAMLDocReader reader; - yaml_parser_set_input_file(reader.getParser(), fp); - bool res = reader.parse(); - fclose(fp); + bool res = reader.parse(&freader); if (!res) return; @@ -208,13 +206,12 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() /* Read in tag cache */ if (tagCachePath.getPathType() == hecl::ProjectPath::Type::File) { - FILE* cacheFile = hecl::Fopen(tagCachePath.getAbsolutePath().c_str(), _S("r")); - if (cacheFile) + athena::io::FileReader reader(tagCachePath.getAbsolutePath()); + if (reader.isOpen()) { Log.report(logvisor::Info, _S("Cache index of '%s' loading"), m_origSpec->m_name); athena::io::YAMLDocReader cacheReader; - yaml_parser_set_input_file(cacheReader.getParser(), cacheFile); - if (cacheReader.parse()) + if (cacheReader.parse(&reader)) { std::unique_lock lk(m_backgroundIndexMutex); m_tagToPath.reserve(cacheReader.getRootNode()->m_mapChildren.size()); @@ -231,7 +228,6 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() } fprintf(stderr, "\n"); } - fclose(cacheFile); Log.report(logvisor::Info, _S("Cache index of '%s' loaded; %d tags"), m_origSpec->m_name, m_tagToPath.size()); @@ -239,10 +235,9 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() { /* Read in name cache */ Log.report(logvisor::Info, _S("Name index of '%s' loading"), m_origSpec->m_name); - FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("r")); + athena::io::FileReader nreader(nameCachePath.getAbsolutePath()); athena::io::YAMLDocReader nameReader; - yaml_parser_set_input_file(nameReader.getParser(), nameFile); - if (nameReader.parse()) + if (nameReader.parse(&nreader)) { std::unique_lock lk(m_backgroundIndexMutex); m_catalogNameToTag.reserve(nameReader.getRootNode()->m_mapChildren.size()); @@ -254,7 +249,6 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() m_catalogNameToTag[child.first] = search->first; } } - fclose(nameFile); Log.report(logvisor::Info, _S("Name index of '%s' loaded; %d names"), m_origSpec->m_name, m_catalogNameToTag.size()); } @@ -264,10 +258,8 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() Log.report(logvisor::Info, _S("Name index of '%s' started"), m_origSpec->m_name); athena::io::YAMLDocWriter nameWriter(nullptr); BackgroundIndexRecursiveCatalogs(specRoot, nameWriter, 0); - FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("w")); - yaml_emitter_set_output_file(nameWriter.getEmitter(), nameFile); - nameWriter.finish(); - fclose(nameFile); + athena::io::FileWriter nwriter(nameCachePath.getAbsolutePath()); + nameWriter.finish(&nwriter); Log.report(logvisor::Info, _S("Name index of '%s' complete; %d names"), m_origSpec->m_name, m_catalogNameToTag.size()); } @@ -282,15 +274,11 @@ void ProjectResourceFactoryBase::BackgroundIndexProc() BackgroundIndexRecursiveProc(specRoot, cacheWriter, nameWriter, 0); tagCachePath.makeDirChain(false); - FILE* cacheFile = hecl::Fopen(tagCachePath.getAbsolutePath().c_str(), _S("w")); - yaml_emitter_set_output_file(cacheWriter.getEmitter(), cacheFile); - cacheWriter.finish(); - fclose(cacheFile); + athena::io::FileWriter twriter(tagCachePath.getAbsolutePath()); + cacheWriter.finish(&twriter); - FILE* nameFile = hecl::Fopen(nameCachePath.getAbsolutePath().c_str(), _S("w")); - yaml_emitter_set_output_file(nameWriter.getEmitter(), nameFile); - nameWriter.finish(); - fclose(nameFile); + athena::io::FileWriter nwriter(nameCachePath.getAbsolutePath()); + nameWriter.finish(&nwriter); m_backgroundBlender.shutdown(); Log.report(logvisor::Info, _S("Background index of '%s' complete; %d tags, %d names"), diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 3e2912502..eabb8af4d 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -32,7 +32,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore) SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.blend")); SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend")); SObjectTag bgModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_BC34D54C.blend")); - CAnimRes samusAnimRes(samusCharSet.id, -1, zeus::CVector3f::skOne, -1, true); + CAnimRes samusAnimRes(samusCharSet.id, 2, zeus::CVector3f::skOne, 0, true); g_GameState->GetWorldTransitionManager()->EnableTransition(samusAnimRes, platModel.id, zeus::CVector3f::skOne, bgModel.id, zeus::CVector3f::skOne, false); diff --git a/hecl b/hecl index 3bc81a3fe..9b9dae615 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 3bc81a3fe2711d9d7817e6f24afe7e29ca5e99d3 +Subproject commit 9b9dae61566460086a51ccf371fc1bdf682ee5cb diff --git a/specter b/specter index 5e695dab6..4c675e2e0 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 5e695dab622d5095120224297b3c2fea4b3b85ca +Subproject commit 4c675e2e0512c911b76da84b0073396392c7f3a3