-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close file descriptors of created files #75
Conversation
Actually it would be better to store the descriptor for the created file and close it explicitly when deleting it
std::pair<fs::path, file::native_handle_type> create_file(std::string_view prefix, std::string_view suffix)
file::file(std::pair<fs::path, file::native_handle_type> handle, bool binary)
: tmp::path(std::move(handle.first)),
binary(binary),
handle(handle.second) {}
file::file(std::string_view prefix, std::string_view suffix, bool binary)
: file(create_file(prefix, suffix), binary) {} And #ifdef WIN32
CloseHandle(handle);
#else
close(handle);
#endif |
And since /// Returns the underlying implementation-defined handle
[[nodiscard]] native_handle_type file::native_handle() const noexcept; |
Added native handle management |
# Conflicts: # src/tmp.cpp
@@ -174,6 +172,18 @@ void remove(const fs::path& path) noexcept { | |||
} | |||
} | |||
|
|||
/// Closes the given file, ignoring any errors | |||
/// @param file The file to close |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// @param file The file to close | |
/// @param file The file to close |
native_handle_type
to temporary filesfile::native_handle
method