Stupid winsock needs special way to close sockets.
[dftpd.git] / IO.hpp
blob7be58eee62942ffda968d79e5e636b24e1117c8a
1 #ifndef __DFTPD__IO_HPP__
2 #define __DFTPD__IO_HPP__
4 #ifdef _WIN32
5 #include <windows.h>
6 #define S_ISDIR(mode) (((mode) & _S_IFMT) == (_S_IFDIR))
7 #define S_ISREG(mode) (((mode) & _S_IFMT) == (_S_IFREG))
8 #define localtime_r(a,b) localtime_s(b,a)
9 #else
10 #include <dirent.h>
11 #endif
13 #include <string>
15 class IO
17 public:
18 static bool MkDir( const std::string& dir );
19 static bool RmDir( const std::string& dir );
21 private:
22 IO() {};
25 class Directory
27 public:
28 Directory();
29 ~Directory();
31 bool Open( const std::string& dir );
33 Directory& operator++();
34 operator bool();
36 std::string GetName();
38 private:
39 #ifdef _WIN32
40 HANDLE m_handle;
41 WIN32_FIND_DATA m_ffd;
42 std::string m_path;
43 #else
44 DIR* m_dir;
45 dirent* m_dirent;
46 #endif
49 #endif