mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 07:58:22 +00:00
Reintroduce type for UTF8 win32 path conversions
This commit is contained in:
parent
d4cff0cb1c
commit
841034a35e
@ -24,7 +24,7 @@ static int init_filter(char *filter, size_t n, const char *dir)
|
|||||||
|
|
||||||
git__DIR *git__opendir(const char *dir)
|
git__DIR *git__opendir(const char *dir)
|
||||||
{
|
{
|
||||||
char filter[GIT_WIN_PATH_UTF8];
|
git_win32_path_as_utf8 filter;
|
||||||
git_win32_path filter_w;
|
git_win32_path filter_w;
|
||||||
git__DIR *new = NULL;
|
git__DIR *new = NULL;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
struct git__dirent {
|
struct git__dirent {
|
||||||
int d_ino;
|
int d_ino;
|
||||||
char d_name[GIT_WIN_PATH_UTF8];
|
git_win32_path_as_utf8 d_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -109,10 +109,10 @@ static int do_lstat(
|
|||||||
* the length of the path pointed to, which we expect everywhere else
|
* the length of the path pointed to, which we expect everywhere else
|
||||||
*/
|
*/
|
||||||
if (S_ISLNK(fMode)) {
|
if (S_ISLNK(fMode)) {
|
||||||
char target[GIT_WIN_PATH_UTF8];
|
git_win32_path_as_utf8 target;
|
||||||
int readlink_result;
|
int readlink_result;
|
||||||
|
|
||||||
readlink_result = p_readlink(file_name, target, GIT_WIN_PATH_UTF8);
|
readlink_result = p_readlink(file_name, target, sizeof(target));
|
||||||
|
|
||||||
if (readlink_result == -1)
|
if (readlink_result == -1)
|
||||||
return -1;
|
return -1;
|
||||||
@ -300,7 +300,7 @@ int p_getcwd(char *buffer_out, size_t size)
|
|||||||
|
|
||||||
int p_stat(const char* path, struct stat* buf)
|
int p_stat(const char* path, struct stat* buf)
|
||||||
{
|
{
|
||||||
char target[GIT_WIN_PATH_UTF8];
|
git_win32_path_as_utf8 target;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
error = do_lstat(path, buf, 0);
|
error = do_lstat(path, buf, 0);
|
||||||
@ -308,7 +308,7 @@ int p_stat(const char* path, struct stat* buf)
|
|||||||
/* We need not do this in a loop to unwind chains of symlinks since
|
/* We need not do this in a loop to unwind chains of symlinks since
|
||||||
* p_readlink calls GetFinalPathNameByHandle which does it for us. */
|
* p_readlink calls GetFinalPathNameByHandle which does it for us. */
|
||||||
if (error >= 0 && S_ISLNK(buf->st_mode) &&
|
if (error >= 0 && S_ISLNK(buf->st_mode) &&
|
||||||
(error = p_readlink(path, target, GIT_WIN_PATH_UTF8)) >= 0)
|
(error = p_readlink(path, target, sizeof(target))) >= 0)
|
||||||
error = do_lstat(target, buf, 0);
|
error = do_lstat(target, buf, 0);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
@ -4,13 +4,12 @@
|
|||||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||||
* a Linking Exception. For full terms see the included COPYING file.
|
* a Linking Exception. For full terms see the included COPYING file.
|
||||||
*/
|
*/
|
||||||
|
#ifndef INCLUDE_git_utfconv_h__
|
||||||
|
#define INCLUDE_git_utfconv_h__
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifndef INCLUDE_git_utfconv_h__
|
|
||||||
#define INCLUDE_git_utfconv_h__
|
|
||||||
|
|
||||||
/* Maximum characters in a Windows path plus one for NUL byte */
|
/* Maximum characters in a Windows path plus one for NUL byte */
|
||||||
#define GIT_WIN_PATH_UTF16 (260 + 1)
|
#define GIT_WIN_PATH_UTF16 (260 + 1)
|
||||||
|
|
||||||
@ -19,6 +18,8 @@
|
|||||||
|
|
||||||
typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16];
|
typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16];
|
||||||
|
|
||||||
|
typedef char git_win32_path_as_utf8[GIT_WIN_PATH_UTF8];
|
||||||
|
|
||||||
/* dest_size is the size of dest in wchar_t's */
|
/* dest_size is the size of dest in wchar_t's */
|
||||||
int git__utf8_to_16(wchar_t * dest, size_t dest_size, const char *src);
|
int git__utf8_to_16(wchar_t * dest, size_t dest_size, const char *src);
|
||||||
/* dest_size is the size of dest in char's */
|
/* dest_size is the size of dest in char's */
|
||||||
@ -29,7 +30,7 @@ GIT_INLINE(int) git_win32_path_from_c(git_win32_path dest, const char *src)
|
|||||||
return git__utf8_to_16(dest, GIT_WIN_PATH_UTF16, src);
|
return git__utf8_to_16(dest, GIT_WIN_PATH_UTF16, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
GIT_INLINE(int) git_win32_path_to_c(char *dest, const git_win32_path src)
|
GIT_INLINE(int) git_win32_path_to_c(git_win32_path_as_utf8 dest, const wchar_t *src)
|
||||||
{
|
{
|
||||||
return git__utf16_to_8(dest, GIT_WIN_PATH_UTF8, src);
|
return git__utf16_to_8(dest, GIT_WIN_PATH_UTF8, src);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user