Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/compat/win32.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / compat / win32.h` 43 lines ยท 991 bytes Raw Blame History 1 #ifndef WIN32_H 2 #define WIN32_H 3 4 /* common Win32 functions for MinGW and Cygwin */ 5 #ifndef GIT_WINDOWS_NATIVE /* Not defined for Cygwin */ 6 #include 7 #endif 8 9 static inline int file_attr_to_st_mode (DWORD attr, DWORD tag) 10 { 11 int fMode = S_IREAD; 12 if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) && tag == IO_REPARSE_TAG_SYMLINK) 13 fMode |= S_IFLNK; 14 else if (attr & FILE_ATTRIBUTE_DIRECTORY) 15 fMode |= S_IFDIR; 16 else 17 fMode |= S_IFREG; 18 if (!(attr & FILE_ATTRIBUTE_READONLY)) 19 fMode |= S_IWRITE; 20 return fMode; 21 } 22 23 static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fdata) 24 { 25 if (GetFileAttributesExA(fname, GetFileExInfoStandard, fdata)) 26 return 0; 27 28 switch (GetLastError()) { 29 case ERROR_ACCESS_DENIED: 30 case ERROR_SHARING_VIOLATION: 31 case ERROR_LOCK_VIOLATION: 32 case ERROR_SHARING_BUFFER_EXCEEDED: 33 return EACCES; 34 case ERROR_BUFFER_OVERFLOW: 35 return ENAMETOOLONG; 36 case ERROR_NOT_ENOUGH_MEMORY: 37 return ENOMEM; 38 default: 39 return ENOENT; 40 } 41 } 42 43 #endif