libfilezilla
file.hpp
Go to the documentation of this file.
00001 #ifndef LIBFILEZILLA_FILE_HEADER
00002 #define LIBFILEZILLA_FILE_HEADER
00003 
00004 #include "libfilezilla.hpp"
00005 
00006 #ifdef FZ_WINDOWS
00007 #include "private/windows.hpp"
00008 #endif
00009 
00014 #include <stdint.h>
00015 
00016 namespace fz {
00017 
00025 class FZ_PUBLIC_SYMBOL file final
00026 {
00027 public:
00029     enum mode {
00030         reading,
00031         writing
00032     };
00033 
00040     enum creation_flags {
00042         existing,
00043 
00045         empty
00046     };
00047 
00048     file();
00049     file(native_string const& f, mode m, creation_flags d = existing);
00050 
00051     ~file();
00052 
00053     file(file const&) = delete;
00054     file& operator=(file const&) = delete;
00055 
00056     bool opened() const;
00057 
00058     bool open(native_string const& f, mode m, creation_flags d = existing);
00059 
00060     void close();
00061 
00063     enum seek_mode {
00065         begin,
00066 
00068         current,
00069 
00071         end
00072     };
00073 
00077     int64_t size() const;
00078 
00091     int64_t seek(int64_t offset, seek_mode m);
00092 
00098     bool truncate();
00099 
00113     int64_t read(void *buf, int64_t count);
00114 
00125     int64_t write(void const* buf, int64_t count);
00126 
00127 private:
00128 #ifdef FZ_WINDOWS
00129     HANDLE hFile_{INVALID_HANDLE_VALUE};
00130 #else
00131     int fd_{-1};
00132 #endif
00133 };
00134 
00135 bool FZ_PUBLIC_SYMBOL remove_file(native_string const& name);
00136 
00137 }
00138 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines