diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-07-06 15:38:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-07-06 15:38:18 -0700 |
commit | 71ee7fd15457a0252c089420b5b66de266dcbd2f (patch) | |
tree | 98d4d7d1f72c30fd7695f011be78d3e45158c41a /compat/win32.h | |
parent | Merge commit 'v1.6.0' into jc/checkout-reflog-fix (diff) | |
parent | Git 1.7.0 (diff) | |
download | tgif-71ee7fd15457a0252c089420b5b66de266dcbd2f.tar.xz |
Merge commit 'v1.7.0' into jc/checkout-reflog-fix
* commit 'v1.7.0': (4188 commits)
Git 1.7.0
Fix typo in 1.6.6.2 release notes
Re-fix check-ref-format documentation mark-up
archive documentation: attributes are taken from the tree by default
Documentation: minor fixes to RelNotes-1.7.0
bash: support 'git am's new '--continue' option
filter-branch: Fix error message for --prune-empty --commit-filter
am: switch --resolved to --continue
Update draft release notes to 1.7.0 one more time
Git 1.6.6.2
t8003: check exit code of command and error message separately
check-ref-format documentation: fix enumeration mark-up
Documentation: quote braces in {upstream} notation
t3902: Protect against OS X normalization
blame: prevent a segv when -L given start > EOF
git-push: document all the status flags used in the output
Fix parsing of imap.preformattedHTML and imap.sslverify
git-add documentation: Fix shell quoting example
Revert "pack-objects: fix pack generation when using pack_size_limit"
archive: simplify archive format guessing
...
Diffstat (limited to 'compat/win32.h')
-rw-r--r-- | compat/win32.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/compat/win32.h b/compat/win32.h new file mode 100644 index 0000000000..8ce91048de --- /dev/null +++ b/compat/win32.h @@ -0,0 +1,41 @@ +#ifndef WIN32_H +#define WIN32_H + +/* common Win32 functions for MinGW and Cygwin */ +#ifndef WIN32 /* Not defined by Cygwin */ +#include <windows.h> +#endif + +static inline int file_attr_to_st_mode (DWORD attr) +{ + int fMode = S_IREAD; + if (attr & FILE_ATTRIBUTE_DIRECTORY) + fMode |= S_IFDIR; + else + fMode |= S_IFREG; + if (!(attr & FILE_ATTRIBUTE_READONLY)) + fMode |= S_IWRITE; + return fMode; +} + +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; + } +} + +#endif |