added winrt and wp8 platforms. Cleaned up platform checks

This commit is contained in:
Dale Stammen 2014-10-14 16:45:43 -07:00
parent 0cfe930078
commit cca5d90cbe
1 changed files with 30 additions and 22 deletions

View File

@ -450,7 +450,17 @@ bool AssetsManager::uncompress()
*/
bool AssetsManager::createDirectory(const char *path)
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#pragma message("warning: AssetsManager::createDirectory() not implemented for CC_PLATFORM_WINRT//WP8 " __FILE__ " : " __FUNCTION__)
return false;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
BOOL ret = CreateDirectoryA(path, nullptr);
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
{
return false;
}
return true;
#else
mode_t processMask = umask(0);
int ret = mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO);
umask(processMask);
@ -458,16 +468,11 @@ bool AssetsManager::createDirectory(const char *path)
{
return false;
}
return true;
#else
BOOL ret = CreateDirectoryA(path, nullptr);
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
{
return false;
}
return true;
#endif
}
void AssetsManager::setSearchPath()
@ -638,19 +643,20 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version
void AssetsManager::createStoragePath()
{
// Remove downloaded files
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#pragma message("warning: AssetsManager::createStoragePath() not implemented for CC_PLATFORM_WINRT/WP8 " __FILE__ " : " __FUNCTION__)
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES)
{
CreateDirectoryA(_storagePath.c_str(), 0);
}
#else
DIR *dir = nullptr;
dir = opendir (_storagePath.c_str());
if (!dir)
{
mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
}
#else
if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES)
{
CreateDirectoryA(_storagePath.c_str(), 0);
}
#endif
}
@ -660,16 +666,18 @@ void AssetsManager::destroyStoragePath()
deleteVersion();
// Remove downloaded files
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
string command = "rm -r ";
// Path may include space.
command += "\"" + _storagePath + "\"";
system(command.c_str());
#else
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#pragma message("warning: AssetsManager::destroyStoragePath() not implemented for CC_PLATFORM_WINRT/WP8 " __FILE__ " : " __FUNCTION__)
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
string command = "rd /s /q ";
// Path may include space.
command += "\"" + _storagePath + "\"";
system(command.c_str());
#else
string command = "rm -r ";
// Path may include space.
command += "\"" + _storagePath + "\"";
system(command.c_str());
#endif
}