[+] AuTryInsert for maps
[*] Fix Aurora::IO::FS Remove not removing empty directories
This commit is contained in:
parent
d67d6b38db
commit
3f4cf93877
@ -285,6 +285,30 @@ static auline bool AuTryRemoveByTupleN(List &list, const Key &key)
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <auROXTL/auTupleUtils.hpp>
|
||||
|
||||
template<typename Container, typename Key_t, typename Type_t>
|
||||
static auline bool AuTryInsert(Container &container, const Key_t &key, Type_t &&value)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto itr = container.find(key);
|
||||
if (itr == container.end())
|
||||
{
|
||||
container.insert(AuMakePair(key, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
itr->second = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Container, typename Type>
|
||||
static auline bool AuTryInsert(Container &container, const Type &value)
|
||||
{
|
||||
|
@ -211,7 +211,11 @@ namespace Aurora::IO::FS
|
||||
{
|
||||
try
|
||||
{
|
||||
return DeleteFileW(Locale::ConvertFromUTF8(NormalizePathRet(path)).c_str());
|
||||
auto translatedPath = Locale::ConvertFromUTF8(NormalizePathRet(path));
|
||||
if (!DeleteFileW(translatedPath.c_str()))
|
||||
{
|
||||
return RemoveDirectoryW(translatedPath.c_str());
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -52,9 +52,9 @@ namespace Aurora::Threading::Threads
|
||||
{
|
||||
AU_LOCK_GUARD(gMutex);
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
AuTryInsert(gUnixHandlesToThreads, AuMakePair(id.unixThreadId, handle));
|
||||
AuTryInsert(gUnixHandlesToThreads, id.unixThreadId, handle);
|
||||
#endif
|
||||
AuTryInsert(gNativeHandlesToThreads, AuMakePair(id.threadId, handle));
|
||||
AuTryInsert(gNativeHandlesToThreads, id.threadId, handle);
|
||||
}
|
||||
|
||||
static void ReleaseThisThread(BasicThreadId id)
|
||||
|
Loading…
Reference in New Issue
Block a user