Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24ebe5b

Browse files
authored
uvatlastool updates for some POSIX like support (#107)
1 parent0d59f52 commit24ebe5b

File tree

3 files changed

+88
-24
lines changed

3 files changed

+88
-24
lines changed

‎UVAtlasTool/UVAtlas.cpp‎

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#defineNOHELP
2121
#pragma warning(pop)
2222

23+
#if __cplusplus < 201703L
24+
#error Requires C++17 (and /Zc:__cplusplus with MSVC)
25+
#endif
26+
2327
#include<algorithm>
2428
#include<cassert>
2529
#include<cstddef>
@@ -29,6 +33,7 @@
2933
#include<cstring>
3034
#include<cwchar>
3135
#include<cwctype>
36+
#include<filesystem>
3237
#include<fstream>
3338
#include<iterator>
3439
#include<list>
@@ -357,33 +362,37 @@ namespace
357362
}
358363
else
359364
{
365+
std::filesystem::pathpath(fname +1);
366+
auto& npath = path.make_preferred();
360367
if (wcspbrk(fname,L"?*") !=nullptr)
361368
{
362369
std::list<SConversion> removeFiles;
363-
SearchForFiles(&fname[1], removeFiles,false);
370+
SearchForFiles(npath.c_str(), removeFiles,false);
364371

365-
for (auto it : removeFiles)
372+
for (auto& it : removeFiles)
366373
{
367374
_wcslwr_s(it.szSrc);
368375
excludes.insert(it.szSrc);
369376
}
370377
}
371378
else
372379
{
373-
std::wstring name =(fname +1);
380+
std::wstring name =npath.c_str();
374381
std::transform(name.begin(), name.end(), name.begin(), towlower);
375382
excludes.insert(name);
376383
}
377384
}
378385
}
379386
elseif (wcspbrk(fname,L"?*") !=nullptr)
380387
{
381-
SearchForFiles(fname, flist,false);
388+
std::filesystem::pathpath(fname);
389+
SearchForFiles(path.make_preferred().c_str(), flist,false);
382390
}
383391
else
384392
{
385393
SConversion conv = {};
386-
wcscpy_s(conv.szSrc, MAX_PATH, fname);
394+
std::filesystem::pathpath(fname);
395+
wcscpy_s(conv.szSrc, path.make_preferred().c_str());
387396
flist.push_back(conv);
388397
}
389398

@@ -438,7 +447,7 @@ namespace
438447
wprintf(L"\n");
439448
}
440449

441-
voidPrintLogo()
450+
voidPrintLogo(bool versionOnly)
442451
{
443452
wchar_t version[32] = {};
444453

@@ -466,20 +475,27 @@ namespace
466475
swprintf_s(version,L"%03d (library)", UVATLAS_VERSION);
467476
}
468477

469-
wprintf(L"Microsoft (R) UVAtlas Command-line Tool Version %ls\n", version);
470-
wprintf(L"Copyright (C) Microsoft Corp.\n");
471-
#ifdef _DEBUG
472-
wprintf(L"*** Debug build ***\n");
473-
#endif
474-
wprintf(L"\n");
478+
if (versionOnly)
479+
{
480+
wprintf(L"uvatlastool version %ls\n", version);
481+
}
482+
else
483+
{
484+
wprintf(L"Microsoft (R) UVAtlas Command-line Tool Version %ls\n", version);
485+
wprintf(L"Copyright (C) Microsoft Corp.\n");
486+
#ifdef _DEBUG
487+
wprintf(L"*** Debug build ***\n");
488+
#endif
489+
wprintf(L"\n");
490+
}
475491
}
476492

477493
voidPrintUsage()
478494
{
479-
PrintLogo();
495+
PrintLogo(false);
480496

481497
staticconstwchar_t*const s_usage =
482-
L"Usage: uvatlas <options> <files>\n"
498+
L"Usage: uvatlas <options>[--]<files>\n"
483499
L"\n"
484500
L" Input file type must be Wavefront Object (.obj)\n"
485501
L"\n"
@@ -527,7 +543,9 @@ namespace
527543
L" -fn <normal-format> format to use for writing normals/tangents/normals\n"
528544
L" -fuv <uv-format> format to use for texture coordinates\n"
529545
L" -fc <color-format> format to use for writing colors\n"
530-
L" -uv2 place UVs into a second texture coordinate channel\n";
546+
L" -uv2 place UVs into a second texture coordinate channel\n"
547+
L"\n"
548+
L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n";
531549

532550
wprintf(L"%ls", s_usage);
533551

@@ -635,12 +653,38 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
635653
// Process command line
636654
uint64_t dwOptions =0;
637655
std::list<SConversion> conversion;
656+
bool allowOpts =true;
638657

639658
for (int iArg =1; iArg < argc; iArg++)
640659
{
641660
PWSTR pArg = argv[iArg];
642661

643-
if (('-' == pArg[0]) || ('/' == pArg[0]))
662+
if (allowOpts
663+
&& ('-' == pArg[0]) && ('-' == pArg[1]))
664+
{
665+
if (pArg[2] ==0)
666+
{
667+
// "-- " is the POSIX standard for "end of options" marking to escape the '-' and '/' characters at the start of filepaths.
668+
allowOpts =false;
669+
}
670+
elseif (!_wcsicmp(pArg,L"--version"))
671+
{
672+
PrintLogo(true);
673+
return0;
674+
}
675+
elseif (!_wcsicmp(pArg,L"--help"))
676+
{
677+
PrintUsage();
678+
return0;
679+
}
680+
else
681+
{
682+
wprintf(L"Unknown option: %ls\n", pArg);
683+
return1;
684+
}
685+
}
686+
elseif (allowOpts
687+
&& (('-' == pArg[0]) || ('/' == pArg[0])))
644688
{
645689
pArg++;
646690
PWSTR pValue;
@@ -789,8 +833,11 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
789833
wprintf(L"Cannot use both if and iv at the same time\n");
790834
return1;
791835
}
792-
793-
wcscpy_s(szTexFile, MAX_PATH, pValue);
836+
else
837+
{
838+
std::filesystem::pathpath(pValue);
839+
wcscpy_s(szTexFile, path.make_preferred().c_str());
840+
}
794841
break;
795842

796843
case OPT_IMT_VERTEX:
@@ -820,7 +867,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
820867
break;
821868

822869
case OPT_OUTPUTFILE:
823-
wcscpy_s(szOutputFile, MAX_PATH, pValue);
870+
{
871+
std::filesystem::pathpath(pValue);
872+
wcscpy_s(szOutputFile, path.make_preferred().c_str());
873+
}
824874
break;
825875

826876
case OPT_TOPOLOGICAL_ADJ:
@@ -934,7 +984,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
934984

935985
case OPT_FILELIST:
936986
{
937-
std::wifstreaminFile(pValue);
987+
std::filesystem::pathpath(pValue);
988+
std::wifstreaminFile(path.make_preferred().c_str());
938989
if (!inFile)
939990
{
940991
wprintf(L"Error opening -flist file %ls\n", pValue);
@@ -951,7 +1002,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
9511002
elseif (wcspbrk(pArg,L"?*") !=nullptr)
9521003
{
9531004
constsize_t count = conversion.size();
954-
SearchForFiles(pArg, conversion, (dwOptions & (uint64_t(1) << OPT_RECURSIVE)) !=0);
1005+
std::filesystem::pathpath(pArg);
1006+
SearchForFiles(path.make_preferred().c_str(), conversion, (dwOptions& (1 << OPT_RECURSIVE)) !=0);
9551007
if (conversion.size() <= count)
9561008
{
9571009
wprintf(L"No matching files found for %ls\n", pArg);
@@ -961,8 +1013,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
9611013
else
9621014
{
9631015
SConversion conv = {};
964-
wcscpy_s(conv.szSrc, MAX_PATH,pArg);
965-
1016+
std::filesystem::pathpath(pArg);
1017+
wcscpy_s(conv.szSrc, path.make_preferred().c_str());
9661018
conversion.push_back(conv);
9671019
}
9681020
}
@@ -980,7 +1032,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
9801032
}
9811033

9821034
if (~dwOptions & (uint64_t(1) << OPT_NOLOGO))
983-
PrintLogo();
1035+
PrintLogo(false);
9841036

9851037
// Process files
9861038
for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv)

‎UVAtlasTool/UVAtlasTool_2019.vcxproj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<OpenMPSupport>true</OpenMPSupport>
143143
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
144144
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
145+
<LanguageStandard>stdcpp17</LanguageStandard>
145146
</ClCompile>
146147
<Link>
147148
<AdditionalDependencies>ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -167,6 +168,7 @@
167168
<OpenMPSupport>true</OpenMPSupport>
168169
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
169170
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
171+
<LanguageStandard>stdcpp17</LanguageStandard>
170172
</ClCompile>
171173
<Link>
172174
<AdditionalDependencies>ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -191,6 +193,7 @@
191193
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
192194
<OpenMPSupport>true</OpenMPSupport>
193195
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
196+
<LanguageStandard>stdcpp17</LanguageStandard>
194197
</ClCompile>
195198
<Link>
196199
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -217,6 +220,7 @@
217220
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
218221
<OpenMPSupport>true</OpenMPSupport>
219222
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
223+
<LanguageStandard>stdcpp17</LanguageStandard>
220224
</ClCompile>
221225
<Link>
222226
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -242,6 +246,7 @@
242246
<ConformanceMode>true</ConformanceMode>
243247
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
244248
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
249+
<LanguageStandard>stdcpp17</LanguageStandard>
245250
</ClCompile>
246251
<Link>
247252
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -267,6 +272,7 @@
267272
<ConformanceMode>true</ConformanceMode>
268273
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
269274
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
275+
<LanguageStandard>stdcpp17</LanguageStandard>
270276
</ClCompile>
271277
<Link>
272278
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>

‎UVAtlasTool/UVAtlasTool_2022.vcxproj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<OpenMPSupport>true</OpenMPSupport>
143143
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
144144
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
145+
<LanguageStandard>stdcpp17</LanguageStandard>
145146
</ClCompile>
146147
<Link>
147148
<AdditionalDependencies>ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -168,6 +169,7 @@
168169
<OpenMPSupport>true</OpenMPSupport>
169170
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
170171
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
172+
<LanguageStandard>stdcpp17</LanguageStandard>
171173
</ClCompile>
172174
<Link>
173175
<AdditionalDependencies>ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -193,6 +195,7 @@
193195
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
194196
<OpenMPSupport>true</OpenMPSupport>
195197
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
198+
<LanguageStandard>stdcpp17</LanguageStandard>
196199
</ClCompile>
197200
<Link>
198201
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -220,6 +223,7 @@
220223
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
221224
<OpenMPSupport>true</OpenMPSupport>
222225
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
226+
<LanguageStandard>stdcpp17</LanguageStandard>
223227
</ClCompile>
224228
<Link>
225229
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -246,6 +250,7 @@
246250
<ConformanceMode>true</ConformanceMode>
247251
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
248252
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
253+
<LanguageStandard>stdcpp17</LanguageStandard>
249254
</ClCompile>
250255
<Link>
251256
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -272,6 +277,7 @@
272277
<ConformanceMode>true</ConformanceMode>
273278
<AdditionalOptions>/Zc:__cplusplus /Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>
274279
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
280+
<LanguageStandard>stdcpp17</LanguageStandard>
275281
</ClCompile>
276282
<Link>
277283
<AdditionalDependencies>ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp