mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 05:10:16 -05:00
Fix touching of files that in Windows have the read-only attribute set
This commit is contained in:
parent
abcea4d9f3
commit
e4aa186b1a
4 changed files with 57 additions and 0 deletions
|
|
@ -766,6 +766,31 @@ int windows_fstat(int fd, struct windows_stat* st)
|
|||
return windows_info2stat(&info, &tag, st);
|
||||
}
|
||||
|
||||
int windows_get_file_attributes(const char* file)
|
||||
{
|
||||
wchar_t conv_buf[CONV_MAX];
|
||||
|
||||
DWORD ret = GetFileAttributesW(convert(conv_buf, file));
|
||||
if (ret == INVALID_FILE_ATTRIBUTES) {
|
||||
windows_errno(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int windows_set_file_attributes(const char* file, int attributes)
|
||||
{
|
||||
wchar_t conv_buf[CONV_MAX];
|
||||
|
||||
if (!SetFileAttributesW(convert(conv_buf, file), attributes)) {
|
||||
windows_errno(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int windows_lstat(const char* file, struct windows_stat* st)
|
||||
{
|
||||
wchar_t conv_buf[CONV_MAX];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue