|
|
|
@@ -24,11 +24,11 @@
|
|
|
|
|
#include <direct.h>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
#include "sdl_private.h"
|
|
|
|
|
#include "window.h"
|
|
|
|
|
#include "noimpl.h"
|
|
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
#include "sdl_private.h"
|
|
|
|
|
#include "window.h"
|
|
|
|
|
#include "noimpl.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <glob.h>
|
|
|
|
|
|
|
|
|
@@ -41,13 +41,13 @@ using namespace std;
|
|
|
|
|
|
|
|
|
|
namespace Shared{ namespace Platform{
|
|
|
|
|
|
|
|
|
|
namespace Private{
|
|
|
|
|
|
|
|
|
|
bool shouldBeFullscreen = false;
|
|
|
|
|
int ScreenWidth;
|
|
|
|
|
int ScreenHeight;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
namespace Private{
|
|
|
|
|
|
|
|
|
|
bool shouldBeFullscreen = false;
|
|
|
|
|
int ScreenWidth;
|
|
|
|
|
int ScreenHeight;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class PerformanceTimer
|
|
|
|
@@ -133,15 +133,15 @@ int64 Chrono::queryCounter(int multiplier) const{
|
|
|
|
|
return multiplier*(accumCount+endCount-startCount)/freq;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64 Chrono::getCurMillis() {
|
|
|
|
|
return getCurTicks() * 1000 / freq;
|
|
|
|
|
}
|
|
|
|
|
int64 Chrono::getCurTicks() {
|
|
|
|
|
int64 now;
|
|
|
|
|
QueryPerformanceCounter((LARGE_INTEGER*) &now);
|
|
|
|
|
return now;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int64 Chrono::getCurMillis() {
|
|
|
|
|
return getCurTicks() * 1000 / freq;
|
|
|
|
|
}
|
|
|
|
|
int64 Chrono::getCurTicks() {
|
|
|
|
|
int64 now;
|
|
|
|
|
QueryPerformanceCounter((LARGE_INTEGER*) &now);
|
|
|
|
|
return now;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class PlatformExceptionHandler
|
|
|
|
@@ -314,8 +314,9 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
|
|
|
|
bool isdir(const char *path)
|
|
|
|
|
{
|
|
|
|
|
struct stat stats;
|
|
|
|
|
|
|
|
|
|
bool ret = stat (path, &stats) == 0 && S_ISDIR(stats.st_mode);
|
|
|
|
|
if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
|
|
|
|
//if(ret == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] NOT a path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
@@ -331,208 +332,237 @@ bool EndsWith(const string &str, const string& key)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//finds all filenames like path and gets their checksum of all files combined
|
|
|
|
|
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
|
|
|
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
|
|
|
|
size_t count = paths.size();
|
|
|
|
|
for(unsigned int idx = 0; idx < count; ++idx) {
|
|
|
|
|
string path = paths[idx] + pathSearchString;
|
|
|
|
|
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
|
|
|
|
//finds all filenames like path and gets their checksum of all files combined
|
|
|
|
|
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
|
|
|
|
int count = paths.size();
|
|
|
|
|
for(int idx = 0; idx < count; ++idx) {
|
|
|
|
|
string path = paths[idx] + pathSearchString;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
|
|
|
|
|
|
|
|
|
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
|
|
|
|
|
|
|
|
|
if(recursiveChecksum != NULL) {
|
|
|
|
|
*recursiveChecksum = checksum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksum.getSum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksum.getFinalFileListSum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//finds all filenames like path and gets their checksum of all files combined
|
|
|
|
|
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
|
|
|
|
|
|
|
|
|
std::string mypath = path;
|
|
|
|
|
/** Stupid win32 is searching for all files without extension when *. is
|
|
|
|
|
* specified as wildcard
|
|
|
|
|
*/
|
|
|
|
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
|
|
|
|
mypath = mypath.substr(0, mypath.size() - 2);
|
|
|
|
|
mypath += "*";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
|
|
|
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
if(isdir(p) == false)
|
|
|
|
|
{
|
|
|
|
|
bool addFile = true;
|
|
|
|
|
if(filterFileExt != "")
|
|
|
|
|
{
|
|
|
|
|
addFile = EndsWith(p, filterFileExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addFile)
|
|
|
|
|
{
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
checksum.addFile(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
// Look recursively for sub-folders
|
|
|
|
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
|
|
|
|
|
|
|
|
|
if(recursiveChecksum != NULL) {
|
|
|
|
|
*recursiveChecksum = checksum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return checksum.getSum();
|
|
|
|
|
string cacheKey = path + "_" + filterFileExt;
|
|
|
|
|
static std::map<string,int32> crcTreeCache;
|
|
|
|
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
|
|
|
|
return crcTreeCache[cacheKey];
|
|
|
|
|
}
|
|
|
|
|
Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum);
|
|
|
|
|
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
|
|
|
|
|
|
|
|
|
std::string mypath = path;
|
|
|
|
|
/** Stupid win32 is searching for all files without extension when *. is
|
|
|
|
|
* specified as wildcard
|
|
|
|
|
*/
|
|
|
|
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
|
|
|
|
mypath = mypath.substr(0, mypath.size() - 2);
|
|
|
|
|
mypath += "*";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
|
|
|
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
if(isdir(p) == false)
|
|
|
|
|
{
|
|
|
|
|
bool addFile = true;
|
|
|
|
|
if(filterFileExt != "")
|
|
|
|
|
{
|
|
|
|
|
addFile = EndsWith(p, filterFileExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addFile)
|
|
|
|
|
{
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
checksum.addFile(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
// Look recursively for sub-folders
|
|
|
|
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum());
|
|
|
|
|
|
|
|
|
|
if(recursiveChecksum != NULL) {
|
|
|
|
|
*recursiveChecksum = checksum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey]);
|
|
|
|
|
|
|
|
|
|
return crcTreeCache[cacheKey];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
|
|
|
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
|
|
|
|
size_t count = paths.size();
|
|
|
|
|
for(unsigned int idx = 0; idx < count; ++idx) {
|
|
|
|
|
string path = paths[idx] + pathSearchString;
|
|
|
|
|
getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles);
|
|
|
|
|
}
|
|
|
|
|
return checksumFiles;
|
|
|
|
|
}
|
|
|
|
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
|
|
|
|
int count = paths.size();
|
|
|
|
|
for(int idx = 0; idx < count; ++idx) {
|
|
|
|
|
string path = paths[idx] + pathSearchString;
|
|
|
|
|
getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
return checksumFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//finds all filenames like path and gets the checksum of each file
|
|
|
|
|
vector<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
|
|
|
|
|
|
|
|
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
|
|
|
|
|
|
|
|
|
std::string mypath = path;
|
|
|
|
|
/** Stupid win32 is searching for all files without extension when *. is
|
|
|
|
|
* specified as wildcard
|
|
|
|
|
*/
|
|
|
|
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
|
|
|
|
mypath = mypath.substr(0, mypath.size() - 2);
|
|
|
|
|
mypath += "*";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
|
|
|
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if(isdir(p) == false)
|
|
|
|
|
{
|
|
|
|
|
bool addFile = true;
|
|
|
|
|
if(filterFileExt != "")
|
|
|
|
|
{
|
|
|
|
|
addFile = EndsWith(p, filterFileExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addFile)
|
|
|
|
|
{
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
Checksum checksum;
|
|
|
|
|
checksum.addFile(p);
|
|
|
|
|
|
|
|
|
|
checksumFiles.push_back(std::pair<string,int32>(p,checksum.getSum()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
// Look recursively for sub-folders
|
|
|
|
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
|
|
|
|
|
|
|
|
|
return checksumFiles;
|
|
|
|
|
string cacheKey = path + "_" + filterFileExt;
|
|
|
|
|
static std::map<string,vector<std::pair<string,int32> > > crcTreeCache;
|
|
|
|
|
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
|
|
|
|
return crcTreeCache[cacheKey];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *recursiveMap);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
|
|
|
|
|
|
|
|
|
std::string mypath = path;
|
|
|
|
|
/** Stupid win32 is searching for all files without extension when *. is
|
|
|
|
|
* specified as wildcard
|
|
|
|
|
*/
|
|
|
|
|
if(mypath.compare(mypath.size() - 2, 2, "*.") == 0) {
|
|
|
|
|
mypath = mypath.substr(0, mypath.size() - 2);
|
|
|
|
|
mypath += "*";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
glob_t globbuf;
|
|
|
|
|
|
|
|
|
|
int res = glob(mypath.c_str(), 0, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if(isdir(p) == false)
|
|
|
|
|
{
|
|
|
|
|
bool addFile = true;
|
|
|
|
|
if(filterFileExt != "")
|
|
|
|
|
{
|
|
|
|
|
addFile = EndsWith(p, filterFileExt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(addFile)
|
|
|
|
|
{
|
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p);
|
|
|
|
|
|
|
|
|
|
Checksum checksum;
|
|
|
|
|
checksum.addFile(p);
|
|
|
|
|
|
|
|
|
|
checksumFiles.push_back(std::pair<string,int32>(p,checksum.getSum()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
// Look recursively for sub-folders
|
|
|
|
|
res = glob(mypath.c_str(), GLOB_ONLYDIR, 0, &globbuf);
|
|
|
|
|
if(res < 0) {
|
|
|
|
|
std::stringstream msg;
|
|
|
|
|
msg << "Couldn't scan directory '" << mypath << "': " << strerror(errno);
|
|
|
|
|
throw runtime_error(msg.str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < globbuf.gl_pathc; ++i) {
|
|
|
|
|
const char* p = globbuf.gl_pathv[i];
|
|
|
|
|
/*
|
|
|
|
|
const char* begin = p;
|
|
|
|
|
for( ; *p != 0; ++p) {
|
|
|
|
|
// strip the path component
|
|
|
|
|
if(*p == '/')
|
|
|
|
|
begin = p+1;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
globfree(&globbuf);
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
|
|
|
|
|
|
|
|
|
crcTreeCache[cacheKey] = checksumFiles;
|
|
|
|
|
|
|
|
|
|
return crcTreeCache[cacheKey];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string extractDirectoryPathFromFile(string filename)
|
|
|
|
@@ -642,64 +672,64 @@ void createDirectoryPaths(string Path)
|
|
|
|
|
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
|
|
|
|
|
// Get the current video hardware information
|
|
|
|
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
//screenWidth = vidInfo->current_w;
|
|
|
|
|
//screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
/* Get available fullscreen/hardware modes */
|
|
|
|
|
SDL_Rect**modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
|
|
|
|
|
|
|
|
|
|
/* Check if there are any modes available */
|
|
|
|
|
if (modes == (SDL_Rect**)0) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
screenWidth = vidInfo->current_w;
|
|
|
|
|
screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
/* Check if our resolution is restricted */
|
|
|
|
|
else if (modes == (SDL_Rect**)-1) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
screenWidth = vidInfo->current_w;
|
|
|
|
|
screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
/* Print valid modes */
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
int bestW = -1;
|
|
|
|
|
int bestH = -1;
|
|
|
|
|
for(int i=0; modes[i]; ++i) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
|
|
|
|
|
|
|
|
|
if(bestW < modes[i]->w) {
|
|
|
|
|
bestW = modes[i]->w;
|
|
|
|
|
bestH = modes[i]->h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bestW > screenWidth) {
|
|
|
|
|
screenWidth = bestW;
|
|
|
|
|
screenHeight = bestH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
|
|
|
|
|
// Get the current video hardware information
|
|
|
|
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
//screenWidth = vidInfo->current_w;
|
|
|
|
|
//screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
/* Get available fullscreen/hardware modes */
|
|
|
|
|
SDL_Rect**modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
|
|
|
|
|
|
|
|
|
|
/* Check if there are any modes available */
|
|
|
|
|
if (modes == (SDL_Rect**)0) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
screenWidth = vidInfo->current_w;
|
|
|
|
|
screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
/* Check if our resolution is restricted */
|
|
|
|
|
else if (modes == (SDL_Rect**)-1) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
|
colorBits = vidInfo->vfmt->BitsPerPixel;
|
|
|
|
|
screenWidth = vidInfo->current_w;
|
|
|
|
|
screenHeight = vidInfo->current_h;
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
/* Print valid modes */
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
|
|
|
int bestW = -1;
|
|
|
|
|
int bestH = -1;
|
|
|
|
|
for(int i=0; modes[i]; ++i) {
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
|
|
|
|
|
|
|
|
|
if(bestW < modes[i]->w) {
|
|
|
|
|
bestW = modes[i]->w;
|
|
|
|
|
bestH = modes[i]->h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bestW > screenWidth) {
|
|
|
|
|
screenWidth = bestW;
|
|
|
|
|
screenHeight = bestH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
|
|
|
|
// Get the current video hardware information
|
|
|
|
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
|
|
@@ -785,15 +815,15 @@ void getFullscreenVideoModes(list<ModeInfo> *modeinfos) {
|
|
|
|
|
}
|
|
|
|
|
} while(++loops != 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool changeVideoMode(int resW, int resH, int colorBits, int ) {
|
|
|
|
|
Private::shouldBeFullscreen = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void restoreVideoMode(bool exitingApp) {
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool changeVideoMode(int resW, int resH, int colorBits, int ) {
|
|
|
|
|
Private::shouldBeFullscreen = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void restoreVideoMode(bool exitingApp) {
|
|
|
|
|
SDL_Quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void message(string message){
|
|
|
|
@@ -825,13 +855,13 @@ void exceptionMessage(const exception &excp){
|
|
|
|
|
// return GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
int getScreenW() {
|
|
|
|
|
return SDL_GetVideoSurface()->w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getScreenH() {
|
|
|
|
|
return SDL_GetVideoSurface()->h;
|
|
|
|
|
}
|
|
|
|
|
int getScreenW() {
|
|
|
|
|
return SDL_GetVideoSurface()->w;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getScreenH() {
|
|
|
|
|
return SDL_GetVideoSurface()->h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sleep(int millis){
|
|
|
|
@@ -845,49 +875,49 @@ void showCursor(bool b){
|
|
|
|
|
bool isKeyDown(int virtualKey){
|
|
|
|
|
//return (GetKeyState(virtualKey) & 0x8000) != 0;
|
|
|
|
|
|
|
|
|
|
char key = static_cast<char> (virtualKey);
|
|
|
|
|
const Uint8* keystate = SDL_GetKeyState(0);
|
|
|
|
|
|
|
|
|
|
// kinda hack and wrong...
|
|
|
|
|
if(key >= 0) {
|
|
|
|
|
return keystate[key];
|
|
|
|
|
}
|
|
|
|
|
switch(key) {
|
|
|
|
|
case vkAdd:
|
|
|
|
|
return keystate[SDLK_PLUS] | keystate[SDLK_KP_PLUS];
|
|
|
|
|
case vkSubtract:
|
|
|
|
|
return keystate[SDLK_MINUS] | keystate[SDLK_KP_MINUS];
|
|
|
|
|
case vkAlt:
|
|
|
|
|
return keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
|
|
|
|
case vkControl:
|
|
|
|
|
return keystate[SDLK_LCTRL] | keystate[SDLK_RCTRL];
|
|
|
|
|
case vkShift:
|
|
|
|
|
return keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT];
|
|
|
|
|
case vkEscape:
|
|
|
|
|
return keystate[SDLK_ESCAPE];
|
|
|
|
|
case vkUp:
|
|
|
|
|
return keystate[SDLK_UP];
|
|
|
|
|
case vkLeft:
|
|
|
|
|
return keystate[SDLK_LEFT];
|
|
|
|
|
case vkRight:
|
|
|
|
|
return keystate[SDLK_RIGHT];
|
|
|
|
|
case vkDown:
|
|
|
|
|
return keystate[SDLK_DOWN];
|
|
|
|
|
case vkReturn:
|
|
|
|
|
return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER];
|
|
|
|
|
case vkBack:
|
|
|
|
|
return keystate[SDLK_BACKSPACE];
|
|
|
|
|
default:
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"isKeyDown called with unknown key.\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
char key = static_cast<char> (virtualKey);
|
|
|
|
|
const Uint8* keystate = SDL_GetKeyState(0);
|
|
|
|
|
|
|
|
|
|
// kinda hack and wrong...
|
|
|
|
|
if(key >= 0) {
|
|
|
|
|
return keystate[key];
|
|
|
|
|
}
|
|
|
|
|
switch(key) {
|
|
|
|
|
case vkAdd:
|
|
|
|
|
return keystate[SDLK_PLUS] | keystate[SDLK_KP_PLUS];
|
|
|
|
|
case vkSubtract:
|
|
|
|
|
return keystate[SDLK_MINUS] | keystate[SDLK_KP_MINUS];
|
|
|
|
|
case vkAlt:
|
|
|
|
|
return keystate[SDLK_LALT] | keystate[SDLK_RALT];
|
|
|
|
|
case vkControl:
|
|
|
|
|
return keystate[SDLK_LCTRL] | keystate[SDLK_RCTRL];
|
|
|
|
|
case vkShift:
|
|
|
|
|
return keystate[SDLK_LSHIFT] | keystate[SDLK_RSHIFT];
|
|
|
|
|
case vkEscape:
|
|
|
|
|
return keystate[SDLK_ESCAPE];
|
|
|
|
|
case vkUp:
|
|
|
|
|
return keystate[SDLK_UP];
|
|
|
|
|
case vkLeft:
|
|
|
|
|
return keystate[SDLK_LEFT];
|
|
|
|
|
case vkRight:
|
|
|
|
|
return keystate[SDLK_RIGHT];
|
|
|
|
|
case vkDown:
|
|
|
|
|
return keystate[SDLK_DOWN];
|
|
|
|
|
case vkReturn:
|
|
|
|
|
return keystate[SDLK_RETURN] | keystate[SDLK_KP_ENTER];
|
|
|
|
|
case vkBack:
|
|
|
|
|
return keystate[SDLK_BACKSPACE];
|
|
|
|
|
default:
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"isKeyDown called with unknown key.\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =====================================
|
|
|
|
|
// ModeInfo
|
|
|
|
|
// =====================================
|
|
|
|
|
|
|
|
|
|
// =====================================
|
|
|
|
|
// ModeInfo
|
|
|
|
|
// =====================================
|
|
|
|
|
|
|
|
|
|
ModeInfo::ModeInfo(int w, int h, int d) {
|
|
|
|
|
width=w;
|
|
|
|
|
height=h;
|
|
|
|
|