22 #ifndef AVFORMAT_OS_SUPPORT_H
23 #define AVFORMAT_OS_SUPPORT_H
48 # define lseek(f,p,w) _lseeki64((f), (p), (w))
53 # define stat win32_stat
69 unsigned short st_mode;
83 # define fstat win32_fstat
94 # define lseek(f,p,w) lseek64((f), (p), (w))
100 if (path[0] && path[1] ==
':')
108 #define S_IRUSR S_IREAD
111 #define S_IWUSR S_IWRITE
117 #define SHUT_RD SD_RECEIVE
118 #define SHUT_WR SD_SEND
119 #define SHUT_RDWR SD_BOTH
121 #include <sys/socket.h>
122 #if !defined(SHUT_RD)
130 typedef int socklen_t;
134 #if !HAVE_CLOSESOCKET
135 #define closesocket close
139 typedef unsigned long nfds_t;
142 #include <winsock2.h>
144 #if !HAVE_STRUCT_POLLFD
152 #define POLLIN 0x0001
153 #define POLLOUT 0x0002
154 #define POLLRDNORM POLLIN
155 #define POLLWRNORM POLLOUT
156 #define POLLRDBAND 0x0008
157 #define POLLWRBAND 0x0010
158 #define POLLPRI 0x0020
161 #define POLLERR 0x0004
162 #define POLLHUP 0x0080
163 #define POLLNVAL 0x1000
167 int ff_poll(
struct pollfd *fds, nfds_t numfds,
int timeout);
177 #define DEF_FS_FUNCTION(name, wfunc, afunc) \
178 static inline int win32_##name(const char *filename_utf8) \
180 wchar_t *filename_w; \
183 if (get_extended_win32_path(filename_utf8, &filename_w)) \
188 ret = wfunc(filename_w); \
189 av_free(filename_w); \
194 return afunc(filename_utf8); \
197 DEF_FS_FUNCTION(unlink, _wunlink, _unlink)
198 DEF_FS_FUNCTION(mkdir, _wmkdir, _mkdir)
199 DEF_FS_FUNCTION(rmdir, _wrmdir , _rmdir)
201 static inline int win32_access(
const char *filename_utf8,
int mode)
205 if (get_extended_win32_path(filename_utf8, &filename_w))
209 ret = _waccess(filename_w,
mode);
213 return _access(filename_utf8,
mode);
216 static inline void copy_stat(
struct _stat64 *crtstat,
struct win32_stat *buf)
218 buf->st_dev = crtstat->st_dev;
219 buf->st_ino = crtstat->st_ino;
220 buf->st_mode = crtstat->st_mode;
221 buf->st_nlink = crtstat->st_nlink;
222 buf->st_uid = crtstat->st_uid;
223 buf->st_gid = crtstat->st_gid;
224 buf->st_rdev = crtstat->st_rdev;
225 buf->st_size = crtstat->st_size;
226 buf->st_atime = crtstat->st_atime;
227 buf->st_mtime = crtstat->st_mtime;
228 buf->st_ctime = crtstat->st_ctime;
231 static inline int win32_stat(
const char *filename_utf8,
struct win32_stat *buf)
233 struct _stat64 crtstat = { 0 };
237 if (get_extended_win32_path(filename_utf8, &filename_w))
241 ret = _wstat64(filename_w, &crtstat);
244 ret = _stat64(filename_utf8, &crtstat);
246 copy_stat(&crtstat, buf);
251 static inline int win32_fstat(
int fd,
struct win32_stat *buf)
253 struct _stat64 crtstat = { 0 };
256 ret = _fstat64(fd, &crtstat);
258 copy_stat(&crtstat, buf);
263 static inline int win32_rename(
const char *src_utf8,
const char *dest_utf8)
265 wchar_t *src_w, *dest_w;
268 if (get_extended_win32_path(src_utf8, &src_w))
270 if (get_extended_win32_path(dest_utf8, &dest_w)) {
274 if (!src_w || !dest_w) {
280 ret = MoveFileExW(src_w, dest_w, MOVEFILE_REPLACE_EXISTING);
291 ret = MoveFileExA(src_utf8, dest_utf8, MOVEFILE_REPLACE_EXISTING);
303 ret = rename(src_utf8, dest_utf8);
308 #define mkdir(a, b) win32_mkdir(a)
309 #define rename win32_rename
310 #define rmdir win32_rmdir
311 #define unlink win32_unlink
312 #define access win32_access