mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8108 from huangshiwu/v3_wp8test
fix wp8 directory control bug
This commit is contained in:
commit
6569f1a7f0
|
@ -1068,6 +1068,8 @@ bool FileUtils::createDirectory(const std::string& path)
|
||||||
for(int i = 0 ; i < dirs.size() ; ++i)
|
for(int i = 0 ; i < dirs.size() ; ++i)
|
||||||
{
|
{
|
||||||
subpath += dirs[i];
|
subpath += dirs[i];
|
||||||
|
if (i > 0 && !isDirectoryExist(subpath))
|
||||||
|
{
|
||||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||||
{
|
{
|
||||||
|
@ -1075,6 +1077,7 @@ bool FileUtils::createDirectory(const std::string& path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
|
@ -1084,6 +1087,8 @@ bool FileUtils::createDirectory(const std::string& path)
|
||||||
for (int i = 0; i < dirs.size(); ++i)
|
for (int i = 0; i < dirs.size(); ++i)
|
||||||
{
|
{
|
||||||
subpath += dirs[i];
|
subpath += dirs[i];
|
||||||
|
if (!isDirectoryExist(subpath))
|
||||||
|
{
|
||||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||||
{
|
{
|
||||||
|
@ -1091,6 +1096,7 @@ bool FileUtils::createDirectory(const std::string& path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1114,16 +1120,44 @@ bool FileUtils::removeDirectory(const std::string& path)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||||
if (RemoveDirectoryA(path.c_str()))
|
std::string Files = path + "*.*";
|
||||||
|
WIN32_FIND_DATA wfd;
|
||||||
|
HANDLE hFind = FindFirstFileEx(Files.c_str(), FindExInfoStandard, &wfd, FindExSearchNameMatch, NULL, 0);
|
||||||
|
bool ret=true;
|
||||||
|
std::string Tmp;
|
||||||
|
if (hFind!=INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
return true;
|
bool find=true;
|
||||||
|
while (find)
|
||||||
|
{
|
||||||
|
//. ..
|
||||||
|
if(wfd.cFileName[0]!='.')
|
||||||
|
{
|
||||||
|
Tmp = path + wfd.cFileName;
|
||||||
|
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
Tmp += '/';
|
||||||
|
ret = ret && this->removeDirectory(Tmp);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFileAttributes(Tmp.c_str(), FILE_ATTRIBUTE_NORMAL);
|
||||||
|
ret = ret && DeleteFile(Tmp.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
find = FindNextFile(find, &wfd);
|
||||||
|
}
|
||||||
|
FindClose(find);
|
||||||
|
}
|
||||||
|
if (ret)
|
||||||
|
return RemoveDirectoryA(path.c_str());
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
std::string command = "rd /s /q ";
|
std::string command = "cmd /c rd /s /q ";
|
||||||
// Path may include space.
|
// Path may include space.
|
||||||
command += "\"" + path + "\"";
|
command += "\"" + path + "\"";
|
||||||
|
|
||||||
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -1151,9 +1185,18 @@ bool FileUtils::removeFile(const std::string &path)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
std::string command = "del /q ";
|
std::string command = "cmd /c del /q ";
|
||||||
// Path may include space.
|
std::string win32path = path;
|
||||||
command += "\"" + path + "\"";
|
int len = win32path.length();
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
if (win32path[i] == '/')
|
||||||
|
{
|
||||||
|
win32path[i] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command += win32path;
|
||||||
|
|
||||||
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -1176,9 +1219,19 @@ bool FileUtils::renameFile(const std::string &path, const std::string &oldname,
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
std::string command = "ren ";
|
std::string command = "cmd /c ren ";
|
||||||
|
std::string win32path = path;
|
||||||
|
int len = win32path.length();
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
if (win32path[i] == '/')
|
||||||
|
{
|
||||||
|
win32path[i] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
// Path may include space.
|
// Path may include space.
|
||||||
command += "\"" + path + oldname + "\" \"" + name + "\"";
|
command += win32path + oldname + " " + name;
|
||||||
|
|
||||||
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue