@@ -52,7 +52,7 @@ File::Impl::Impl(const std::string &pFileNameOrUrl, bool pRetrieveContents)
5252 } else {
5353 mFilePath = stringToPath (" /some/path/file" );
5454 }
55- } else if (!std::filesystem::exists (mFilePath )) {
55+ } else if (!std::filesystem::exists (mFilePath ) && pRetrieveContents ) {
5656 mType = Type::IRRETRIEVABLE_FILE;
5757
5858 addError (" The file does not exist." );
@@ -87,30 +87,32 @@ void File::Impl::checkType(const FilePtr &pOwner, bool pResetType)
8787#endif
8888 }
8989
90- // Try to get a CellML file, a SED-ML file, or a COMBINE archive.
90+ // Try to get a CellML file, a SED-ML file, or a COMBINE archive, but only if we have some contents .
9191
92- mCellmlFile = CellmlFile::create (pOwner);
92+ if (!contents ().empty ()) {
93+ mCellmlFile = CellmlFile::create (pOwner);
9394
94- if (mCellmlFile != nullptr ) {
95- mType = Type::CELLML_FILE;
95+ if (mCellmlFile != nullptr ) {
96+ mType = Type::CELLML_FILE;
9697
97- addIssues (mCellmlFile );
98- } else {
99- mSedmlFile = SedmlFile::create (pOwner);
100-
101- if (mSedmlFile != nullptr ) {
102- mType = Type::SEDML_FILE;
103-
104- addIssues (mSedmlFile );
98+ addIssues (mCellmlFile );
10599 } else {
106- mCombineArchive = CombineArchive ::create (pOwner);
100+ mSedmlFile = SedmlFile ::create (pOwner);
107101
108- if (mCombineArchive != nullptr ) {
109- mType = Type::COMBINE_ARCHIVE ;
102+ if (mSedmlFile != nullptr ) {
103+ mType = Type::SEDML_FILE ;
110104
111- addIssues (mCombineArchive );
105+ addIssues (mSedmlFile );
112106 } else {
113- addError (" The file is not a CellML file, a SED-ML file, or a COMBINE archive." );
107+ mCombineArchive = CombineArchive::create (pOwner);
108+
109+ if (mCombineArchive != nullptr ) {
110+ mType = Type::COMBINE_ARCHIVE;
111+
112+ addIssues (mCombineArchive );
113+ } else {
114+ addError (" The file is not a CellML file, a SED-ML file, or a COMBINE archive." );
115+ }
114116 }
115117 }
116118 }
0 commit comments