| 1 |
/* |
| 2 |
Copyright (C) 2009-2010 wxLauncher Team |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License |
| 6 |
as published by the Free Software Foundation; either version 2 |
| 7 |
of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "generated/configure_launcher.h" |
| 20 |
#include "datastructures/FSOExecutable.h" |
| 21 |
#include <wx/dir.h> |
| 22 |
#include <wx/tokenzr.h> |
| 23 |
|
| 24 |
#include "global/MemoryDebugging.h" |
| 25 |
|
| 26 |
// on linux these seem to be defined to be gnu_dev_* |
| 27 |
#ifdef major |
| 28 |
#undef major |
| 29 |
#endif |
| 30 |
#ifdef minor |
| 31 |
#undef minor |
| 32 |
#endif |
| 33 |
|
| 34 |
enum BuildCapabilities_enum { |
| 35 |
SUPPORT_OPENAL = 1<<0, |
| 36 |
NOT_SUPPORT_DIRECT3D = 1<<1, |
| 37 |
} BuildCapabilities; |
| 38 |
|
| 39 |
FSOExecutable::FSOExecutable(): |
| 40 |
major(0), minor(0), revision(0), |
| 41 |
inferno(false), sse(0), _64bit(false), |
| 42 |
configuration(CONFIG_RELEASE), |
| 43 |
build(0), year(0), month(0), |
| 44 |
antipodes(false),antNumber(0), |
| 45 |
buildCaps(0) |
| 46 |
{ |
| 47 |
} |
| 48 |
|
| 49 |
FSOExecutable::~FSOExecutable() { |
| 50 |
} |
| 51 |
|
| 52 |
bool FSOExecutable::SupportsDirect3D() { |
| 53 |
return (buildCaps & NOT_SUPPORT_DIRECT3D) == 0; |
| 54 |
} |
| 55 |
|
| 56 |
bool FSOExecutable::SupportsOpenAL() { |
| 57 |
return (buildCaps & SUPPORT_OPENAL) > 0; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
bool FSOExecutable::IsRootFolderValid(const wxFileName& path, bool quiet) { |
| 62 |
if ( !path.IsOk() ) { |
| 63 |
if (!quiet) { |
| 64 |
wxLogError(_T(" New root folder %s is not OK"), path.GetFullPath().c_str()); |
| 65 |
} |
| 66 |
return false; |
| 67 |
} |
| 68 |
if ( path.GetPath().IsEmpty() ) { |
| 69 |
if (!quiet) { |
| 70 |
wxLogError(_T(" Root folder %s is empty"), path.GetFullPath().c_str()); |
| 71 |
} |
| 72 |
return false; |
| 73 |
} |
| 74 |
return HasFSOExecutables(path); |
| 75 |
} |
| 76 |
|
| 77 |
bool FSOExecutable::HasFSOExecutables(const wxFileName& path) { |
| 78 |
wxCHECK_MSG(path.IsOk(), false, |
| 79 |
wxString::Format(_T("provided path %s to HasFSOExecutables is invalid"), |
| 80 |
path.GetFullPath().c_str())); |
| 81 |
|
| 82 |
return !FSOExecutable::GetBinariesFromRootFolder(path, true).IsEmpty(); |
| 83 |
} |
| 84 |
|
| 85 |
#if IS_LINUX |
| 86 |
bool IsFileToIgnore(const wxString& filename) { |
| 87 |
return filename.EndsWith(_T(".exe")) |
| 88 |
|| filename.EndsWith(_T(".map")) |
| 89 |
|| filename.EndsWith(_T(".pdb")) |
| 90 |
|| filename.EndsWith(_T(".app")) |
| 91 |
|| filename.EndsWith(_T(".ini")) |
| 92 |
|| filename.EndsWith(_T(".tar")) |
| 93 |
|| filename.EndsWith(_T(".gz")) |
| 94 |
|| filename.EndsWith(_T(".bz2")) |
| 95 |
|| filename.EndsWith(_T(".tgz")) |
| 96 |
|| filename.EndsWith(_T(".tbz")) |
| 97 |
|| filename.EndsWith(_T(".tbz2")); |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
#if IS_WIN32 |
| 102 |
#define EXECUTABLE_GLOB_PATTERN _T("fs2_*.exe") |
| 103 |
#define FRED_EXECUTABLE_GLOB_PATTERN _T("fred2_*.exe") |
| 104 |
#elif IS_LINUX |
| 105 |
#define EXECUTABLE_GLOB_PATTERN _T("fs2_*") |
| 106 |
#define FRED_EXECUTABLE_GLOB_PATTERN _T("fred2_*") |
| 107 |
#elif IS_APPLE |
| 108 |
#define EXECUTABLE_GLOB_PATTERN _T("fs2_*.app") |
| 109 |
#define FRED_EXECUTABLE_GLOB_PATTERN _T("fred2_*.app") |
| 110 |
#else |
| 111 |
#error "One of IS_WIN32, IS_LINUX, IS_APPLE must evaluate to true" |
| 112 |
#endif |
| 113 |
|
| 114 |
// quiet is for when you just want to check whether there are FSO/FRED binaries |
| 115 |
wxArrayString FSOExecutable::GetBinariesFromRootFolder(const wxFileName& path, bool quiet) { |
| 116 |
return FSOExecutable::GetBinariesFromRootFolder(path, EXECUTABLE_GLOB_PATTERN, quiet); |
| 117 |
} |
| 118 |
|
| 119 |
wxArrayString FSOExecutable::GetFredBinariesFromRootFolder(const wxFileName& path, bool quiet) { |
| 120 |
return FSOExecutable::GetBinariesFromRootFolder(path, FRED_EXECUTABLE_GLOB_PATTERN, quiet); |
| 121 |
} |
| 122 |
|
| 123 |
wxArrayString FSOExecutable::GetBinariesFromRootFolder(const wxFileName& path, const wxString& globPattern, bool quiet) { |
| 124 |
wxArrayString files; |
| 125 |
|
| 126 |
// Check args because this function gets crap tossed at it to validate |
| 127 |
wxString pathStr(path.GetPath()); |
| 128 |
if (pathStr.IsEmpty()) |
| 129 |
{ |
| 130 |
wxLogInfo(wxT("GetBinaries called with empty root folder")); |
| 131 |
return files; |
| 132 |
} |
| 133 |
|
| 134 |
wxDir folder(pathStr); |
| 135 |
if (!folder.IsOpened()) |
| 136 |
{ |
| 137 |
wxLogInfo(wxT("GetBinaries called on '%s' which cannot be opened"), |
| 138 |
pathStr.c_str()); |
| 139 |
return files; |
| 140 |
} |
| 141 |
wxString filename; |
| 142 |
|
| 143 |
#if IS_APPLE // Binaries are directories on OSX. |
| 144 |
bool cont = folder.GetFirst(&filename, globPattern, wxDIR_DIRS); |
| 145 |
#else |
| 146 |
bool cont = folder.GetFirst(&filename, globPattern, wxDIR_FILES); |
| 147 |
#endif |
| 148 |
|
| 149 |
while (cont) { |
| 150 |
#if IS_LINUX |
| 151 |
if ( !IsFileToIgnore(filename) ) { |
| 152 |
#endif |
| 153 |
files.Add(filename); |
| 154 |
#if IS_LINUX |
| 155 |
} |
| 156 |
#endif |
| 157 |
cont = folder.GetNext(&filename); |
| 158 |
} |
| 159 |
|
| 160 |
// filter out launcher binaries (at least on OSX) |
| 161 |
for (int i = files.GetCount() - 1; i >= 0; --i) { |
| 162 |
if (files[i].Lower().Find(_T("launcher")) != wxNOT_FOUND) { |
| 163 |
files.RemoveAt(i); |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
#if IS_APPLE |
| 168 |
// find actual (Unix) executable inside .app bundle and call the path to it the "executable" |
| 169 |
for (wxArrayString::iterator it = files.begin(), end = files.end(); it != end; ++it) { |
| 170 |
wxString pathToBin = |
| 171 |
wxDir::FindFirst(path.GetPath(wxPATH_GET_SEPARATOR) + *it + _T("/Contents/MacOS"), |
| 172 |
_T("*"), |
| 173 |
wxDIR_FILES); |
| 174 |
pathToBin.Replace(path.GetPath(wxPATH_GET_SEPARATOR), _T("")); |
| 175 |
*it = pathToBin; |
| 176 |
} |
| 177 |
#endif |
| 178 |
|
| 179 |
if (!quiet) { |
| 180 |
wxString execType = globPattern.Lower().Find(_T("fred")) == wxNOT_FOUND ? _T("FS2") : _T("FRED2"); |
| •181 |
wxLogInfo(_T(" Found %u %s Open executables in '%s'"), |
| 182 |
static_cast<unsigned>(files.GetCount()), execType.c_str(), path.GetPath().c_str()); |
| 183 |
|
| 184 |
for (size_t i = 0, n = files.GetCount(); i < n; ++i) { |
| 185 |
wxLogDebug(_T("Found executable: %s"), files.Item(i).c_str()); |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
return files; |
| 190 |
} |
| 191 |
|
| 192 |
FSOExecutable FSOExecutable::GetBinaryVersion(wxString binaryname) { |
| 193 |
wxLogDebug(_T("Making version struct for the executable '%s'"), binaryname.c_str()); |
| 194 |
FSOExecutable ver; |
| 195 |
wxStringTokenizer tok(binaryname, _T("_.- ()[]/")); |
| 196 |
ver.executablename = binaryname; |
| 197 |
|
| 198 |
if ( !tok.HasMoreTokens() ) { |
| 199 |
wxLogError( |
| 200 |
_T("Did not find initial 'fs2' or 'fred2' token in executable '%s'"), |
| 201 |
binaryname.c_str()); |
| 202 |
return ver; |
| 203 |
} |
| 204 |
wxString first(tok.GetNextToken()); |
| 205 |
if ( tok.HasMoreTokens() && (!first.CmpNoCase(_T("fred2")) || !first.CmpNoCase(_T("fs2"))) ) { |
| 206 |
wxString second(tok.GetNextToken()); |
| 207 |
if ( !second.CmpNoCase(_T("open")) ) { |
| 208 |
if ( !first.CmpNoCase(_T("fs2")) ) { |
| 209 |
ver.binaryname = _T("FS2 Open"); |
| 210 |
} else { |
| 211 |
ver.binaryname = _T("FRED2 Open"); |
| 212 |
} |
| 213 |
} else { |
| 214 |
wxLogWarning(_T("was expecting 'open'; got %s in executable %s"), |
| 215 |
second.c_str(), binaryname.c_str()); |
| 216 |
return ver; |
| 217 |
} |
| 218 |
} else { |
| 219 |
wxLogWarning(_T("executable name '%s' too short"), binaryname.c_str()); |
| 220 |
return ver; |
| 221 |
} |
| 222 |
|
| 223 |
while ( tok.HasMoreTokens() ) { |
| 224 |
wxString token = tok.GetNextToken(); |
| 225 |
wxString temp; |
| 226 |
long tempVersion; |
| 227 |
|
| 228 |
if (token.IsEmpty()) { // can happen in OS X nightly debug builds |
| 229 |
// do nothing |
| 230 |
} else if ( !token.CmpNoCase(_T("exe")) ) { |
| 231 |
; // do nothing |
| 232 |
#if IS_APPLE |
| 233 |
} else if ( !token.CmpNoCase(_T("app")) ) { |
| 234 |
break; // we've reached the end of the app name |
| 235 |
#endif |
| 236 |
} else if (token.ToLong(&tempVersion) && token.size() == 8) { |
| 237 |
// must be a date from a nightly build; add it to the string |
| 238 |
if (!ver.string.IsEmpty()) { |
| 239 |
ver.string += _T(" "); |
| 240 |
} |
| 241 |
wxString year(token.Mid(0, 4)); |
| 242 |
wxString month(token.Mid(4, 2)); |
| 243 |
wxString day(token.Mid(6, 2)); |
| 244 |
|
| 245 |
year.ToLong(&ver.year); |
| 246 |
year.ToLong(&ver.month); |
| 247 |
// not interested in the day at this time |
| 248 |
|
| 249 |
// add it in YYYY-MM-DD format |
| 250 |
ver.string += year; |
| 251 |
ver.string += _T("-"); |
| 252 |
ver.string += month; |
| 253 |
ver.string += _T("-"); |
| 254 |
ver.string += day; |
| 255 |
} else if ( (ver.year > 2015 || (ver.year == 2015 && ver.month > 5)) |
| 256 |
&& token.size() == 7 && SmellsLikeGitCommitHash(token)) |
| 257 |
{ |
| 258 |
// must be a commit hash on a nightly build |
| 259 |
if (ver.string.size() > 0) { |
| 260 |
ver.string += _T(' '); |
| 261 |
} |
| 262 |
ver.string += token; |
| 263 |
} else if (token.ToLong(&tempVersion) && ver.antipodes && ver.antNumber == 0) { |
| 264 |
// must be antipodes number |
| 265 |
if ( tempVersion > 0 ) { |
| 266 |
ver.antNumber = (int)tempVersion; |
| 267 |
} else { |
| 268 |
wxLogWarning( |
| 269 |
_T("antipodes number out of range (%ld) in executable %s"), |
| 270 |
tempVersion, binaryname.c_str()); |
| 271 |
} |
| 272 |
} else if ( token.ToLong(&tempVersion) && ver.major == 0 ) { |
| 273 |
// must be major version number |
| 274 |
if ( tempVersion < 1000 && tempVersion > 0 ) { |
| 275 |
ver.major = (int)tempVersion; |
| 276 |
} else { |
| 277 |
wxLogWarning( |
| 278 |
_T("major version number out of range (%ld) in executable %s"), |
| 279 |
tempVersion, binaryname.c_str()); |
| 280 |
} |
| 281 |
} else if ( token.ToLong(&tempVersion) && ver.minor == 0 ) { |
| 282 |
// must be minor version number |
| 283 |
if ( tempVersion < 1000 && tempVersion >= 0 ) { |
| 284 |
ver.minor = (int)tempVersion; |
| 285 |
} else { |
| 286 |
wxLogWarning( |
| 287 |
_T("minor version number out of range (%ld) in executable %s"), |
| 288 |
tempVersion, binaryname.c_str()); |
| 289 |
} |
| 290 |
} else if ( token.ToLong(&tempVersion) && ver.revision == 0) { |
| 291 |
// must be revision version number |
| 292 |
if ( tempVersion < 1000 && tempVersion >= 0 ) { |
| 293 |
ver.revision = (int)tempVersion; |
| 294 |
} else { |
| 295 |
wxLogWarning( |
| 296 |
_T("Revision version number out of range (%ld) in executable %s"), |
| 297 |
tempVersion, binaryname.c_str()); |
| 298 |
} |
| 299 |
} else if ( !token.CmpNoCase(_T("d")) || !token.CmpNoCase(_T("debug")) ) { |
| 300 |
ver.configuration = CONFIG_DEBUG; |
| 301 |
} else if ( !token.CmpNoCase(_T("FastDbg")) ) { |
| 302 |
ver.configuration = CONFIG_FASTDEBUG; |
| 303 |
} else if ( token.Lower().EndsWith(_T("d"), &temp) ) { |
| 304 |
if ( temp.ToLong(&tempVersion) ) { |
| 305 |
// is the revision version number |
| 306 |
if ( tempVersion < 1000 && tempVersion >= 0 ) { |
| 307 |
ver.revision = (int)tempVersion; |
| 308 |
ver.configuration = CONFIG_DEBUG; |
| 309 |
} else { |
| 310 |
wxLogWarning( |
| 311 |
_T("Revision version number out of range (%ld) in executable %s"), |
| 312 |
tempVersion, binaryname.c_str()); |
| 313 |
} |
| 314 |
} else { |
| 315 |
wxLogWarning( |
| 316 |
_T("Token ending in 'd' is not a number (%s) in executable %s"), |
| 317 |
token.c_str(), binaryname.c_str()); |
| 318 |
ver.string += wxString::Format(ver.string.IsEmpty() ? _T("%s") : _T(" %s") , token.c_str()); |
| 319 |
} |
| 320 |
} else if ( token.Lower().EndsWith(_T("r"), &temp) ) { |
| 321 |
if (temp.IsEmpty()) { |
| 322 |
// do nothing, the 'r' wasn't preceded by a number |
| 323 |
} else if ( temp.ToLong(&tempVersion) ) { |
| 324 |
// is the revision version number |
| 325 |
if ( tempVersion < 1000 && tempVersion >= 0 ) { |
| 326 |
ver.revision = (int)tempVersion; |
| 327 |
ver.configuration = CONFIG_RELEASE; |
| 328 |
} else { |
| 329 |
wxLogWarning( |
| 330 |
_T("Revision version number out of range (%ld) in executable %s"), |
| 331 |
tempVersion, binaryname.c_str()); |
| 332 |
} |
| 333 |
} else { |
| 334 |
wxLogWarning( |
| 335 |
_T("Token ending in 'r' is not a number (%s) in executable %s"), |
| 336 |
token.c_str(), binaryname.c_str()); |
| 337 |
ver.string += wxString::Format(ver.string.IsEmpty() ? _T("%s") : _T(" %s"), token.c_str()); |
| 338 |
} |
| 339 |
} else if ( token.StartsWith(_T("r"), &temp) && temp.ToLong(&tempVersion) ) { |
| 340 |
// must be a revision number from SirKnightly's builds |
| 341 |
if ( tempVersion > 0 ) { |
| 342 |
ver.build = (int)tempVersion; |
| 343 |
} else { |
| 344 |
wxLogWarning( |
| 345 |
_T("SirKnightly build number out of range (%ld) in executable %s"), |
| 346 |
tempVersion, binaryname.c_str()); |
| 347 |
} |
| 348 |
} else if ( !token.CmpNoCase(_T("ant")) ) { |
| 349 |
ver.antipodes = true; |
| 350 |
} else if ( token.Lower().StartsWith(_T("ant"), &temp) && !ver.antipodes ) { |
| 351 |
ver.antipodes = true; |
| 352 |
|
| 353 |
// in case the token is of the format, e.g., "Ant8" |
| 354 |
long antNumber; |
| 355 |
if (temp.ToLong(&antNumber)) { |
| 356 |
if (antNumber > 0) { |
| 357 |
ver.antNumber = antNumber; |
| 358 |
} else { |
| 359 |
wxLogWarning(_T("Invalid antipodes number %ld in executable %s"), |
| 360 |
antNumber, binaryname.c_str()); |
| 361 |
} |
| 362 |
} |
| 363 |
} else if ( !token.CmpNoCase(_T("avx")) ) { |
| 364 |
ver.sse = 3; |
| 365 |
} else if ( !token.CmpNoCase(_T("sse2")) ) { |
| 366 |
ver.sse = 2; |
| 367 |
} else if ( !token.CmpNoCase(_T("sse")) ) { |
| 368 |
if (ver.string.Lower().EndsWith(_T("no"))) { // probably NO SSE |
| 369 |
ver.sse = -1; |
| 370 |
|
| 371 |
const int lastSpaceIndex = ver.string.Find(_T(' '), true); |
| 372 |
|
| 373 |
if (lastSpaceIndex == wxNOT_FOUND) { |
| 374 |
wxASSERT(ver.string.Lower() == _T("no")); |
| 375 |
ver.string = wxEmptyString; |
| 376 |
} else { |
| 377 |
ver.string = ver.string.Mid(0, lastSpaceIndex); |
| 378 |
} |
| 379 |
} else { |
| 380 |
ver.sse = 1; |
| 381 |
} |
| 382 |
} else if ( !token.CmpNoCase(_T("inf")) || !token.CmpNoCase(_T("inferno"))) { |
| 383 |
ver.inferno = true; |
| 384 |
} else if ( !token.CmpNoCase(_T("x64")) ) { |
| 385 |
ver._64bit = true; |
| 386 |
} else { |
| 387 |
if (!ver.string.IsEmpty()) { |
| 388 |
ver.string += _T(" "); |
| 389 |
} |
| 390 |
ver.string += token; |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
return ver; |
| 395 |
} |
| 396 |
|
| 397 |
/** Returns the version string to display to the user from a previously |
| 398 |
parsed FSOVersion object. The intention is to display all information that |
| 399 |
is normally encoded into the executable's file name into a long string that |
| 400 |
more user friendly. |
| 401 |
|
| 402 |
The resulting string looks something like this: \verbatim |
| 403 |
FS2 Open Antipodes 4 Debug SSE2 |
| 404 |
FS2 Open 3.6.10 Inferno SSE |
| 405 |
FRED2 Open 3.6.11 Debug |
| 406 |
\endverbatim |
| 407 |
*/ |
| 408 |
wxString FSOExecutable::GetVersionString() const { |
| 409 |
const bool hasVersion = (this->major != 0) || this->antipodes; |
| 410 |
const bool useFullVersion = hasVersion && !this->antipodes; |
| 411 |
|
| 412 |
// just to improve code readability |
| 413 |
wxString antipodesStr; |
| 414 |
if (this->antipodes) { |
| 415 |
antipodesStr += _T(" Antipodes"); |
| 416 |
if (this->antNumber != 0) { |
| 417 |
antipodesStr += wxString::Format(_T(" %d"), antNumber); |
| 418 |
} |
| 419 |
} |
| 420 |
|
| 421 |
// again, to improve code readability |
| 422 |
wxString sseStr; |
| 423 |
switch (this->sse) { |
| 424 |
case -1: |
| 425 |
sseStr = _T(" NO SSE"); |
| 426 |
break; |
| 427 |
case 1: |
| 428 |
sseStr = _T(" SSE"); |
| 429 |
break; |
| 430 |
case 2: |
| 431 |
sseStr = _T(" SSE2"); |
| 432 |
break; |
| 433 |
case 3: |
| 434 |
sseStr = _T(" AVX"); |
| 435 |
break; |
| 436 |
default: |
| 437 |
// nothing |
| 438 |
break; |
| 439 |
} |
| 440 |
|
| 441 |
wxString configString; |
| 442 |
switch(this->configuration) |
| 443 |
{ |
| 444 |
case CONFIG_RELEASE: |
| 445 |
configString = _T(""); |
| 446 |
break; |
| 447 |
case CONFIG_DEBUG: |
| 448 |
configString = _T(" Debug"); |
| 449 |
break; |
| 450 |
case CONFIG_FASTDEBUG: |
| 451 |
configString = _T(" Fast Debug"); |
| 452 |
break; |
| 453 |
default: |
| 454 |
configString = _T(""); |
| 455 |
break; |
| 456 |
} |
| 457 |
|
| 458 |
return wxString::Format(_T("%s%s%s%s%s%s%s%s%s"), |
| 459 |
(this->binaryname.IsEmpty()) ? _T("Unknown") : this->binaryname.c_str(), // FS2 Open |
| 460 |
(useFullVersion) ? wxString::Format(_T(" %d.%d.%d"), this->major, this->minor, this->revision).c_str() : wxEmptyString, |
| 461 |
(this->antipodes) ? antipodesStr.c_str() : wxEmptyString, |
| 462 |
(this->build == 0) ? wxEmptyString : wxString::Format((hasVersion) ? _T(" (Build %d)") : _T(" Build %d"), this->build).c_str(), |
| 463 |
(this->string.IsEmpty()) ? wxEmptyString : wxString::Format((hasVersion) ? _T(" (%s)") : _T(" %s"), this->string.c_str()).c_str(), |
| 464 |
configString.c_str(), |
| 465 |
(this->inferno && !this->antipodes) ? _T(" Inferno") : wxEmptyString, |
| 466 |
(this->sse == 0) ? wxEmptyString : sseStr.c_str(), |
| 467 |
(this->_64bit) ? _T(" 64-bit") : wxEmptyString |
| 468 |
); |
| 469 |
} |
| 470 |
|
| 471 |
bool FSOExecutable::SmellsLikeGitCommitHash(const wxString & str) |
| 472 |
{ |
| 473 |
auto c = str.begin(); |
| 474 |
while (c != str.end()) { |
| 475 |
switch (int(*c)) { |
| 476 |
case _T('0'): |
| 477 |
case _T('1'): |
| 478 |
case _T('2'): |
| 479 |
case _T('3'): |
| 480 |
case _T('4'): |
| 481 |
case _T('5'): |
| 482 |
case _T('6'): |
| 483 |
case _T('7'): |
| 484 |
case _T('8'): |
| 485 |
case _T('9'): |
| 486 |
case _T('a'): |
| 487 |
case _T('b'): |
| 488 |
case _T('c'): |
| 489 |
case _T('d'): |
| 490 |
case _T('e'): |
| 491 |
case _T('f'): |
| 492 |
break; |
| 493 |
default: |
| 494 |
return false; |
| 495 |
} |
| 496 |
c++; |
| 497 |
} |
| 498 |
return true; |
| 499 |
} |