-#ifdef WIN32
- HANDLE handle;
- handle = CreateFile(path.str().c_str(), 0, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
- if(handle==INVALID_HANDLE_VALUE)
- {
- DWORD err = GetLastError();
- if(err==ERROR_FILE_NOT_FOUND)
- return Stat();
- else
- throw system_error("CreateFile", err);
- }
-
- BY_HANDLE_FILE_INFORMATION info;
- if(!GetFileInformationByHandle(handle, &info))
- {
- CloseHandle(handle);
- throw system_error("GetFileInformationByHandle");
- }
-
- Stat result;
- if(info.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
- result.type = DIRECTORY;
- else
- result.type = REGULAR;
-
- result.size = FileSize(info.nFileSizeHigh)<<32 | info.nFileSizeLow;
- result.alloc_size = (result.size+511)&~511;
- result.mtime = Time::TimeStamp(Time::filetime_to_rawtime(info.ftLastWriteTime));
-
- PSECURITY_DESCRIPTOR sec_desc;
- PSID owner = 0;
- PSID group = 0;
- if(!GetSecurityInfo(handle, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION, &owner, &group, 0, 0, &sec_desc))
- {
- CloseHandle(handle);
- throw system_error("GetSecurityInfo");
- }
-
- if(owner)
- result.owner = get_account_name(owner);
- if(group)
- result.group = get_account_name(group);
-
- LocalFree(sec_desc);
-
- CloseHandle(handle);
-
- return result;
-#else
- struct stat st;
- int ret = ::stat(path.str().c_str(), &st);
- if(ret==-1)
- {
- if(errno==ENOENT)
- return Stat();
- else
- throw system_error("stat");
- }
-
- return Private::from_struct_stat(st);
-#endif