From 2eeab1feb00defc95ff8152a3a35e0c3b88e587d Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Tue, 1 Jul 2014 19:34:25 +0400 Subject: [PATCH] Compilation fix --- Utilities/GNU.h | 8 ++++++++ rpcs3/Emu/SysCalls/Modules/cellGame.cpp | 24 ++++++++++++------------ rpcs3/Emu/SysCalls/Modules/cellGame.h | 6 +++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Utilities/GNU.h b/Utilities/GNU.h index a3a2ba48e5..a79dfbf3d0 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -6,6 +6,14 @@ #define thread_local __thread #endif +template +void strcpy_trunc(char (&dst)[size], const std::string& src) +{ + const size_t count = (src.size() >= size) ? size - 1 /* truncation */ : src.size(); + memcpy(dst, src.c_str(), count); + dst[count] = 0; +} + #if defined(__GNUG__) #include #include diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 43aec8a1f0..d247780327 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -24,7 +24,7 @@ int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_tWarning("cellGameBootCheck(type_addr=0x%x, attributes_addr=0x%x, size_addr=0x%x, dirName_addr=0x%x)", type.GetAddr(), attributes.GetAddr(), size.GetAddr(), dirName.GetAddr()); - if (!type.IsGood() || !attributes.IsGood() || !size.IsGood() || !dirName.IsGood()) + if (!type.IsGood() || !attributes.IsGood() || !size.IsGood() || (dirName.GetAddr() && !dirName.IsGood())) { cellGame->Error("cellGameBootCheck(): CELL_GAME_ERROR_PARAM"); return CELL_GAME_ERROR_PARAM; @@ -56,7 +56,7 @@ int cellGameBootCheck(mem32_t type, mem32_t attributes, mem_ptr_t dirName, u32 cbGet->hddFreeSizeKB = 40000000; //40 GB cbGet->isNewData = CELL_GAMEDATA_ISNEWDATA_NO; - strncpy_s(cbGet->contentInfoPath, dir.c_str(), _TRUNCATE); - strncpy_s(cbGet->gameDataPath, (dir + "/USRDIR").c_str(), _TRUNCATE); + strcpy_trunc(cbGet->contentInfoPath, dir); + strcpy_trunc(cbGet->gameDataPath, dir + "/USRDIR"); // TODO: set correct time - cbGet->st_atime = 0; - cbGet->st_ctime = 0; - cbGet->st_mtime = 0; + cbGet->st_atime_ = 0; + cbGet->st_ctime_ = 0; + cbGet->st_mtime_ = 0; // TODO: calculate data size, if necessary cbGet->sizeKB = CELL_GAMEDATA_SIZEKB_NOTCALC; @@ -266,9 +266,9 @@ int cellGameDataCheckCreate2(u32 version, const mem_list_ptr_t dirName, u32 cbGet->getParam.attribute = CELL_GAMEDATA_ATTR_NORMAL; cbGet->getParam.parentalLevel = psf.GetInteger("PARENTAL_LEVEL"); - strncpy_s(cbGet->getParam.dataVersion, psf.GetString("APP_VER").c_str(), _TRUNCATE); - strncpy_s(cbGet->getParam.titleId, psf.GetString("TITLE_ID").c_str(), _TRUNCATE); - strncpy_s(cbGet->getParam.title, psf.GetString("TITLE").c_str(), _TRUNCATE); + strcpy_trunc(cbGet->getParam.dataVersion, psf.GetString("APP_VER")); + strcpy_trunc(cbGet->getParam.titleId, psf.GetString("TITLE_ID")); + strcpy_trunc(cbGet->getParam.title, psf.GetString("TITLE")); // TODO: write lang titles funcStat(cbResult.GetAddr(), cbGet.GetAddr(), cbSet.GetAddr()); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.h b/rpcs3/Emu/SysCalls/Modules/cellGame.h index 06d214215a..12a0165eba 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.h @@ -186,9 +186,9 @@ struct CellGameDataStatGet char contentInfoPath[CELL_GAMEDATA_PATH_MAX]; char gameDataPath[CELL_GAMEDATA_PATH_MAX]; char reserved0[2]; - be_t st_atime; - be_t st_mtime; - be_t st_ctime; + be_t st_atime_; + be_t st_mtime_; + be_t st_ctime_; CellGameDataSystemFileParam getParam; be_t sizeKB; be_t sysSizeKB;