mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
texassemble/texconv/texdiag updated with improved -flist support (#239)
This commit is contained in:
parent
ac071b3425
commit
848e37625a
@ -20,17 +20,21 @@
|
|||||||
#define NOHELP
|
#define NOHELP
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -472,6 +476,90 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessFileList(std::wifstream& inFile, std::list<SConversion>& files)
|
||||||
|
{
|
||||||
|
std::list<SConversion> flist;
|
||||||
|
std::set<std::wstring> excludes;
|
||||||
|
wchar_t fname[1024] = {};
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
inFile >> fname;
|
||||||
|
if (!inFile)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*fname == L'#')
|
||||||
|
{
|
||||||
|
// Comment
|
||||||
|
}
|
||||||
|
else if (*fname == L'-')
|
||||||
|
{
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
std::list<SConversion> removeFiles;
|
||||||
|
SearchForFiles(&fname[1], removeFiles, false);
|
||||||
|
|
||||||
|
for (auto it : removeFiles)
|
||||||
|
{
|
||||||
|
_wcslwr_s(it.szSrc);
|
||||||
|
excludes.insert(it.szSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wstring name = (fname + 1);
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
excludes.insert(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
SearchForFiles(fname, flist, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SConversion conv = {};
|
||||||
|
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
||||||
|
flist.push_back(conv);
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.ignore(1000, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.close();
|
||||||
|
|
||||||
|
if (!excludes.empty())
|
||||||
|
{
|
||||||
|
// Remove any excluded files
|
||||||
|
for (auto it = flist.begin(); it != flist.end();)
|
||||||
|
{
|
||||||
|
std::wstring name = it->szSrc;
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
auto item = it;
|
||||||
|
++it;
|
||||||
|
if (excludes.find(name) != excludes.end())
|
||||||
|
{
|
||||||
|
flist.erase(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: No file names found in -flist\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.splice(files.end(), flist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintFormat(DXGI_FORMAT Format)
|
void PrintFormat(DXGI_FORMAT Format)
|
||||||
{
|
{
|
||||||
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
||||||
@ -1070,37 +1158,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
wprintf(L"Error opening -flist file %ls\n", pValue);
|
wprintf(L"Error opening -flist file %ls\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
wchar_t fname[1024] = {};
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
inFile >> fname;
|
|
||||||
if (!inFile)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (*fname == L'#')
|
ProcessFileList(inFile, conversion);
|
||||||
{
|
|
||||||
// Comment
|
|
||||||
}
|
|
||||||
else if (*fname == L'-')
|
|
||||||
{
|
|
||||||
wprintf(L"Command-line arguments not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (wcspbrk(fname, L"?*") != nullptr)
|
|
||||||
{
|
|
||||||
wprintf(L"Wildcards not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SConversion conv = {};
|
|
||||||
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
|
||||||
conversion.push_back(conv);
|
|
||||||
}
|
|
||||||
|
|
||||||
inFile.ignore(1000, '\n');
|
|
||||||
}
|
|
||||||
inFile.close();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -27,12 +27,14 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <wrl\client.h>
|
#include <wrl\client.h>
|
||||||
@ -617,6 +619,90 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessFileList(std::wifstream& inFile, std::list<SConversion>& files)
|
||||||
|
{
|
||||||
|
std::list<SConversion> flist;
|
||||||
|
std::set<std::wstring> excludes;
|
||||||
|
wchar_t fname[1024] = {};
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
inFile >> fname;
|
||||||
|
if (!inFile)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*fname == L'#')
|
||||||
|
{
|
||||||
|
// Comment
|
||||||
|
}
|
||||||
|
else if (*fname == L'-')
|
||||||
|
{
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
std::list<SConversion> removeFiles;
|
||||||
|
SearchForFiles(&fname[1], removeFiles, false, nullptr);
|
||||||
|
|
||||||
|
for (auto it : removeFiles)
|
||||||
|
{
|
||||||
|
_wcslwr_s(it.szSrc);
|
||||||
|
excludes.insert(it.szSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wstring name = (fname + 1);
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
excludes.insert(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
SearchForFiles(fname, flist, false, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SConversion conv = {};
|
||||||
|
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
||||||
|
flist.push_back(conv);
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.ignore(1000, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.close();
|
||||||
|
|
||||||
|
if (!excludes.empty())
|
||||||
|
{
|
||||||
|
// Remove any excluded files
|
||||||
|
for (auto it = flist.begin(); it != flist.end();)
|
||||||
|
{
|
||||||
|
std::wstring name = it->szSrc;
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
auto item = it;
|
||||||
|
++it;
|
||||||
|
if (excludes.find(name) != excludes.end())
|
||||||
|
{
|
||||||
|
flist.erase(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: No file names found in -flist\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.splice(files.end(), flist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintFormat(DXGI_FORMAT Format)
|
void PrintFormat(DXGI_FORMAT Format)
|
||||||
{
|
{
|
||||||
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
||||||
@ -1771,37 +1857,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
wprintf(L"Error opening -flist file %ls\n", pValue);
|
wprintf(L"Error opening -flist file %ls\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
wchar_t fname[1024] = {};
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
inFile >> fname;
|
|
||||||
if (!inFile)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (*fname == L'#')
|
ProcessFileList(inFile, conversion);
|
||||||
{
|
|
||||||
// Comment
|
|
||||||
}
|
|
||||||
else if (*fname == L'-')
|
|
||||||
{
|
|
||||||
wprintf(L"Command-line arguments not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (wcspbrk(fname, L"?*") != nullptr)
|
|
||||||
{
|
|
||||||
wprintf(L"Wildcards not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SConversion conv = {};
|
|
||||||
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
|
||||||
conversion.push_back(conv);
|
|
||||||
}
|
|
||||||
|
|
||||||
inFile.ignore(1000, '\n');
|
|
||||||
}
|
|
||||||
inFile.close();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -26,11 +26,14 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -477,6 +480,90 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessFileList(std::wifstream& inFile, std::list<SConversion>& files)
|
||||||
|
{
|
||||||
|
std::list<SConversion> flist;
|
||||||
|
std::set<std::wstring> excludes;
|
||||||
|
wchar_t fname[1024] = {};
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
inFile >> fname;
|
||||||
|
if (!inFile)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (*fname == L'#')
|
||||||
|
{
|
||||||
|
// Comment
|
||||||
|
}
|
||||||
|
else if (*fname == L'-')
|
||||||
|
{
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
std::list<SConversion> removeFiles;
|
||||||
|
SearchForFiles(&fname[1], removeFiles, false);
|
||||||
|
|
||||||
|
for (auto it : removeFiles)
|
||||||
|
{
|
||||||
|
_wcslwr_s(it.szSrc);
|
||||||
|
excludes.insert(it.szSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::wstring name = (fname + 1);
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
excludes.insert(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (wcspbrk(fname, L"?*") != nullptr)
|
||||||
|
{
|
||||||
|
SearchForFiles(fname, flist, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SConversion conv = {};
|
||||||
|
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
||||||
|
flist.push_back(conv);
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.ignore(1000, '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
inFile.close();
|
||||||
|
|
||||||
|
if (!excludes.empty())
|
||||||
|
{
|
||||||
|
// Remove any excluded files
|
||||||
|
for (auto it = flist.begin(); it != flist.end();)
|
||||||
|
{
|
||||||
|
std::wstring name = it->szSrc;
|
||||||
|
std::transform(name.begin(), name.end(), name.begin(), towlower);
|
||||||
|
auto item = it;
|
||||||
|
++it;
|
||||||
|
if (excludes.find(name) != excludes.end())
|
||||||
|
{
|
||||||
|
flist.erase(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flist.empty())
|
||||||
|
{
|
||||||
|
wprintf(L"WARNING: No file names found in -flist\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.splice(files.end(), flist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrintFormat(DXGI_FORMAT Format)
|
void PrintFormat(DXGI_FORMAT Format)
|
||||||
{
|
{
|
||||||
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
for (auto pFormat = g_pFormats; pFormat->name; pFormat++)
|
||||||
@ -3296,37 +3383,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
wprintf(L"Error opening -flist file %ls\n", pValue);
|
wprintf(L"Error opening -flist file %ls\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
wchar_t fname[1024] = {};
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
inFile >> fname;
|
|
||||||
if (!inFile)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (*fname == L'#')
|
ProcessFileList(inFile, conversion);
|
||||||
{
|
|
||||||
// Comment
|
|
||||||
}
|
|
||||||
else if (*fname == L'-')
|
|
||||||
{
|
|
||||||
wprintf(L"Command-line arguments not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (wcspbrk(fname, L"?*") != nullptr)
|
|
||||||
{
|
|
||||||
wprintf(L"Wildcards not supported in -flist file\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SConversion conv = {};
|
|
||||||
wcscpy_s(conv.szSrc, MAX_PATH, fname);
|
|
||||||
conversion.push_back(conv);
|
|
||||||
}
|
|
||||||
|
|
||||||
inFile.ignore(1000, '\n');
|
|
||||||
}
|
|
||||||
inFile.close();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user