mirror of https://github.com/axmolengine/axmol.git
fix wp8 directory control bug
This commit is contained in:
parent
afd1271078
commit
d42cec0708
|
@ -1068,10 +1068,13 @@ bool FileUtils::createDirectory(const std::string& path)
|
|||
for(int i = 0 ; i < dirs.size() ; ++i)
|
||||
{
|
||||
subpath += dirs[i];
|
||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||
if (i > 0 && !isDirectoryExist(subpath))
|
||||
{
|
||||
return false;
|
||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1081,14 +1084,17 @@ bool FileUtils::createDirectory(const std::string& path)
|
|||
if ((GetFileAttributesA(path.c_str())) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
subpath = "";
|
||||
for(int i = 0 ; i < dirs.size() ; ++i)
|
||||
for (int i = 0; i < dirs.size(); ++i)
|
||||
{
|
||||
subpath += dirs[i];
|
||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isDirectoryExist(subpath))
|
||||
{
|
||||
BOOL ret = CreateDirectoryA(subpath.c_str(), NULL);
|
||||
if (!ret && ERROR_ALREADY_EXISTS != GetLastError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1114,20 +1120,48 @@ bool FileUtils::removeDirectory(const std::string& path)
|
|||
return false;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
if (RemoveDirectoryA(path.c_str()))
|
||||
{
|
||||
return true;
|
||||
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)
|
||||
{
|
||||
bool bFind=true;
|
||||
while (bFind)
|
||||
{
|
||||
//. ..
|
||||
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());
|
||||
}
|
||||
}
|
||||
bFind = FindNextFile(hFind, &wfd);
|
||||
}
|
||||
FindClose(hFind);
|
||||
}
|
||||
if (Ret)
|
||||
return RemoveDirectoryA(path.c_str());
|
||||
return false;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
std::string command = "rd /s /q ";
|
||||
// Path may include space.
|
||||
command += "\"" + path + "\"";
|
||||
std::string command = "cmd /c rd /s /q ";
|
||||
// Path may include space.
|
||||
command += "\"" + path + "\"";
|
||||
|
||||
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1151,13 +1185,22 @@ bool FileUtils::removeFile(const std::string &path)
|
|||
return false;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
std::string command = "del /q ";
|
||||
// Path may include space.
|
||||
command += "\"" + path + "\"";
|
||||
std::string command = "cmd /c del /q ";
|
||||
std::string win32path = 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)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1176,13 +1219,23 @@ bool FileUtils::renameFile(const std::string &path, const std::string &oldname,
|
|||
}
|
||||
return true;
|
||||
#else
|
||||
std::string command = "ren ";
|
||||
// Path may include space.
|
||||
command += "\"" + path + oldname + "\" \"" + name + "\"";
|
||||
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.
|
||||
command += win32path + oldname + " " + name;
|
||||
|
||||
if (WinExec(command.c_str(), SW_HIDE) > 31)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue