1 #ifndef LIBFILEZILLA_FILE_HEADER
2 #define LIBFILEZILLA_FILE_HEADER
8 #include "glue/windows.hpp"
28 class FZ_PUBLIC_SYMBOL
file final
32 typedef HANDLE file_t;
63 current_user_only = 0x4,
75 current_user_and_admins_only = 0x8
86 explicit file(file_t fd);
91 file& operator=(
file const&) =
delete;
94 file& operator=(
file && op) noexcept;
97 explicit operator
bool()
const {
return opened(); }
99 result open(
native_string const& f, mode m, creation_flags d = existing);
125 int64_t size()
const;
139 int64_t seek(int64_t offset, seek_mode m);
164 rwresult read2(
void *buf,
size_t count);
167 inline int64_t
read(
void *buf, int64_t count) {
168 rwresult res = read2(buf, static_cast<size_t>(count));
169 return res ? res.
value_ : -1;
182 rwresult write2(
void const* buf,
size_t count);
185 inline int64_t
write(
void const* buf, int64_t count) {
186 rwresult res = write2(buf, static_cast<size_t>(count));
187 return res ? res.value_ : -1;
201 bool set_modification_time(datetime
const& t);
205 HANDLE fd_{INVALID_HANDLE_VALUE};
228 return static_cast<file::creation_flags>(
static_cast<std::underlying_type_t<file::creation_flags>
>(lhs) |
static_cast<std::underlying_type_t<file::creation_flags>
>(rhs));
241 rwresult FZ_PUBLIC_SYMBOL
read_file(
fz::file & f, buffer & out,
size_t max_size);
Data has become available.
fz::result and fz::rwresult wrappers for dealing with file system errors.
result remove_file(native_string const &name, bool missing_file_is_error)
remove the specified file.
mode
Files can be opened for reading, writing, or both.
Definition: file.hpp:38
Holds the result of read/write operations.
Definition: fsresult.hpp:76
Seek from current position in the file.
Definition: file.hpp:116
int64_t position()
Get Current position in file.
Definition: file.hpp:142
std::wstring native_string
A string in the system's native character type and encoding. Note: This typedef changes depending on...
Definition: string.hpp:34
size_t value_
Undefined if error_ is not none.
Definition: fsresult.hpp:121
Seek from beginning of file.
Definition: file.hpp:113
The namespace used by libfilezilla.
Definition: apply.hpp:17
seek_mode
Used by seek.
Definition: file.hpp:111
creation_flags
Creation flags when opening file for writing.
Definition: file.hpp:50
Lean class for file access.
Definition: file.hpp:28
Sets some global macros and further includes string.hpp.
file_t fd()
Returns the raw file descriptor, but retains ownership.
Definition: file.hpp:104
rwresult read_file(fz::file &f, buffer &out, size_t max_size)
Reads the entire source file and appends if to the buffer.