Skip to content

Commit f653043

Browse files
committed
win32: stop inlining file_attribute_to_stat
Move `git_win32__file_attribute_to_stat` to a regular function instead of an inlined function. This helps avoid header ordering issues and declarations.
1 parent b11eb08 commit f653043

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

src/win32/w32_util.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,34 @@ int git_win32__hidden(bool *out, const char *path)
9393
*out = (attrs & FILE_ATTRIBUTE_HIDDEN) ? true : false;
9494
return 0;
9595
}
96+
97+
int git_win32__file_attribute_to_stat(
98+
struct stat *st,
99+
const WIN32_FILE_ATTRIBUTE_DATA *attrdata,
100+
const wchar_t *path)
101+
{
102+
git_win32__stat_init(st,
103+
attrdata->dwFileAttributes,
104+
attrdata->nFileSizeHigh,
105+
attrdata->nFileSizeLow,
106+
attrdata->ftCreationTime,
107+
attrdata->ftLastAccessTime,
108+
attrdata->ftLastWriteTime);
109+
110+
if (attrdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && path) {
111+
git_win32_path target;
112+
113+
if (git_win32_path_readlink_w(target, path) >= 0) {
114+
st->st_mode = (st->st_mode & ~S_IFMT) | S_IFLNK;
115+
116+
/* st_size gets the UTF-8 length of the target name, in bytes,
117+
* not counting the NULL terminator */
118+
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
119+
git_error_set(GIT_ERROR_OS, "could not convert reparse point name for '%ls'", path);
120+
return -1;
121+
}
122+
}
123+
}
124+
125+
return 0;
126+
}

src/win32/w32_util.h

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ extern int git_win32__set_hidden(const char *path, bool hidden);
5959
*/
6060
extern int git_win32__hidden(bool *hidden, const char *path);
6161

62+
extern int git_win32__file_attribute_to_stat(
63+
struct stat *st,
64+
const WIN32_FILE_ATTRIBUTE_DATA *attrdata,
65+
const wchar_t *path);
66+
6267
/**
6368
* Converts a FILETIME structure to a struct timespec.
6469
*
@@ -136,35 +141,4 @@ GIT_INLINE(void) git_win32__file_information_to_stat(
136141
fileinfo->ftLastWriteTime);
137142
}
138143

139-
GIT_INLINE(int) git_win32__file_attribute_to_stat(
140-
struct stat *st,
141-
const WIN32_FILE_ATTRIBUTE_DATA *attrdata,
142-
const wchar_t *path)
143-
{
144-
git_win32__stat_init(st,
145-
attrdata->dwFileAttributes,
146-
attrdata->nFileSizeHigh,
147-
attrdata->nFileSizeLow,
148-
attrdata->ftCreationTime,
149-
attrdata->ftLastAccessTime,
150-
attrdata->ftLastWriteTime);
151-
152-
if (attrdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && path) {
153-
git_win32_path target;
154-
155-
if (git_win32_path_readlink_w(target, path) >= 0) {
156-
st->st_mode = (st->st_mode & ~S_IFMT) | S_IFLNK;
157-
158-
/* st_size gets the UTF-8 length of the target name, in bytes,
159-
* not counting the NULL terminator */
160-
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
161-
git_error_set(GIT_ERROR_OS, "could not convert reparse point name for '%ls'", path);
162-
return -1;
163-
}
164-
}
165-
}
166-
167-
return 0;
168-
}
169-
170144
#endif

0 commit comments

Comments
 (0)