mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-15 22:53:47 +00:00
Add fs::file::set_delete
This commit is contained in:
parent
a54d9c527f
commit
0736fc8b28
@ -1229,6 +1229,15 @@ fs::native_handle fs::file::get_handle() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
bool fs::file::set_delete(bool autodelete) const
|
||||||
|
{
|
||||||
|
FILE_DISPOSITION_INFO disp;
|
||||||
|
disp.DeleteFileW = autodelete;
|
||||||
|
return SetFileInformationByHandle(get_handle(), FileDispositionInfo, &disp, sizeof(disp)) != 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void fs::dir::xnull() const
|
void fs::dir::xnull() const
|
||||||
{
|
{
|
||||||
fmt::throw_exception<std::logic_error>("fs::dir is null");
|
fmt::throw_exception<std::logic_error>("fs::dir is null");
|
||||||
|
@ -361,6 +361,11 @@ namespace fs
|
|||||||
|
|
||||||
// Get native handle if available
|
// Get native handle if available
|
||||||
native_handle get_handle() const;
|
native_handle get_handle() const;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows-specific function
|
||||||
|
bool set_delete(bool autodelete = true) const;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class dir final
|
class dir final
|
||||||
|
@ -387,9 +387,7 @@ logs::file_writer::file_writer(const std::string& name)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Autodelete compressed log file
|
// Autodelete compressed log file
|
||||||
FILE_DISPOSITION_INFO disp;
|
m_fout2.set_delete();
|
||||||
disp.DeleteFileW = TRUE;
|
|
||||||
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
@ -469,9 +467,7 @@ logs::file_writer::~file_writer()
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Cancel compressed log file autodeletion
|
// Cancel compressed log file autodeletion
|
||||||
FILE_DISPOSITION_INFO disp;
|
m_fout2.set_delete(false);
|
||||||
disp.DeleteFileW = FALSE;
|
|
||||||
SetFileInformationByHandle(m_fout2.get_handle(), FileDispositionInfo, &disp, sizeof(disp));
|
|
||||||
|
|
||||||
UnmapViewOfFile(m_fptr);
|
UnmapViewOfFile(m_fptr);
|
||||||
CloseHandle(m_fmap);
|
CloseHandle(m_fmap);
|
||||||
|
Loading…
Reference in New Issue
Block a user