48 _versionMajor(0), _versionMinor(0), _versionBuild(0) {
119 return (major << 16) + minor;
136 bool success =
false;
155 '\0',
'F',
'\0',
'i',
'\0',
'l',
'\0',
'e',
'\0',
'V',
'\0',
'e',
'\0',
'r',
'\0',
's',
'\0',
'i',
'\0',
'o',
'\0',
'n',
'\0' 159 '\0',
'P',
'\0',
'r',
'\0',
'i',
'\0',
'v',
'\0',
'a',
'\0',
't',
'\0',
'e',
'\0',
'B',
'\0',
'u',
'\0',
'i',
'\0',
'l',
'\0',
'd',
'\0' 169 if ((size - (version - binary.
get())) < (
sizeof(
kVersionWin) + 24))
174 if ((size - (build - binary.
get())) < (
sizeof(
kBuildWin) + 14))
177 bool success =
false;
198 (build [
sizeof(
kBuildWin ) + 11] == 0) &&
199 (build [
sizeof(
kBuildWin ) + 13] == 0) &&
211 isdigit(build [
sizeof(
kBuildWin ) + 2]) &&
212 isdigit(build [
sizeof(
kBuildWin ) + 4]) &&
213 isdigit(build [
sizeof(
kBuildWin ) + 6]) &&
214 isdigit(build [
sizeof(
kBuildWin ) + 8]) &&
215 isdigit(build [
sizeof(
kBuildWin ) + 10]) &&
216 isdigit(build [
sizeof(
kBuildWin ) + 12])) {
243 static const byte kVersionMac[42] = {
244 '\0',
'\0',
'S',
't',
'a',
'r',
' ',
'W',
'a',
'r',
's',
':',
' ',
'K',
'n',
'i',
'g',
'h',
't',
's',
' ',
'o',
'f',
' ',
245 't',
'h',
'e',
' ',
'O',
'l',
'd',
' ',
'R',
'e',
'p',
'u',
'b',
'l',
'i',
'c',
'\0',
'\0' 257 binary.
reset(
readFile(appDir,
"Knights of the Old Republic", size));
262 byte *version = std::search(binary.
get(), binary.
get() + size, kVersionMac, kVersionMac +
sizeof(kVersionMac));
263 if ((version - binary.
get()) < 20)
266 bool success =
false;
269 if ((version[-11] == 0) &&
270 (version[-12] == 0) &&
271 (version[-19] == 0) &&
272 (version[- 3] ==
',') &&
273 (version[- 6] ==
',') &&
274 (version[- 9] ==
',') &&
275 (version[- 9] ==
',') &&
276 (version[- 2] ==
' ') &&
277 (version[- 5] ==
' ') &&
278 (version[- 8] ==
' ')) {
281 if (isdigit(version[- 1]) &&
282 isdigit(version[- 4]) &&
283 isdigit(version[- 7]) &&
284 isdigit(version[-10]) &&
285 isdigit(version[-13]) &&
286 isdigit(version[-14]) &&
287 isdigit(version[-15]) &&
288 isdigit(version[-16]) &&
289 isdigit(version[-17]) &&
290 isdigit(version[-18])) {
317 static const byte kVersionXbox[9] = {
318 '\0',
'R',
'e',
'l',
'e',
'a',
's',
'e',
'\0' 327 byte *version = std::search(binary.
get(), binary.
get() + size, kVersionXbox, kVersionXbox +
sizeof(kVersionXbox));
328 if ((version - binary.
get()) < 13)
331 bool success =
false;
334 if ((version[-12] == 0) &&
335 (version[- 2] ==
'.') &&
336 (version[- 7] ==
'.') &&
337 (version[-10] ==
'.')) {
340 if (isdigit(version[- 1]) &&
341 isdigit(version[- 3]) &&
342 isdigit(version[- 4]) &&
343 isdigit(version[- 5]) &&
344 isdigit(version[- 6]) &&
345 isdigit(version[- 8]) &&
346 isdigit(version[- 9]) &&
347 isdigit(version[-11])) {
384 if (!file.
open(path))
390 if (file.
read(buffer.
get(), size) != size)
bool isTooNew() const
Is this version newer than the optimum?
uint32 getVersionBuild() const
Return the build number.
A class holding an UTF-8 string.
void reset(PointerType o=0)
Resets the pointer with the new value.
bool detectWindows(const Common::UString &directory)
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
bool detect(const Common::UString &directory)
Try to detect the version of the KotOR installation in this directory.
bool detectXbox(const Common::UString &directory)
A simple streaming file reading class.
Utility functions to handle files used in BioWare's Aurora engine.
byte * readFile(const Common::UString &directory, const Common::UString &file, size_t &size)
Common::UString getPlatformName() const
A simple scoped smart pointer template.
bool isTooOld() const
Is this version older than the optimum?
UString findFirst(const UString &str, bool caseInsensitive) const
Find the first file ending with the given string.
Aurora::Platform _platform
Aurora::Platform getPlatform() const
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
bool hasVersion() const
Did we detect a version?
Version(Aurora::Platform platform)
bool open(const UString &fileName)
Try to open the file with the given fileName.
static uint32 makeCombinedVersion(uint32 major, uint32 minor)
uint32 _versionBuild
v1.03.514078 -> 514078
Star Wars: Knights of the Old Republic installation version detection.
size_t read(void *dataPtr, size_t dataSize)
Read data from the stream.
uint16 getOptimumVersionMinor() const
Return the optimum minor version.
bool empty() const
Is the string empty?
static const byte kBuildWin[25]
uint16 getVersionMinor() const
Return the minor version.
static const byte kVersionWin[23]
bool detectMacOSX(const Common::UString &directory)
Implementing the stream reading interfaces for files.
uint16 getVersionMajor() const
Return the major version.
PointerType get() const
Returns the plain pointer value.
size_t size() const
Obtains the total size of the stream, measured in bytes.
uint16 _versionMinor
v1.03.514078 -> 3
Common::UString getOptimumVersionString()
bool addDirectory(const UString &directory, int recurseDepth=0)
Add a directory to the list.
Common::UString getPlatformDescription(Platform platform)
Return the human readable string of a Platform.
uint16 _versionMajor
v1.03.514078 -> 1
Common::UString getVersionString() const
uint16 getOptimumVersionMajor() const
Return the optimum major version.
Utility class for manipulating file paths.
static UString findSubDirectory(const UString &directory, const UString &subDirectory, bool caseInsensitive=false)
Find a directory's subdirectory.