0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

io: make MP_PATH_MAX private to win32 code

The win32 code is the only thing which actually needs this (and it's
used to make emulation of UTF-8 filename APIs easier).
This commit is contained in:
wm4 2014-02-03 22:11:33 +01:00
parent d91b9e9f3b
commit 8edf2cda4b
2 changed files with 10 additions and 12 deletions

View File

@ -217,6 +217,16 @@ FILE *mp_fopen(const char *filename, const char *mode)
return res;
}
// Windows' MAX_PATH/PATH_MAX/FILENAME_MAX is fixed to 260, but this limit
// applies to unicode paths encoded with wchar_t (2 bytes on Windows). The UTF-8
// version could end up bigger in memory. In the worst case each wchar_t is
// encoded to 3 bytes in UTF-8, so in the worst case we have:
// wcslen(wpath) * 3 <= strlen(utf8path)
// Thus we need MP_PATH_MAX as the UTF-8/char version of PATH_MAX.
// Also make sure there's free space for the terminating \0.
// (For codepoints encoded as UTF-16 surrogate pairs, UTF-8 has the same length.)
#define MP_PATH_MAX (FILENAME_MAX * 3 + 1)
struct mp_dir {
DIR crap; // must be first member
_WDIR *wdir;

View File

@ -54,16 +54,6 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s);
#include <sys/stat.h>
#include <fcntl.h>
// Windows' MAX_PATH/PATH_MAX/FILENAME_MAX is fixed to 260, but this limit
// applies to unicode paths encoded with wchar_t (2 bytes on Windows). The UTF-8
// version could end up bigger in memory. In the worst case each wchar_t is
// encoded to 3 bytes in UTF-8, so in the worst case we have:
// wcslen(wpath) * 3 <= strlen(utf8path)
// Thus we need MP_PATH_MAX as the UTF-8/char version of PATH_MAX.
// Also make sure there's free space for the terminating \0.
// (For codepoints encoded as UTF-16 surrogate pairs, UTF-8 has the same length.)
#define MP_PATH_MAX (FILENAME_MAX * 3 + 1)
void mp_get_converted_argv(int *argc, char ***argv);
int mp_stat(const char *path, struct stat *buf);
@ -94,8 +84,6 @@ char *mp_getenv(const char *name);
#else /* __MINGW32__ */
#define MP_PATH_MAX PATH_MAX
#define mp_stat(...) stat(__VA_ARGS__)
#endif /* __MINGW32__ */