fs/io/FileReader: use class UniqueFileDescriptor
This commit is contained in:
parent
84df470008
commit
ab7597b089
@ -28,7 +28,7 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include "system/FileDescriptor.hxx"
|
#include "system/UniqueFileDescriptor.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Path;
|
class Path;
|
||||||
@ -40,7 +40,7 @@ class FileReader final : public Reader {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
#else
|
#else
|
||||||
FileDescriptor fd;
|
UniqueFileDescriptor fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -50,18 +50,16 @@ public:
|
|||||||
FileReader(FileReader &&other) noexcept
|
FileReader(FileReader &&other) noexcept
|
||||||
:path(std::move(other.path)),
|
:path(std::move(other.path)),
|
||||||
handle(std::exchange(other.handle, INVALID_HANDLE_VALUE)) {}
|
handle(std::exchange(other.handle, INVALID_HANDLE_VALUE)) {}
|
||||||
#else
|
|
||||||
FileReader(FileReader &&other) noexcept
|
|
||||||
:path(std::move(other.path)),
|
|
||||||
fd(other.fd) {
|
|
||||||
other.fd.SetUndefined();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~FileReader() noexcept {
|
~FileReader() noexcept {
|
||||||
if (IsDefined())
|
if (IsDefined())
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
FileReader(FileReader &&other) noexcept
|
||||||
|
:path(std::move(other.path)),
|
||||||
|
fd(std::move(other.fd)) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user