Don't report unsupported file types as 'corrupted' captures

* This adds a specific error message if even the magic number doesn't look like
  a supported file type.
This commit is contained in:
baldurk
2023-06-23 18:53:41 +01:00
parent 615c02dbd7
commit 7c6b4633df
3 changed files with 8 additions and 3 deletions
+1
View File
@@ -63,6 +63,7 @@ rdcstr DoStringise(const ResultCode &el)
FileIncompatibleVersion,
"Capture file incompatible due to being made on an different major version of RenderDoc");
STRINGISE_ENUM_CLASS_NAMED(FileCorrupted, "File is corrupted");
STRINGISE_ENUM_CLASS_NAMED(FileUnrecognised, "File format is unrecognised");
STRINGISE_ENUM_CLASS_NAMED(
ImageUnsupported, "The image file or format is unrecognised or not supported in this form");
STRINGISE_ENUM_CLASS_NAMED(APIUnsupported, "API used in this capture is unsupported");
+5
View File
@@ -3803,6 +3803,10 @@ a remote server.
The capture file is corrupted or otherwise unrecognisable.
.. data:: FileUnrecognised
The file was not recognised as any supported file type.
.. data:: ImageUnsupported
The image file or format is unrecognised or not supported in this form.
@@ -3895,6 +3899,7 @@ enum class ResultCode : uint32_t
FileIOFailed,
FileIncompatibleVersion,
FileCorrupted,
FileUnrecognised,
ImageUnsupported,
APIUnsupported,
APIInitFailed,
+2 -3
View File
@@ -329,9 +329,8 @@ void RDCFile::Init(StreamReader &reader)
if(header.magic != MAGIC_HEADER)
{
SET_ERROR_RESULT(m_Error, ResultCode::FileCorrupted,
"Invalid capture file. Expected magic %08x, got %08x.", MAGIC_HEADER,
(uint32_t)header.magic);
SET_ERROR_RESULT(m_Error, ResultCode::FileUnrecognised,
"Unrecognised file type. File magic number is %08x.", (uint32_t)header.magic);
return;
}