TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Directory.cpp File Reference
#include "../CascLib.h"
#include "../CascCommon.h"
+ Include dependency graph for Directory.cpp:

Macros

#define __CASCLIB_SELF__
 

Functions

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

Macro Definition Documentation

#define __CASCLIB_SELF__

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

+ Here is the caller graph for this function:

int ScanIndexDirectory ( const TCHAR szIndexPath,
INDEX_FILE_FOUND  pfnOnFileFound,
PDWORD  MainIndexes,
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:

+ Here is the caller graph for this function: