Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert command-line tools to use GNU-style long options #541

Merged
merged 18 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
texdiag fixes for dumpdds
walbourn committed Oct 26, 2024
commit 98c9b73275526b2347885eb9f14af4062b685a03
29 changes: 18 additions & 11 deletions Texdiag/texdiag.cpp
Original file line number Diff line number Diff line change
@@ -423,7 +423,7 @@ namespace
{
PrintLogo(false, g_ToolName, g_Description);

static const wchar_t* const s_usage =
static const wchar_t *const s_usage =
L"Usage: texdiag <command> <options> [--] <files>\n"
L"\n"
L" info Output image metadata\n"
@@ -446,7 +446,7 @@ namespace
L"\n"
L" (diff only)\n"
L" -f <format> format\n"
L" -o <filename> output filename\n"
L" -o <path/filename> output filename for diff; output path for dumpdds\n"
L" -l force output filename to lower case\n"
L" -y overwrite existing output file (if any)\n"
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[])
break;

case OPT_OUTPUTFILE:
if (dwCommand != CMD_DIFF)
if (dwCommand != CMD_DIFF && dwCommand != CMD_DUMPDDS)
{
wprintf(L"-o only valid for use with diff command\n");
wprintf(L"-o only valid for use with diff or dumpdds commands\n");
return 1;
}
else
{
std::filesystem::path path(pValue);
outputFile = path.make_preferred().native();

fileType = LookupByName(path.extension().c_str(), g_pExtFileTypes);
if (dwCommand == CMD_DIFF)
{
fileType = LookupByName(path.extension().c_str(), g_pExtFileTypes);
}
}
break;

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

auto const ext = LookupByValue(fileType, g_pDumpFileTypes);

std::filesystem::path basePath(outputFile);

if (info.depth > 1)
{
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[])
swprintf_s(subFname, L"%ls_slice%03zu", curpath.stem().c_str(), slice);
}

outputFile.assign(subFname);
outputFile.append(ext);
std::filesystem::path output(basePath);
output.append(subFname);
output.replace_extension(ext);

hr = SaveImage(img, outputFile.c_str(), fileType);
hr = SaveImage(img, output.c_str(), fileType);
if (FAILED(hr))
{
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[])
swprintf_s(subFname, L"%ls_item%03zu", curpath.stem().c_str(), item);
}

outputFile.assign(subFname);
outputFile.append(ext);
std::filesystem::path output(basePath);
output.append(subFname);
output.replace_extension(ext);

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

Unchanged files with check annotations Beta

{
const uint64_t bytes = image.width * image.height;
if (bytes > static_cast<uint64_t>(UINT32_MAX))

Check warning on line 547 in Auxiliary/DirectXTexEXR.cpp

GitHub Actions / build (windows-2022, x86-Debug-VCPKG, amd64_x86)

Conversion rules for arithmetic operations in the comparison at D:\a\DirectXTex\DirectXTex\Auxiliary\DirectXTexEXR.cpp(545) mean that one branch cannot be executed. Cast '<unknown>' to 'ULONG64' (or similar type of 8 bytes).
{
return /* HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) */ static_cast<HRESULT>(0x80070216L);
}