2009-09-16 12:20:18 +04:00
|
|
|
#ifndef WIN32_H
|
|
|
|
#define WIN32_H
|
|
|
|
|
2008-09-27 12:43:01 +04:00
|
|
|
/* common Win32 functions for MinGW and Cygwin */
|
2013-05-02 23:26:08 +04:00
|
|
|
#ifndef GIT_WINDOWS_NATIVE /* Not defined for Cygwin */
|
2008-09-27 12:43:01 +04:00
|
|
|
#include <windows.h>
|
2009-09-16 12:20:26 +04:00
|
|
|
#endif
|
2008-09-27 12:43:01 +04:00
|
|
|
|
2018-04-24 00:20:00 +03:00
|
|
|
extern int file_attr_to_st_mode (DWORD attr, DWORD tag, const char *path);
|
2008-09-27 12:43:01 +04:00
|
|
|
|
|
|
|
static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fdata)
|
|
|
|
{
|
|
|
|
if (GetFileAttributesExA(fname, GetFileExInfoStandard, fdata))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (GetLastError()) {
|
|
|
|
case ERROR_ACCESS_DENIED:
|
|
|
|
case ERROR_SHARING_VIOLATION:
|
|
|
|
case ERROR_LOCK_VIOLATION:
|
|
|
|
case ERROR_SHARING_BUFFER_EXCEEDED:
|
|
|
|
return EACCES;
|
|
|
|
case ERROR_BUFFER_OVERFLOW:
|
|
|
|
return ENAMETOOLONG;
|
|
|
|
case ERROR_NOT_ENOUGH_MEMORY:
|
|
|
|
return ENOMEM;
|
|
|
|
default:
|
|
|
|
return ENOENT;
|
|
|
|
}
|
|
|
|
}
|
2009-09-16 12:20:18 +04:00
|
|
|
|
|
|
|
#endif
|