22 #ifndef AVFORMAT_OS_SUPPORT_H
23 #define AVFORMAT_OS_SUPPORT_H
49 # define lseek(f,p,w) _lseeki64((f), (p), (w))
54 # define stat win32_stat
70 unsigned short st_mode;
84 # define fstat win32_fstat
95 # define lseek(f,p,w) lseek64((f), (p), (w))
101 if (path[0] && path[1] ==
':')
109 #define S_IRUSR S_IREAD
112 #define S_IWUSR S_IWRITE
118 #define SHUT_RD SD_RECEIVE
119 #define SHUT_WR SD_SEND
120 #define SHUT_RDWR SD_BOTH
122 #include <sys/socket.h>
123 #if !defined(SHUT_RD)
131 typedef int socklen_t;
135 #if !HAVE_CLOSESOCKET
136 #define closesocket close
140 typedef unsigned long nfds_t;
143 #include <winsock2.h>
145 #if !HAVE_STRUCT_POLLFD
153 #define POLLIN 0x0001
154 #define POLLOUT 0x0002
155 #define POLLRDNORM POLLIN
156 #define POLLWRNORM POLLOUT
157 #define POLLRDBAND 0x0008
158 #define POLLWRBAND 0x0010
159 #define POLLPRI 0x0020
162 #define POLLERR 0x0004
163 #define POLLHUP 0x0080
164 #define POLLNVAL 0x1000
168 int ff_poll(
struct pollfd *fds, nfds_t numfds,
int timeout);
178 #define DEF_FS_FUNCTION(name, wfunc, afunc) \
179 static inline int win32_##name(const char *filename_utf8) \
181 wchar_t *filename_w; \
184 if (get_extended_win32_path(filename_utf8, &filename_w)) \
189 ret = wfunc(filename_w); \
190 av_free(filename_w); \
195 return afunc(filename_utf8); \
198 DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
199 DEF_FS_FUNCTION(mkdir, _wmkdir, _mkdir)
200 DEF_FS_FUNCTION(rmdir, _wrmdir , _rmdir)
202 static inline int win32_access(
const char *filename_utf8,
int mode)
206 if (get_extended_win32_path(filename_utf8, &filename_w))
210 ret = _waccess(filename_w,
mode);
214 return _access(filename_utf8,
mode);
217 static inline void copy_stat(
struct _stat64 *crtstat,
struct win32_stat *buf)
219 buf->st_dev = crtstat->st_dev;
220 buf->st_ino = crtstat->st_ino;
221 buf->st_mode = crtstat->st_mode;
222 buf->st_nlink = crtstat->st_nlink;
223 buf->st_uid = crtstat->st_uid;
224 buf->st_gid = crtstat->st_gid;
225 buf->st_rdev = crtstat->st_rdev;
226 buf->st_size = crtstat->st_size;
227 buf->st_atime = crtstat->st_atime;
228 buf->st_mtime = crtstat->st_mtime;
229 buf->st_ctime = crtstat->st_ctime;
232 static inline int win32_stat(
const char *filename_utf8,
struct win32_stat *buf)
234 struct _stat64 crtstat = { 0 };
238 if (get_extended_win32_path(filename_utf8, &filename_w))
242 ret = _wstat64(filename_w, &crtstat);
245 ret = _stat64(filename_utf8, &crtstat);
247 copy_stat(&crtstat, buf);
252 static inline int win32_fstat(
int fd,
struct win32_stat *buf)
254 struct _stat64 crtstat = { 0 };
257 ret = _fstat64(fd, &crtstat);
259 copy_stat(&crtstat, buf);
264 static inline int win32_rename(
const char *src_utf8,
const char *dest_utf8)
266 wchar_t *src_w, *dest_w;
269 if (get_extended_win32_path(src_utf8, &src_w))
271 if (get_extended_win32_path(dest_utf8, &dest_w)) {
275 if (!src_w || !dest_w) {
281 ret = MoveFileExW(src_w, dest_w, MOVEFILE_REPLACE_EXISTING);
292 ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
304 ret = rename(src_utf8, dest_utf8);
309 #define mkdir(a, b) win32_mkdir(a)
310 #define rename win32_rename
311 #define rmdir win32_rmdir
312 #define unlink win32_unlink
313 #define access win32_access