]>
Commit | Line | Data |
---|---|---|
22a2d3d5 UG |
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 | ||
c25aa7cd PP |
11 | #include <git2/common.h> |
12 | ||
13 | /* | |
14 | * 4096 is the max allowed Git path. `MAX_PATH` (260) is the typical max allowed | |
15 | * Windows path length, however win32 Unicode APIs generally allow up to 32,767 | |
16 | * if prefixed with "\\?\" (i.e. converted to an NT-style name). | |
17 | */ | |
18 | #define GIT_WIN_PATH_MAX GIT_PATH_MAX | |
19 | ||
22a2d3d5 | 20 | /* |
c25aa7cd PP |
21 | * Provides a large enough buffer to support Windows Git paths: |
22 | * GIT_WIN_PATH_MAX is 4096, corresponding to a maximum path length of 4095 | |
23 | * characters plus a NULL terminator. Prefixing with "\\?\" adds 4 characters, | |
24 | * but if the original was a UNC path, then we turn "\\server\share" into | |
22a2d3d5 | 25 | * "\\?\UNC\server\share". So we replace the first two characters with |
c25aa7cd | 26 | * 8 characters, a net gain of 6, so the maximum length is GIT_WIN_PATH_MAX+6. |
22a2d3d5 | 27 | */ |
c25aa7cd | 28 | #define GIT_WIN_PATH_UTF16 GIT_WIN_PATH_MAX+6 |
22a2d3d5 | 29 | |
c25aa7cd PP |
30 | /* Maximum size of a UTF-8 Win32 Git path. We remove the "\\?\" or "\\?\UNC\" |
31 | * prefixes for presentation, bringing us back to 4095 (non-NULL) | |
22a2d3d5 UG |
32 | * characters. UTF-8 does have 4-byte sequences, but they are encoded in |
33 | * UTF-16 using surrogate pairs, which takes up the space of two characters. | |
34 | * Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8 | |
35 | * (6 bytes) than one surrogate pair (4 bytes). | |
36 | */ | |
c25aa7cd | 37 | #define GIT_WIN_PATH_UTF8 ((GIT_WIN_PATH_MAX - 1) * 3 + 1) |
22a2d3d5 UG |
38 | |
39 | /* | |
40 | * The length of a Windows "shortname", for 8.3 compatibility. | |
41 | */ | |
42 | #define GIT_WIN_PATH_SHORTNAME 13 | |
43 | ||
44 | /* Win32 path types */ | |
45 | typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16]; | |
46 | typedef char git_win32_utf8_path[GIT_WIN_PATH_UTF8]; | |
47 | ||
48 | #endif |