summaryrefslogtreecommitdiff
path: root/lib/FindFilePlus/find_file_plus.h
blob: aacdf0eadcaeb9b4726201e8f1515235a9a937d8 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de)                    *
// **************************************************************************

#ifndef FIND_FIRST_FILE_PLUS_HEADER_087483434
#define FIND_FIRST_FILE_PLUS_HEADER_087483434

#ifdef FIND_FILE_PLUS_DLL_EXPORTS
#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport)
#else
#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport)
#endif


#ifdef FIND_FILE_PLUS_DLL_EXPORTS
#include <Ntifs.h>  //driver level headers must be included *before* windows api headers!
#endif
#include <windef.h> //
#undef min
#undef max

#include <zen/build_info.h>

namespace findplus
{
/*--------------
  |declarations|
  --------------*/

struct FileInformation
{
    FILETIME creationTime;
    FILETIME lastWriteTime;
    ULARGE_INTEGER fileSize;
    ULARGE_INTEGER fileId;
    DWORD fileAttributes;
    DWORD shortNameLength;
    WCHAR shortName[MAX_PATH + 1]; //shortName is 0-terminated
}; //no need for #pragma pack -> all members already starting at 4 byte boundary!

class FileSearcher;
typedef FileSearcher* FindHandle;

DLL_FUNCTION_DECLARATION
FindHandle openDir(const wchar_t* dirname); //returns NULL on error, call ::GetLastError()
//note: do NOT place an asterisk at end, e.g. C:\SomeDir\*, as one would do for ::FindFirstFile()

DLL_FUNCTION_DECLARATION
bool readDir(FindHandle hnd, FileInformation& output); //returns false on error or if there are no more files; ::GetLastError() returns ERROR_NO_MORE_FILES

DLL_FUNCTION_DECLARATION
void closeDir(FindHandle hnd);

/*----------
  |typedefs|
  ----------*/
typedef FindHandle (*OpenDirFunc )(const wchar_t* dirname);
typedef bool       (*ReadDirFunc )(FindHandle hnd, FileInformation& dirInfo);
typedef void       (*CloseDirFunc)(FindHandle hnd);

/*--------------
  |symbol names|
  --------------*/
//const pointers ensure internal linkage
const char openDirFuncName [] = "openDir";
const char readDirFuncName [] = "readDir";
const char closeDirFuncName[] = "closeDir";

/*---------------
  |library names|
  ---------------*/
inline const wchar_t* getDllName() { return zen::is64BitBuild ? L"FindFilePlus_x64.dll" : L"FindFilePlus_Win32.dll"; }
}


#endif //FIND_FIRST_FILE_PLUS_HEADER_087483434
bgstack15