diff --git a/Source/IO/FS/FileStream.NT.cpp b/Source/IO/FS/FileStream.NT.cpp index 30123c67..5353afab 100644 --- a/Source/IO/FS/FileStream.NT.cpp +++ b/Source/IO/FS/FileStream.NT.cpp @@ -397,7 +397,6 @@ namespace Aurora::IO::FS bool bDeleteFailed {}; AuString path; - if ((hHandle != INVALID_HANDLE_VALUE) && (this->bShouldDelete)) { diff --git a/Source/IO/FS/FileStream.Unix.cpp b/Source/IO/FS/FileStream.Unix.cpp index dd61ac27..d95f73e7 100755 --- a/Source/IO/FS/FileStream.Unix.cpp +++ b/Source/IO/FS/FileStream.Unix.cpp @@ -255,18 +255,22 @@ namespace Aurora::IO::FS void PosixFileStream::Close() { + AU_DEBUG_MEMCRUNCH; AU_LOCK_GUARD(this->mutex_); + AuString path; + + if (AuExchange(this->bMadeTemporary, false) && + this->pHandle_) + { + path = this->pHandle_->GetPath(); + } - auto pHandle = this->pHandle_; AuResetMember(this->pHandle_); - if (AuExchange(this->bMadeTemporary, false)) + if (path.size()) { Aurora::RuntimeWaitForSecondaryTick(); - if (pHandle) - { - PosixUnlink(pHandle->GetPath().c_str()); - } + PosixUnlink(path.c_str()); } }