source: filezilla/trunk/fuentes/src/include/local_filesys.h @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 3 years ago

First release to xenial

File size: 2.4 KB
Line 
1#ifndef __LOCAL_FILESYS_H__
2#define __LOCAL_FILESYS_H__
3
4// This class adds an abstraction layer for the local filesystem.
5// Although wxWidgets provides functions for this, they are in
6// general too slow.
7// This class offers exactly what's needed by FileZilla and
8// exploits some platform-specific features.
9class CLocalFileSystem final
10{
11public:
12        CLocalFileSystem() = default;
13        ~CLocalFileSystem();
14
15        CLocalFileSystem(CLocalFileSystem const&) = delete;
16        CLocalFileSystem& operator=(CLocalFileSystem const&) = delete;
17
18        enum local_fileType
19        {
20                unknown = -1,
21                file,
22                dir,
23                link,
24                link_file = link,
25                link_dir
26        };
27
28        static const wxChar path_separator;
29
30        // If called with a symlink, GetFileType stats the link, not
31        // the target.
32        static local_fileType GetFileType(wxString const& path);
33
34        // Follows symlinks and stats the target, sets isLink to true if path was
35        // a link.
36        static local_fileType GetFileInfo(wxString const& path, bool &isLink, int64_t* size, CDateTime* modificationTime, int* mode);
37
38        // Shortcut, returns -1 on error.
39        static int64_t GetSize(wxString const& path, bool *isLink = 0);
40
41        // If parent window is given, display confirmation dialog
42        // Returns false iff there's an encoding error, e.g. program
43        // started without UTF-8 locale.
44        static bool RecursiveDelete(wxString const& path, wxWindow* parent);
45        static bool RecursiveDelete(std::list<wxString> dirsToVisit, wxWindow* parent);
46
47        bool BeginFindFiles(wxString path, bool dirs_only);
48        bool GetNextFile(wxString& name);
49        bool GetNextFile(wxString& name, bool &isLink, bool &is_dir, int64_t* size, CDateTime* modificationTime, int* mode);
50        void EndFindFiles();
51
52        static CDateTime GetModificationTime(wxString const& path);
53        static bool SetModificationTime(wxString const& path, const CDateTime& t);
54
55        static wxString GetSymbolicLinkTarget(wxString const& path);
56
57protected:
58#ifndef __WXMSW__
59        static local_fileType GetFileInfo(const char* path, bool &isLink, int64_t* size, CDateTime* modificationTime, int* mode);
60        void AllocPathBuffer(const char* file);  // Ensures m_raw_path is large enough to hold path and filename
61#endif
62
63        // State for directory enumeration
64        bool m_dirs_only{};
65#ifdef __WXMSW__
66        WIN32_FIND_DATA m_find_data;
67        HANDLE m_hFind{INVALID_HANDLE_VALUE};
68        bool m_found{};
69        wxString m_find_path;
70#else
71        char* m_raw_path{};
72        char* m_file_part{}; // Points into m_raw_path past the trailing slash of the path part
73        int m_buffer_length{};
74        DIR* m_dir{};
75#endif
76};
77
78#endif //__LOCAL_FILESYS_H__
Note: See TracBrowser for help on using the repository browser.