![]() |
libfilezilla
|
00001 #ifndef LIBFILEZILLA_LOCAL_FILESYS_HEADER 00002 #define LIBFILEZILLA_LOCAL_FILESYS_HEADER 00003 00004 #include "libfilezilla.hpp" 00005 #include "time.hpp" 00006 00007 #ifdef FZ_WINDOWS 00008 #include "private/windows.hpp" 00009 #else 00010 #include <dirent.h> 00011 #endif 00012 00016 namespace fz { 00017 00024 class FZ_PUBLIC_SYMBOL local_filesys final 00025 { 00026 public: 00027 local_filesys() = default; 00028 ~local_filesys(); 00029 00030 local_filesys(local_filesys const&) = delete; 00031 local_filesys& operator=(local_filesys const&) = delete; 00032 00034 enum type { 00035 unknown = -1, 00036 file, 00037 dir, 00038 link 00039 }; 00040 00042 static char const path_separator; 00043 00047 static inline bool is_separator(wchar_t c) { 00048 #ifdef FZ_WINDOWS 00049 return c == '/' || c == '\\'; 00050 #else 00051 return c == '/'; 00052 #endif 00053 } 00054 00058 static type get_file_type(native_string const& path, bool follow_links = false); 00059 00062 static type get_file_info(native_string const& path, bool &is_link, int64_t* size, datetime* modification_time, int* mode); 00063 00065 static int64_t get_size(native_string const& path, bool *is_link = 0); 00066 00070 bool begin_find_files(native_string path, bool dirs_only = false); 00071 00073 bool get_next_file(native_string& name); 00074 00078 bool get_next_file(native_string& name, bool &is_link, bool &is_dir, int64_t* size, datetime* modification_time, int* mode); 00079 00081 void end_find_files(); 00082 00083 static datetime get_modification_time(native_string const& path); 00084 static bool set_modification_time(native_string const& path, const datetime& t); 00085 00087 static native_string get_link_target(native_string const& path); 00088 00089 private: 00090 #ifndef FZ_WINDOWS 00091 void alloc_path_buffer(char const* file); // Ensures m_raw_path is large enough to hold path and filename 00092 #endif 00093 00094 // State for directory enumeration 00095 bool m_dirs_only{}; 00096 00097 #ifdef FZ_WINDOWS 00098 WIN32_FIND_DATA m_find_data{}; 00099 HANDLE m_hFind{INVALID_HANDLE_VALUE}; 00100 bool m_found{}; 00101 native_string m_find_path; 00102 #else 00103 char* m_raw_path{}; 00104 char* m_file_part{}; // Points into m_raw_path past the trailing slash of the path part 00105 int m_buffer_length{}; 00106 DIR* m_dir{}; 00107 #endif 00108 }; 00109 00110 } 00111 00112 #endif