Skip to content

Commit ad890be

Browse files
committed
More linux port for LocatorAPI. Part 2. ToDo: fix _findfirst, _findnext, _findclose
1 parent e75eea6 commit ad890be

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/xrCore/LocatorAPI.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <sys/stat.h>
1313
#else
1414
#include <sys/mman.h>
15+
#include <fstream>
1516
#endif
1617
#include <fcntl.h>
1718
#pragma warning(pop)
@@ -571,15 +572,27 @@ bool ignore_name(const char* _name)
571572

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

576578
if (h != INVALID_HANDLE_VALUE)
577579
{
578580
CloseHandle(h);
579-
return false;
581+
return false; // file exists
580582
}
581583
else
582584
return true;
585+
#else
586+
if (std::ifstream(_path))
587+
return false; // file exists
588+
else
589+
return true;
590+
//if( access( fname, F_OK ) != -1 ) {
591+
// // file exists
592+
//} else {
593+
// // file doesn't exist
594+
//}
595+
#endif
583596
}
584597

585598
bool CLocatorAPI::Recurse(pcstr path)

src/xrCore/LocatorAPI.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@
88
#include <inttypes.h>
99
#include <sys/types.h> /* To get time_t. */
1010

11+
#define _A_HIDDEN 0x02
12+
#define _A_SUBDIR 0x10
13+
1114
#ifndef FILENAME_MAX
1215
#define FILENAME_MAX (260)
1316
#endif
1417

18+
#ifdef XR_X64
1519
#define _finddata_t _finddata64i32_t
20+
#elif XR_X86
21+
#define _finddata_t _finddata32_t
22+
#endif // XR_X64 or XR_X86
23+
1624
typedef int64_t __int64;
1725
typedef __int64 __time64_t;
26+
typedef long __time32_t;
1827
typedef unsigned long _fsize_t;
1928

2029
struct _finddata64i32_t {
@@ -25,6 +34,17 @@ struct _finddata64i32_t {
2534
_fsize_t size;
2635
char name[FILENAME_MAX];
2736
};
37+
38+
struct _finddata32_t
39+
{
40+
unsigned attrib;
41+
__time32_t time_create;
42+
__time32_t time_access;
43+
__time32_t time_write;
44+
_fsize_t size;
45+
char name[FILENAME_MAX];
46+
};
47+
2848
#endif // WINDOWS
2949
#pragma warning(pop)
3050

0 commit comments

Comments
 (0)