mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-06-02 17:13:02 +00:00
Fix runtime issues,
This commit is contained in:
parent
d0e7106cdf
commit
5583e04e0f
|
|
@ -3,9 +3,18 @@
|
|||
|
||||
C_4JProfile ProfileManager;
|
||||
|
||||
static void *s_profileData[4] = {};
|
||||
|
||||
void C_4JProfile::Initialise(DWORD dwTitleID, DWORD dwOfferID, unsigned short usProfileVersion,
|
||||
UINT uiProfileValuesC, UINT uiProfileSettingsC, DWORD *pdwProfileSettingsA,
|
||||
int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask) {}
|
||||
int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
s_profileData[i] = new unsigned char[iGameDefinedDataSizeX4 / 4];
|
||||
memset(s_profileData[i], 0, iGameDefinedDataSizeX4 / 4);
|
||||
}
|
||||
}
|
||||
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable, int iAccept, int iReject) {}
|
||||
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle, int iText) {}
|
||||
int C_4JProfile::GetLockedProfile() { return -1; }
|
||||
|
|
@ -58,7 +67,7 @@ static C_4JProfile::PROFILESETTINGS s_defaultSettings = {};
|
|||
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(int iPad) { return &s_defaultSettings; }
|
||||
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, bool bOverride5MinuteLimitOnProfileWrites) {}
|
||||
void C_4JProfile::ForceQueuedProfileWrites(int iPad) {}
|
||||
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return nullptr; }
|
||||
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return s_profileData[iQuadrant]; }
|
||||
void C_4JProfile::ResetProfileProcessState() {}
|
||||
void C_4JProfile::Tick(void) {}
|
||||
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected,
|
||||
|
|
|
|||
|
|
@ -57,8 +57,106 @@ void C4JRender::TextureDataUpdate(int xoffset, int yoffset, int width, int heigh
|
|||
void C4JRender::TextureSetParam(int param, int value) {}
|
||||
void C4JRender::TextureDynamicUpdateStart() {}
|
||||
void C4JRender::TextureDynamicUpdateEnd() {}
|
||||
// really don't know if this is nessesary but didn't find any other functions to load images properly as a png..
|
||||
// im sorry.
|
||||
#ifdef __linux__
|
||||
#include <png.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static HRESULT LoadPNGFromRows(png_structp png, png_infop info, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
|
||||
{
|
||||
int width = png_get_image_width(png, info);
|
||||
int height = png_get_image_height(png, info);
|
||||
png_byte color_type = png_get_color_type(png, info);
|
||||
png_byte bit_depth = png_get_bit_depth(png, info);
|
||||
|
||||
if (bit_depth == 16) png_set_strip_16(png);
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png);
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png);
|
||||
if (png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png);
|
||||
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb(png);
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
unsigned char *buf = new unsigned char[width * height * 4];
|
||||
png_bytep *rows = new png_bytep[height];
|
||||
for (int y = 0; y < height; y++)
|
||||
rows[y] = buf + y * width * 4;
|
||||
png_read_image(png, rows);
|
||||
delete[] rows;
|
||||
// considering i worked on previous projects with raw pngs,,,,,
|
||||
int *pixels = new int[width * height];
|
||||
for (int i = 0; i < width * height; i++)
|
||||
{
|
||||
unsigned char r = buf[i * 4 + 0];
|
||||
unsigned char g = buf[i * 4 + 1];
|
||||
unsigned char b = buf[i * 4 + 2];
|
||||
unsigned char a = buf[i * 4 + 3];
|
||||
pixels[i] = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
delete[] buf;
|
||||
|
||||
pSrcInfo->Width = width;
|
||||
pSrcInfo->Height = height;
|
||||
*ppDataOut = pixels;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
|
||||
{
|
||||
FILE *fp = fopen(szFilename, "rb");
|
||||
if (!fp) return E_FAIL;
|
||||
|
||||
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png) { fclose(fp); return E_FAIL; }
|
||||
png_infop info = png_create_info_struct(png);
|
||||
if (!info) { png_destroy_read_struct(&png, NULL, NULL); fclose(fp); return E_FAIL; }
|
||||
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); fclose(fp); return E_FAIL; }
|
||||
|
||||
png_init_io(png, fp);
|
||||
png_read_info(png, info);
|
||||
|
||||
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
fclose(fp);
|
||||
return hr;
|
||||
}
|
||||
|
||||
struct PNGMemReader { const unsigned char *data; png_size_t pos; png_size_t size; };
|
||||
|
||||
static void png_mem_read(png_structp png, png_bytep out, png_size_t len)
|
||||
{
|
||||
PNGMemReader *r = (PNGMemReader *)png_get_io_ptr(png);
|
||||
if (r->pos + len > r->size) len = r->size - r->pos;
|
||||
memcpy(out, r->data + r->pos, len);
|
||||
r->pos += len;
|
||||
}
|
||||
|
||||
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
|
||||
{
|
||||
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png) return E_FAIL;
|
||||
png_infop info = png_create_info_struct(png);
|
||||
if (!info) { png_destroy_read_struct(&png, NULL, NULL); return E_FAIL; }
|
||||
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); return E_FAIL; }
|
||||
|
||||
PNGMemReader reader = { pbData, 0, dwBytes };
|
||||
png_set_read_fn(png, &reader, png_mem_read);
|
||||
png_read_info(png, info);
|
||||
|
||||
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
return hr;
|
||||
}
|
||||
|
||||
#else
|
||||
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
|
||||
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
|
||||
#endif
|
||||
HRESULT C4JRender::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) { return S_OK; }
|
||||
HRESULT C4JRender::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn) { return S_OK; }
|
||||
void C4JRender::TextureGetStats() {}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ target_include_directories(${PROJECT_NAME}
|
|||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
# giving a boost on the next macos implmentation
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_package(PNG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE PNG::PNG)
|
||||
endif()
|
||||
|
||||
# Mimic cmake converter behaviour
|
||||
target_precompile_headers(${PROJECT_NAME} PRIVATE
|
||||
|
|
|
|||
|
|
@ -7,6 +7,25 @@
|
|||
#include "../../../Minecraft.h"
|
||||
#include "../../../Textures/Packs/TexturePackRepository.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <stdint.h>
|
||||
static const size_t DLC_WCHAR_BINARY = 2;
|
||||
static wstring dlc_read_wstring(const void *data)
|
||||
{
|
||||
const uint16_t *p = (const uint16_t *)data;
|
||||
wstring s;
|
||||
while (*p) s += (wchar_t)*p++;
|
||||
return s;
|
||||
}
|
||||
#define DLC_WSTRING(ptr) dlc_read_wstring(ptr)
|
||||
#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BINARY)
|
||||
#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BINARY)
|
||||
#else
|
||||
#define DLC_WSTRING(ptr) wstring((WCHAR *)(ptr))
|
||||
#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + sizeof(WCHAR) * (n))
|
||||
#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + sizeof(WCHAR) * (n))
|
||||
#endif
|
||||
|
||||
const WCHAR *DLCManager::wchTypeNamesA[]=
|
||||
{
|
||||
L"DISPLAYNAME",
|
||||
|
|
@ -282,6 +301,7 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/)
|
|||
}
|
||||
}
|
||||
|
||||
// gotta fix this someday
|
||||
if(corruptDLCCount > 0 && showMessage)
|
||||
{
|
||||
UINT uiIDA[1];
|
||||
|
|
@ -398,13 +418,13 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
for(unsigned int i=0;i<uiParameterCount;i++)
|
||||
{
|
||||
// Map DLC strings to application strings, then store the DLC index mapping to application index
|
||||
wstring parameterName((WCHAR *)pParams->wchData);
|
||||
wstring parameterName = DLC_WSTRING(pParams->wchData);
|
||||
DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName);
|
||||
if( type != DLCManager::e_DLCParamType_Invalid )
|
||||
{
|
||||
parameterMapping[pParams->dwType] = type;
|
||||
}
|
||||
uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR));
|
||||
uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount);
|
||||
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
|
||||
}
|
||||
//ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
|
||||
|
|
@ -416,7 +436,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
DWORD dwTemp=uiCurrentByte;
|
||||
for(unsigned int i=0;i<uiFileCount;i++)
|
||||
{
|
||||
dwTemp+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
|
||||
dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount);
|
||||
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
|
||||
}
|
||||
PBYTE pbTemp=((PBYTE )pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
|
||||
|
|
@ -435,7 +455,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
}
|
||||
else if(type != e_DLCType_PackConfig)
|
||||
{
|
||||
dlcFile = pack->addFile(type,(WCHAR *)pFile->wchFile);
|
||||
dlcFile = pack->addFile(type, DLC_WSTRING(pFile->wchFile));
|
||||
}
|
||||
|
||||
// Params
|
||||
|
|
@ -452,15 +472,15 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
{
|
||||
if(type == e_DLCType_PackConfig)
|
||||
{
|
||||
pack->addParameter(it->second,(WCHAR *)pParams->wchData);
|
||||
pack->addParameter(it->second, DLC_WSTRING(pParams->wchData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dlcFile != NULL) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData);
|
||||
else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData);
|
||||
if(dlcFile != NULL) dlcFile->addParameter(it->second, DLC_WSTRING(pParams->wchData));
|
||||
else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, DLC_WSTRING(pParams->wchData));
|
||||
}
|
||||
}
|
||||
pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount);
|
||||
pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount);
|
||||
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
|
||||
}
|
||||
//pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
|
||||
|
|
@ -495,7 +515,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
switch(pFile->dwType)
|
||||
{
|
||||
case DLCManager::e_DLCType_Skin:
|
||||
app.vSkinNames.push_back((WCHAR *)pFile->wchFile);
|
||||
app.vSkinNames.push_back(DLC_WSTRING(pFile->wchFile));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -504,7 +524,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD
|
|||
|
||||
// Move the pointer to the start of the next files data;
|
||||
pbTemp+=pFile->uiFileSize;
|
||||
uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
|
||||
uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount);
|
||||
|
||||
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
|
||||
}
|
||||
|
|
@ -603,13 +623,13 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
|
|||
for(unsigned int i=0;i<uiParameterCount;i++)
|
||||
{
|
||||
// Map DLC strings to application strings, then store the DLC index mapping to application index
|
||||
wstring parameterName((WCHAR *)pParams->wchData);
|
||||
wstring parameterName = DLC_WSTRING(pParams->wchData);
|
||||
DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName);
|
||||
if( type != DLCManager::e_DLCParamType_Invalid )
|
||||
{
|
||||
parameterMapping[pParams->dwType] = type;
|
||||
}
|
||||
uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR));
|
||||
uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount);
|
||||
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
|
||||
}
|
||||
|
||||
|
|
@ -620,7 +640,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
|
|||
DWORD dwTemp=uiCurrentByte;
|
||||
for(unsigned int i=0;i<uiFileCount;i++)
|
||||
{
|
||||
dwTemp+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
|
||||
dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount);
|
||||
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
|
||||
}
|
||||
PBYTE pbTemp=((PBYTE )pFile);
|
||||
|
|
@ -644,7 +664,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
|
|||
{
|
||||
if(it->second==e_DLCParamType_PackId)
|
||||
{
|
||||
wstring wsTemp=(WCHAR *)pParams->wchData;
|
||||
wstring wsTemp = DLC_WSTRING(pParams->wchData);
|
||||
std::wstringstream ss;
|
||||
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
|
||||
ss << std::dec << wsTemp.c_str();
|
||||
|
|
@ -654,14 +674,14 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
|
|||
}
|
||||
}
|
||||
}
|
||||
pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount);
|
||||
pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount);
|
||||
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
|
||||
}
|
||||
|
||||
if(bPackIDSet) break;
|
||||
// Move the pointer to the start of the next files data;
|
||||
pbTemp+=pFile->uiFileSize;
|
||||
uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
|
||||
uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount);
|
||||
|
||||
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ void Texture::_init(const wstring &name, int mode, int width, int height, int de
|
|||
for(unsigned int level = 1; level < m_iMipLevels; ++level)
|
||||
{
|
||||
int ww = width >> level;
|
||||
int hh = height >> height;
|
||||
int hh = height >> level;
|
||||
|
||||
byteArray tempBytes = byteArray(ww * hh * depth * 4);
|
||||
for (int index = 0; index < tempBytes.length; index++)
|
||||
|
|
|
|||
|
|
@ -129,9 +129,7 @@ bool File::mkdir() const
|
|||
#if defined (_UNICODE)
|
||||
return CreateDirectory( getPath().c_str(), NULL) != 0;
|
||||
#elif defined(__linux__)
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
return ::mkdir(path.c_str(), 0777) == 0; // rwxrwxrwx
|
||||
return ::mkdir(wstringtofilename(getPath()), 0777) == 0;
|
||||
#else
|
||||
return CreateDirectory( wstringtofilename(getPath()), NULL) != 0;
|
||||
#endif
|
||||
|
|
@ -186,11 +184,10 @@ bool File::mkdirs() const
|
|||
}
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
const char *mkpath = wstringtofilename(getPath());
|
||||
struct stat info;
|
||||
if (stat(path.c_str(), &info) != 0 || !(info.st_mode & S_IFDIR)) {
|
||||
if (::mkdir(path.c_str(), 0777) != 0) {
|
||||
if (stat(mkpath, &info) != 0 || !(info.st_mode & S_IFDIR)) {
|
||||
if (::mkdir(mkpath, 0777) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -229,9 +226,8 @@ bool File::exists() const
|
|||
#if defined(_UNICODE)
|
||||
return GetFileAttributes( getPath().c_str() ) != -1;
|
||||
#elif defined(__linux__)
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
return access(path.c_str(), F_OK) != -1;
|
||||
// BAD DOBBY BAD DOBBY
|
||||
return access(wstringtofilename(getPath()), F_OK) != -1;
|
||||
#else
|
||||
return GetFileAttributes( wstringtofilename(getPath()) ) != -1;
|
||||
#endif
|
||||
|
|
@ -567,9 +563,9 @@ bool File::isDirectory() const
|
|||
#if defined(_UNICODE)
|
||||
return exists() && ( GetFileAttributes( getPath().c_str() ) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
|
||||
#elif defined(__linux__)
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
return access(path.c_str(), F_OK) != -1;
|
||||
const char *dirpath = wstringtofilename(getPath());
|
||||
struct stat st;
|
||||
return stat(dirpath, &st) == 0 && S_ISDIR(st.st_mode);
|
||||
#else
|
||||
return exists() && ( GetFileAttributes( wstringtofilename(getPath()) ) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY;
|
||||
#endif
|
||||
|
|
@ -645,10 +641,9 @@ __int64 File::length()
|
|||
return statData.fileSize;
|
||||
#elif defined(__linux__)
|
||||
struct stat fileInfoBuffer;
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
const char *path = wstringtofilename(getPath());
|
||||
|
||||
int result = stat(path.c_str(), &fileInfoBuffer);
|
||||
int result = stat(path, &fileInfoBuffer);
|
||||
|
||||
if(result == 0) {
|
||||
return fileInfoBuffer.st_size;
|
||||
|
|
@ -726,10 +721,7 @@ __int64 File::lastModified()
|
|||
}
|
||||
#else
|
||||
struct stat fileStat;
|
||||
struct stat fileInfoBuffer;
|
||||
std::wstring wpath = getPath();
|
||||
std::string path(wpath.begin(), wpath.end());
|
||||
if (stat(path.c_str(), &fileStat) == 0 && !S_ISDIR(fileStat.st_mode)) {
|
||||
if (stat(wstringtofilename(getPath()), &fileStat) == 0 && !S_ISDIR(fileStat.st_mode)) {
|
||||
return static_cast<__int64>(fileStat.st_mtime);
|
||||
} else {
|
||||
return 0l;
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
|
|||
HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
|
||||
{
|
||||
// Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__
|
||||
SIZE_T destSize = (SIZE_T)(*pDestSize);
|
||||
int res = ::compress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize);
|
||||
*pDestSize = (unsigned int)destSize;
|
||||
|
|
@ -328,7 +328,7 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi
|
|||
}
|
||||
|
||||
// Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__
|
||||
SIZE_T destSize = (SIZE_T)(*pDestSize);
|
||||
int res = ::uncompress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize);
|
||||
*pDestSize = (unsigned int)destSize;
|
||||
|
|
@ -405,7 +405,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS
|
|||
}
|
||||
break;
|
||||
case eCompressionType_ZLIBRLE:
|
||||
#if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64)
|
||||
#if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64 || defined __linux__)
|
||||
if (pDestination != NULL)
|
||||
return ::uncompress((PBYTE)pDestination, (unsigned long *) pDestSize, (PBYTE) pSource, SrcSize); // Decompress
|
||||
else break; // Cannot decompress when destination is NULL
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ private:
|
|||
|
||||
//extern Compression gCompression;
|
||||
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
|
||||
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__
|
||||
#define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_ZLIBRLE
|
||||
#elif defined __PS3__
|
||||
#define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_PS3ZLIB
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ const char *wstringtofilename(const wstring& name)
|
|||
for(unsigned int i = 0; i < name.length(); i++ )
|
||||
{
|
||||
wchar_t c = name[i];
|
||||
#if defined __PS3__ || defined __ORBIS__
|
||||
#if defined __PS3__ || defined __ORBIS__ || defined __linux__
|
||||
if(c=='\\') c='/';
|
||||
#else
|
||||
if(c=='/') c='\\';
|
||||
|
|
|
|||
Loading…
Reference in a new issue