Skip to content

Commit

Permalink
catch exception when saving texture
Browse files Browse the repository at this point in the history
  • Loading branch information
DubbleClick committed Dec 4, 2023
1 parent a72b423 commit 6514081
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion header/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct TextureFileStruct {
inline void Message(const char* format, ...)
{
#ifdef _DEBUG
#if 0
#if 1
va_list args;
va_start(args, format);
vprintf(format, args);
Expand Down
13 changes: 11 additions & 2 deletions modules/TextureFunction.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,13 @@ export namespace TextureFunction {
{
const auto file_name = std::format("0x{:x}.dds", entry.crc_hash);
const auto file_out = dll_path / "textures" / file_name;
std::filesystem::create_directory(file_out.parent_path());
if (!std::filesystem::exists(file_out)) {
try {
if (std::filesystem::exists(file_out)) {
return;
}
if (!std::filesystem::exists(file_out.parent_path())) {
std::filesystem::create_directory(file_out.parent_path());
}
const auto hr = DirectX::SaveToDDSFile(
image.GetImages(),
image.GetImageCount(),
Expand All @@ -246,6 +251,10 @@ export namespace TextureFunction {
Warning("SaveDDSImageToDisk (%#lX%s): FAILED\n", entry.crc_hash, entry.ext.c_str());
}
}
catch (const std::exception& e) {
Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what());
return;
}
}

DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path)
Expand Down

0 comments on commit 6514081

Please sign in to comment.