Skip to content

Commit

Permalink
More linux port for LocatorAPI. Part 2. ToDo: fix _findfirst, _findne…
Browse files Browse the repository at this point in the history
…xt, _findclose
  • Loading branch information
q4a committed May 20, 2018
1 parent e75eea6 commit ad890be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sys/stat.h>
#else
#include <sys/mman.h>
#include <fstream>
#endif
#include <fcntl.h>
#pragma warning(pop)
Expand Down Expand Up @@ -571,15 +572,27 @@ bool ignore_name(const char* _name)

bool ignore_path(const char* _path)
{
#ifdef WINDOWS
HANDLE h = CreateFile(_path, 0, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY | FILE_FLAG_NO_BUFFERING, nullptr);

if (h != INVALID_HANDLE_VALUE)
{
CloseHandle(h);
return false;
return false; // file exists
}
else
return true;
#else
if (std::ifstream(_path))
return false; // file exists
else
return true;
//if( access( fname, F_OK ) != -1 ) {
// // file exists
//} else {
// // file doesn't exist
//}
#endif
}

bool CLocatorAPI::Recurse(pcstr path)
Expand Down
20 changes: 20 additions & 0 deletions src/xrCore/LocatorAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@
#include <inttypes.h>
#include <sys/types.h> /* To get time_t. */

#define _A_HIDDEN 0x02
#define _A_SUBDIR 0x10

#ifndef FILENAME_MAX
#define FILENAME_MAX (260)
#endif

#ifdef XR_X64
#define _finddata_t _finddata64i32_t
#elif XR_X86
#define _finddata_t _finddata32_t
#endif // XR_X64 or XR_X86

typedef int64_t __int64;
typedef __int64 __time64_t;
typedef long __time32_t;
typedef unsigned long _fsize_t;

struct _finddata64i32_t {
Expand All @@ -25,6 +34,17 @@ struct _finddata64i32_t {
_fsize_t size;
char name[FILENAME_MAX];
};

struct _finddata32_t
{
unsigned attrib;
__time32_t time_create;
__time32_t time_access;
__time32_t time_write;
_fsize_t size;
char name[FILENAME_MAX];
};

#endif // WINDOWS
#pragma warning(pop)

Expand Down

0 comments on commit ad890be

Please sign in to comment.