File: autodir.h

package info (click to toggle)
rsyncrypto 1.14-1.2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,552 kB
  • sloc: cpp: 3,459; sh: 1,221; makefile: 29
file content (61 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Win32 implementation

#if !defined(_WIN32)
#error Win32 only header included from non-Win32 build environment
#endif

#if !defined(AUTODIR_H)
#define AUTODIR_H

struct dirent {
    char d_name[MAX_PATH];
};

class autodir {
    HANDLE h_dirscan;
    WIN32_FIND_DATA finddata;
    dirent posixdir;
    bool eof;
    bool utf8;

    // Disable default copy constructor
    autodir( const autodir & );
    autodir &operator=( const autodir & );

    // Convert wide find data to UTF8
    void data_w2a( const WIN32_FIND_DATAW *data );
public:
    explicit autodir( const char *dirname, bool _utf8=false );
    ~autodir()
    {
        clear();
    }

    void clear()
    {
        if( h_dirscan!=INVALID_HANDLE_VALUE ) {
            FindClose( h_dirscan );
            h_dirscan=INVALID_HANDLE_VALUE;
            eof=false;
        }
    }

    struct dirent *read();
    
    /*
    void rewind()
    {
        ::rewinddir(dir);
    }
    void seek( off_t offset )
    {
        seekdir( dir, offset );
    }
    off_t telldir()
    {
        return ::telldir( dir );
    }
    */
};

#endif // AUTODIR_H