From 8150c720d3b24fbc5b69fc87d8642a8b9586723d Mon Sep 17 00:00:00 2001 From: Ankush Dutt Date: Wed, 9 Aug 2023 16:15:43 +0530 Subject: [PATCH] COMMON: DumpArchive(): add check to skip directory, return error if a file cannot be opened --- common/archive.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/archive.cpp b/common/archive.cpp index c0f64ec7702..79b935180f6 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -92,6 +92,9 @@ Common::Error Archive::dumpArchive(String destPath) { Common::Path filePath = f->getPathInArchive().punycodeEncode(); debug(1, "File: %s", filePath.toString().c_str()); + // skip if f represents a directory + if (filePath.toString().lastChar() == '/') continue; + Common::SeekableReadStream *stream = f->createReadStream(); uint32 len = stream->size(); @@ -106,7 +109,7 @@ Common::Error Archive::dumpArchive(String destPath) { Common::DumpFile out; Common::Path outPath = Common::Path(destPath).join(filePath); if (!out.open(outPath.toString(), true)) { - warning("Archive::dumpArchive(): Can not open dump file %s", outPath.toString().c_str()); + return Common::Error(Common::kCreatingFileFailed, "Cannot open/create dump file " + outPath.toString()); } else { uint32 writtenBytes = out.write(data, len); if (writtenBytes < len) {