Skip to content

Commit 06e9882

Browse files
Changes to gvfs to allow Visual Studio compile
unistd.h is replaced by io.h and other small changes. gexport.h is for static libs
1 parent 237ff39 commit 06e9882

10 files changed

+93
-1
lines changed

libgvfs/findfp.c

+7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@
3131
* SUCH DAMAGE.
3232
*/
3333

34+
#ifdef WINSTORE
35+
#include <io.h>
36+
#define STDIN_FILENO 0
37+
#define STDOUT_FILENO 1
38+
#define STDERR_FILENO 2
39+
#else
3440
#include <sys/param.h>
3541
#include <unistd.h>
42+
#endif
3643
#include <stdio.h>
3744
#include <errno.h>
3845
#include <stdlib.h>

libgvfs/flags.c

+57
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,68 @@
3232
*/
3333

3434
#include <sys/types.h>
35+
#ifndef WINSTORE
3536
#include <sys/file.h>
37+
#endif
3638
#include <stdio.h>
3739
#include <errno.h>
3840
#include "local.h"
3941

42+
#ifdef WINSTORE
43+
/* Specifiy one of these flags to define the access mode. */
44+
#define _O_RDONLY 0
45+
#define _O_WRONLY 1
46+
#define _O_RDWR 2
47+
48+
/* Mask for access mode bits in the _open flags. */
49+
#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
50+
51+
#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
52+
53+
#define _O_RANDOM 0x0010
54+
#define _O_SEQUENTIAL 0x0020
55+
#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
56+
* WARNING: Even if not created by _open! */
57+
#define _O_NOINHERIT 0x0080
58+
59+
#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
60+
#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
61+
#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
62+
63+
#define _O_SHORT_LIVED 0x1000
64+
65+
/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
66+
#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
67+
#define _O_BINARY 0x8000 /* Input and output is not translated. */
68+
#define _O_RAW _O_BINARY
69+
70+
#if (__MSVCRT_VERSION__ >= 0x0800)
71+
#define _O_WTEXT 0x10000
72+
#define _O_U16TEXT 0x20000
73+
#define _O_U8TEXT 0x40000
74+
#endif
75+
76+
#ifndef _NO_OLDNAMES
77+
78+
/* POSIX/Non-ANSI names for increased portability */
79+
#define O_RDONLY _O_RDONLY
80+
#define O_WRONLY _O_WRONLY
81+
#define O_RDWR _O_RDWR
82+
#define O_ACCMODE _O_ACCMODE
83+
#define O_APPEND _O_APPEND
84+
#define O_CREAT _O_CREAT
85+
#define O_TRUNC _O_TRUNC
86+
#define O_EXCL _O_EXCL
87+
#define O_TEXT _O_TEXT
88+
#define O_BINARY _O_BINARY
89+
#define O_TEMPORARY _O_TEMPORARY
90+
#define O_NOINHERIT _O_NOINHERIT
91+
#define O_SEQUENTIAL _O_SEQUENTIAL
92+
#define O_RANDOM _O_RANDOM
93+
#endif
94+
#endif
95+
96+
4097
/*
4198
* Return the (stdio) flags for a given mode. Store the flags
4299
* to be passed to an open() syscall through *optr.

libgvfs/flockfile.c

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* $OpenBSD: flockfile.c,v 1.7 2004/09/28 18:12:44 otto Exp $ */
22

3+
#ifndef WINSTORE
34
#include <sys/time.h>
5+
#endif
6+
47
#include <stdio.h>
58
#include "local.h"
69

libgvfs/fopen.c

+4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737
#include <limits.h>
3838
#include <stdio.h>
3939
#include <errno.h>
40+
#ifdef WINSTORE
41+
#include <io.h>
42+
#else
4043
#include <unistd.h>
44+
#endif
4145
#include "local.h"
4246

4347
FILE *

libgvfs/freopen.c

+4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
#include <fcntl.h>
3737
#include <errno.h>
3838
#include <limits.h>
39+
#ifdef WINSTORE
40+
#include <io.h>
41+
#else
3942
#include <unistd.h>
43+
#endif
4044
#include <stdio.h>
4145
#include <stdlib.h>
4246
#include "local.h"

libgvfs/gexport.h

+4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
#ifdef GIDEROS_LIBRARY
66
#define GIDEROS_API __declspec(dllexport)
77
#else
8+
#ifdef WINSTORE
9+
#define GIDEROS_API
10+
#else
811
#define GIDEROS_API __declspec(dllimport)
912
#endif
13+
#endif
1014
#else
1115
#define GIDEROS_API
1216
#endif

libgvfs/makebuf.c

+4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333

3434
#include <sys/types.h>
3535
#include <sys/stat.h>
36+
#ifdef WINSTORE
37+
#include <io.h>
38+
#else
3639
#include <unistd.h>
40+
#endif
3741
#include <stdio.h>
3842
#include <stdlib.h>
3943
#include "local.h"

libgvfs/stdio.c

+4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
*/
3333

3434
#include <fcntl.h>
35+
#ifdef WINSTORE
36+
#include <io.h>
37+
#else
3538
#include <unistd.h>
39+
#endif
3640
#include <stdio.h>
3741
#include "local.h"
3842

libgvfs/vfscanf.c

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ static long double strtold(const char *s, char **sp)
5050
}
5151
#endif
5252

53+
#ifdef WINSTORE
54+
#define __signed
55+
#define ssize_t size_t
56+
#endif
57+
5358
#define BUF 513 /* Maximum length of numeric string. */
5459

5560
/*

libgvfs/wsetup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ __swsetup(FILE *fp)
8181
fp->_w = 0;
8282
fp->_lbfsize = -fp->_bf._size;
8383
} else
84-
fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size;
84+
fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size;
8585
return (0);
8686
}

0 commit comments

Comments
 (0)