| 266 | } |
| 267 | |
| 268 | Expected<LoadedObject> makeObjectTreeFromZip( const std::filesystem::path& zipPath, const ProgressCallback& callback ) |
| 269 | { |
| 270 | UniqueTemporaryFolder tmpFolder; |
| 271 | auto contentsFolder = tmpFolder / zipPath.stem(); |
| 272 | |
| 273 | std::ifstream in( zipPath, std::ifstream::binary ); |
| 274 | if ( !in ) |
| 275 | return unexpected( std::string( "Cannot open file for reading " ) + utf8string( zipPath.filename() ) ); |
| 276 | |
| 277 | std::error_code ec; |
| 278 | std::filesystem::create_directory( contentsFolder, ec ); |
| 279 | auto resZip = decompressZip( in, contentsFolder ); |
| 280 | if ( !resZip ) |
| 281 | return unexpected( "ZIP container error: " + resZip.error() ); |
| 282 | |
| 283 | return makeObjectTreeFromFolder( contentsFolder, false, callback ); |
| 284 | } |
| 285 | |
| 286 | MR_ADD_SCENE_LOADER( IOFilter( "ZIP files (.zip)","*.zip" ), makeObjectTreeFromZip ) |
| 287 |
nothing calls this directly
no test coverage detected