TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Directory.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef bool(* INDEX_FILE_FOUND )(const TCHAR *szFileName, PDWORD IndexArray, PDWORD OldIndexArray, void *pvContext)
 

Functions

bool DirectoryExists (const TCHAR *szDirectory)
 
int ScanIndexDirectory (const TCHAR *szIndexPath, INDEX_FILE_FOUND pfnOnFileFound, PDWORD IndexArray, PDWORD OldIndexArray, void *pvContext)
 

Typedef Documentation

typedef bool(* INDEX_FILE_FOUND)(const TCHAR *szFileName, PDWORD IndexArray, PDWORD OldIndexArray, void *pvContext)

Function Documentation

bool DirectoryExists ( const TCHAR szDirectory)
19 {
20 #ifdef PLATFORM_WINDOWS
21 
22  DWORD dwAttributes = GetFileAttributes(szDirectory);
23  if((dwAttributes != INVALID_FILE_ATTRIBUTES) && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
24  return true;
25 
26 #else // PLATFORM_WINDOWS
27 
28  DIR * dir = opendir(szDirectory);
29 
30  if(dir != NULL)
31  {
32  closedir(dir);
33  return true;
34  }
35 
36 #endif
37 
38  return false;
39 }
arena_t NULL
Definition: jemalloc_internal.h:624
unsigned int DWORD
Definition: CascPort.h:139
int ScanIndexDirectory ( const TCHAR szIndexPath,
INDEX_FILE_FOUND  pfnOnFileFound,
PDWORD  IndexArray,
PDWORD  OldIndexArray,
void *  pvContext 
)
47 {
48 #ifdef PLATFORM_WINDOWS
49 
50  WIN32_FIND_DATA wf;
51  TCHAR * szSearchMask;
52  HANDLE hFind;
53 
54  // Prepare the search mask
55  szSearchMask = CombinePath(szIndexPath, _T("*"));
56  if(szSearchMask == NULL)
58 
59  // Prepare directory search
60  hFind = FindFirstFile(szSearchMask, &wf);
61  if(hFind != INVALID_HANDLE_VALUE)
62  {
63  // Skip the first file as it's always just "." or ".."
64  while(FindNextFile(hFind, &wf))
65  {
66  // If the found object is a file, pass it to the handler
67  if(!(wf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
68  {
69  // Let the callback scan the file name
70  pfnOnFileFound(wf.cFileName, MainIndexes, OldIndexArray, pvContext);
71  }
72  }
73 
74  // Close the search handle
75  FindClose(hFind);
76  }
77 
78  CASC_FREE(szSearchMask);
79 
80 #else // PLATFORM_WINDOWS
81 
82  struct dirent * dir_entry;
83  DIR * dir;
84 
85  dir = opendir(szIndexPath);
86  if(dir != NULL)
87  {
88  while((dir_entry = readdir(dir)) != NULL)
89  {
90  if(dir_entry->d_type != DT_DIR)
91  {
92  pfnOnFileFound(dir_entry->d_name, MainIndexes, OldIndexArray, pvContext);
93  }
94  }
95 
96  closedir(dir);
97  }
98 
99 #endif
100 
101  return ERROR_SUCCESS;
102 }
void * HANDLE
Definition: CascPort.h:146
#define ERROR_NOT_ENOUGH_MEMORY
Definition: CascPort.h:208
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
#define _T(x)
Definition: CascPort.h:171
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
TCHAR * CombinePath(const TCHAR *szDirectory, const TCHAR *szSubDir)
Definition: Common.cpp:157
#define INVALID_HANDLE_VALUE
Definition: CascPort.h:169
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function: