diff options
Diffstat (limited to 'firmware/target/hosted/filesystem-win32.h')
-rw-r--r-- | firmware/target/hosted/filesystem-win32.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/firmware/target/hosted/filesystem-win32.h b/firmware/target/hosted/filesystem-win32.h new file mode 100644 index 0000000000..1d8f2749f9 --- /dev/null +++ b/firmware/target/hosted/filesystem-win32.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2014 by Michael Sevakis | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _FILESYSTEM_WIN32_H_ | ||
22 | #define _FILESYSTEM_WIN32_H_ | ||
23 | |||
24 | #ifndef OSFUNCTIONS_DECLARED | ||
25 | |||
26 | #ifdef __MINGW32__ | ||
27 | /* filesystem-win32.c contains some string functions that could be useful | ||
28 | * elsewhere; just move them away to unicode.c or something if they prove | ||
29 | * so. */ | ||
30 | size_t strlcpy_ucs2utf8(char *buffer, const unsigned short *ucs, | ||
31 | size_t bufsize); | ||
32 | |||
33 | #define strlcpy_from_os strlcpy_ucs2utf8 | ||
34 | #endif /* __MINGW32__ */ | ||
35 | |||
36 | #endif /* !OSFUNCTIONS_DECLARED */ | ||
37 | |||
38 | #endif /* _FILESYSTEM_WIN32_H_ */ | ||
39 | |||
40 | #ifdef __MINGW32__ | ||
41 | |||
42 | #ifdef _FILE_H_ | ||
43 | #ifndef _FILESYSTEM_WIN32__FILE_H_ | ||
44 | #define _FILESYSTEM_WIN32__FILE_H_ | ||
45 | |||
46 | #include <unistd.h> | ||
47 | #include <sys/stat.h> | ||
48 | |||
49 | #define OS_STAT_T struct _stat | ||
50 | |||
51 | #ifndef OSFUNCTIONS_DECLARED | ||
52 | /* Wrap for off_t <=> long conversions */ | ||
53 | static inline off_t os_filesize_(int osfd) | ||
54 | { return _filelength(osfd); } | ||
55 | static inline int os_ftruncate_(int osfd, off_t length) | ||
56 | { return _chsize(osfd, length); } | ||
57 | |||
58 | #define os_filesize os_filesize_ | ||
59 | #define os_ftruncate os_ftruncate_ | ||
60 | #define os_fsync _commit | ||
61 | #define os_fstat _fstat | ||
62 | #define os_close close | ||
63 | #define os_lseek lseek | ||
64 | #ifndef os_read | ||
65 | #define os_read read | ||
66 | #endif | ||
67 | #ifndef os_write | ||
68 | #define os_write write | ||
69 | #endif | ||
70 | |||
71 | /* These need string type conversion from utf8 to ucs2; that's done inside */ | ||
72 | int os_open(const char *ospath, int oflag, ...); | ||
73 | int os_creat(const char *ospath, mode_t mode); | ||
74 | int os_stat(const char *ospath, struct _stat *s); | ||
75 | int os_remove(const char *ospath); | ||
76 | int os_rename(const char *osold, const char *osnew); | ||
77 | |||
78 | #endif /* !OSFUNCTIONS_DECLARED */ | ||
79 | |||
80 | #endif /* _FILESYSTEM_WIN32__FILE_H_ */ | ||
81 | #endif /* _FILE_H_ */ | ||
82 | |||
83 | #ifdef _DIR_H_ | ||
84 | #ifndef _FILESYSTEM_WIN32__DIR_H_ | ||
85 | #define _FILESYSTEM_WIN32__DIR_H_ | ||
86 | |||
87 | #include <dirent.h> | ||
88 | |||
89 | #define OS_DIRENT_CONVERT /* needs string conversion */ | ||
90 | #define OS_DIR_T _WDIR | ||
91 | #define OS_DIRENT_T struct _wdirent | ||
92 | |||
93 | #ifndef OSFUNCTIONS_DECLARED | ||
94 | |||
95 | _WDIR * os_opendir(const char *osdirname); | ||
96 | int os_opendirfd(const char *osdirname); | ||
97 | #define os_readdir _wreaddir | ||
98 | #define os_closedir _wclosedir | ||
99 | int os_mkdir(const char *ospath, mode_t mode); | ||
100 | int os_rmdir(const char *ospath); | ||
101 | |||
102 | #endif /* OSFUNCTIONS_DECLARED */ | ||
103 | |||
104 | #endif /* _FILESYSTEM_WIN32__DIR_H_ */ | ||
105 | #endif /* _DIR_H_ */ | ||
106 | |||
107 | #else /* !__MINGW32__ */ | ||
108 | |||
109 | #include "filesystem-unix.h" | ||
110 | |||
111 | #endif /* __MINGW32__ */ | ||