Skip to content

Commit 98c9b73

Browse files
committed
texdiag fixes for dumpdds
1 parent 45cf94a commit 98c9b73

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

Texdiag/texdiag.cpp

+18-11
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ namespace
423423
{
424424
PrintLogo(false, g_ToolName, g_Description);
425425

426-
static const wchar_t* const s_usage =
426+
static const wchar_t *const s_usage =
427427
L"Usage: texdiag <command> <options> [--] <files>\n"
428428
L"\n"
429429
L" info Output image metadata\n"
@@ -446,7 +446,7 @@ namespace
446446
L"\n"
447447
L" (diff only)\n"
448448
L" -f <format> format\n"
449-
L" -o <filename> output filename\n"
449+
L" -o <path/filename> output filename for diff; output path for dumpdds\n"
450450
L" -l force output filename to lower case\n"
451451
L" -y overwrite existing output file (if any)\n"
452452
L" -c <hex-RGB> highlight difference color (defaults to off)\n"
@@ -3173,17 +3173,20 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
31733173
break;
31743174

31753175
case OPT_OUTPUTFILE:
3176-
if (dwCommand != CMD_DIFF)
3176+
if (dwCommand != CMD_DIFF && dwCommand != CMD_DUMPDDS)
31773177
{
3178-
wprintf(L"-o only valid for use with diff command\n");
3178+
wprintf(L"-o only valid for use with diff or dumpdds commands\n");
31793179
return 1;
31803180
}
31813181
else
31823182
{
31833183
std::filesystem::path path(pValue);
31843184
outputFile = path.make_preferred().native();
31853185

3186-
fileType = LookupByName(path.extension().c_str(), g_pExtFileTypes);
3186+
if (dwCommand == CMD_DIFF)
3187+
{
3188+
fileType = LookupByName(path.extension().c_str(), g_pExtFileTypes);
3189+
}
31873190
}
31883191
break;
31893192

@@ -3656,6 +3659,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
36563659

36573660
auto const ext = LookupByValue(fileType, g_pDumpFileTypes);
36583661

3662+
std::filesystem::path basePath(outputFile);
3663+
36593664
if (info.depth > 1)
36603665
{
36613666
wprintf(L"Writing by mip (%3zu) and slice (%3zu)...", info.mipLevels, info.depth);
@@ -3684,10 +3689,11 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
36843689
swprintf_s(subFname, L"%ls_slice%03zu", curpath.stem().c_str(), slice);
36853690
}
36863691

3687-
outputFile.assign(subFname);
3688-
outputFile.append(ext);
3692+
std::filesystem::path output(basePath);
3693+
output.append(subFname);
3694+
output.replace_extension(ext);
36893695

3690-
hr = SaveImage(img, outputFile.c_str(), fileType);
3696+
hr = SaveImage(img, output.c_str(), fileType);
36913697
if (FAILED(hr))
36923698
{
36933699
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
@@ -3728,10 +3734,11 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
37283734
swprintf_s(subFname, L"%ls_item%03zu", curpath.stem().c_str(), item);
37293735
}
37303736

3731-
outputFile.assign(subFname);
3732-
outputFile.append(ext);
3737+
std::filesystem::path output(basePath);
3738+
output.append(subFname);
3739+
output.replace_extension(ext);
37333740

3734-
hr = SaveImage(img, outputFile.c_str(), fileType);
3741+
hr = SaveImage(img, output.c_str(), fileType);
37353742
if (FAILED(hr))
37363743
{
37373744
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));

0 commit comments

Comments
 (0)