]> git.proxmox.com Git - libgit2.git/blob - src/win32/w32_common.h
f9e74b9476f799cec8690076b163d95934df6d20
[libgit2.git] / src / win32 / w32_common.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7
8 #ifndef INCLUDE_win32_w32_common_h__
9 #define INCLUDE_win32_w32_common_h__
10
11 /*
12 * Provides a large enough buffer to support Windows paths: MAX_PATH is
13 * 260, corresponding to a maximum path length of 259 characters plus a
14 * NULL terminator. Prefixing with "\\?\" adds 4 characters, but if the
15 * original was a UNC path, then we turn "\\server\share" into
16 * "\\?\UNC\server\share". So we replace the first two characters with
17 * 8 characters, a net gain of 6, so the maximum length is MAX_PATH+6.
18 */
19 #define GIT_WIN_PATH_UTF16 MAX_PATH+6
20
21 /* Maximum size of a UTF-8 Win32 path. We remove the "\\?\" or "\\?\UNC\"
22 * prefixes for presentation, bringing us back to 259 (non-NULL)
23 * characters. UTF-8 does have 4-byte sequences, but they are encoded in
24 * UTF-16 using surrogate pairs, which takes up the space of two characters.
25 * Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8
26 * (6 bytes) than one surrogate pair (4 bytes).
27 */
28 #define GIT_WIN_PATH_UTF8 (259 * 3 + 1)
29
30 /*
31 * The length of a Windows "shortname", for 8.3 compatibility.
32 */
33 #define GIT_WIN_PATH_SHORTNAME 13
34
35 /* Win32 path types */
36 typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16];
37 typedef char git_win32_utf8_path[GIT_WIN_PATH_UTF8];
38
39 #endif