support windows compilation, upgrade to current uxnt.

This commit is contained in:
U-WIN-U2045GN0RNQ\Vítor Santos Costa
2011-03-09 00:02:21 +00:00
parent e4275b6361
commit 752fa4fc53
8 changed files with 53 additions and 55 deletions

View File

@@ -16,6 +16,10 @@
#endif
#include "Yap.h"
#ifdef __WINDOWS__
#include <windows.h>
#include <uxnt.h>
#endif
#include "YapHeap.h"
/* try not to pollute the SWI space */
#ifdef P
@@ -138,9 +142,6 @@ typedef enum
#if HAVE_SYS_PARAM_H
#include <sys/param.h> //MAXPATHLEN
#endif
#ifdef __WINDOWS__
#include <windows.h>
#endif
#if __YAP_PROLOG__
#include "pl-yap.h"
#if _WIN32
@@ -583,17 +584,6 @@ typedef double real;
/* uxnt package interface */
#if defined(__YAP_PROLOG__) && defined(__MINGW32__)
#define O_XOS 1
#define _XOS_ISFILE 0x01
#define _XOS_ISDIR 0x02
#define _XOS_FILE 0x0001 /* is a file */
#define _XOS_DIR 0x0002 /* is a directory */
#define XOS_DOWNCASE 0x01 /* _xos_canonical_filename() */
#define statfunc stat
#ifndef __WINDOWS__
#define __WINDOWS__ 1

View File

@@ -26,6 +26,9 @@
#define _UNICODE 1
#define _UXNT_KERNEL 1
#include "uxnt.h" /* my prototypes */
#include "utf8.c"
#include <windows.h>
#include <tchar.h>
#include <wchar.h>
@@ -44,9 +47,6 @@
#endif
#include <errno.h>
#include "uxnt.h" /* my prototypes */
#include "utf8.c"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
@@ -293,7 +293,7 @@ _xos_os_filename(const char *cname, char *osname, size_t len)
if ( !_xos_os_filenameW(cname, buf, PATH_MAX) )
return NULL;
return wcstoutf8(osname, buf, len);
}
@@ -319,7 +319,7 @@ _xos_canonical_filenameW(const wchar_t *spec,
for(; *s; s++)
{ int c = *s;
if ( c == '\\' )
{ c = '/';
} else if ( (flags&XOS_DOWNCASE) )
@@ -344,7 +344,7 @@ _xos_canonical_filename(const char *spec, char *xname, size_t len, int flags)
if ( !utf8towcs(buf, spec, PATH_MAX) )
return NULL;
return _xos_canonical_filenameW(buf, xname, len, flags);
}
@@ -521,7 +521,7 @@ _xos_limited_os_filename(const char *spec, char *limited)
while(*i)
{ int wc;
i = utf8_get_char(i, &wc);
wc = towlower((wchar_t)wc);
o = utf8_put_char(o, wc);
@@ -541,7 +541,7 @@ _xos_open(const char *path, int access, ...)
{ va_list args;
TCHAR buf[PATH_MAX];
int mode;
va_start(args, access);
mode = va_arg(args, int);
va_end(args);
@@ -647,18 +647,22 @@ _xos_rename(const char *old, const char *new)
!_xos_os_filenameW(new, osnew, PATH_MAX) )
return -1;
return _wrename(osold, osnew);
if ( MoveFileEx(osold, osnew, MOVEFILE_REPLACE_EXISTING) )
return 0;
errno = EPERM;
return -1; /* TBD: map error codes */
}
int
_xos_stat(const char *path, struct _stat *sbuf)
_xos_stat(const char *path, struct _stati64 *sbuf)
{ TCHAR buf[PATH_MAX];
if ( !_xos_os_filenameW(path, buf, PATH_MAX) )
return -1;
return _wstat(buf, sbuf);
return _wstati64(buf, sbuf);
}
@@ -699,11 +703,14 @@ opendir(const char *path)
DIR *dp = malloc(sizeof(DIR));
if ( !_xos_os_filenameW(path, buf, PATH_MAX-4) )
{ free(dp);
return NULL;
}
_tcscat(buf, _T("\\*.*"));
if ( !(dp->data = malloc(sizeof(WIN32_FIND_DATA))) )
{ errno = ENOMEM;
{ free(dp);
errno = ENOMEM;
return NULL;
}
dp->first = 1;
@@ -712,6 +719,7 @@ opendir(const char *path)
if ( dp->handle == INVALID_HANDLE_VALUE )
{ if ( _waccess(buf, 04) ) /* does not exist */
{ free(dp->data);
free(dp);
return NULL;
}
}
@@ -825,6 +833,7 @@ _xos_getcwd(char *buf, size_t len)
return NULL;
}
/*******************************
* ENVIRONMENT *
*******************************/
@@ -853,7 +862,7 @@ _xos_getenv(const char *name, char *buf, size_t buflen)
rc = strlen(buf);
else
rc = wcutf8len(valp);
if ( valp != val )
free(valp);

4
packages/PLStream/windows/uxnt.h Normal file → Executable file
View File

@@ -33,6 +33,7 @@
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <io.h>
#include <direct.h>
@@ -45,7 +46,6 @@ typedef intptr_t ssize_t; /* signed version of size_t */
#endif
#ifndef _UXNT_KERNEL
#include <sys/stat.h>
#undef remove
#undef rename
@@ -133,7 +133,7 @@ _export int _xos_access(const char *path, int mode);
_export int _xos_chmod(const char *path, int mode);
_export int _xos_remove(const char *path);
_export int _xos_rename(const char *old, const char *newname);
_export int _xos_stat(const char *path, struct _stat *sbuf);
_export int _xos_stat(const char *path, struct _stati64 *sbuf);
_export int _xos_chdir(const char *path);
_export int _xos_mkdir(const char *path, int mode);
_export int _xos_rmdir(const char *path);