func Read(path string) (string, uint32, error) { ptr, err := syscall.UTF16PtrFromString(path) if err != nil { return "", protocol.FlagSymlinkMissingTarget, err } handle, err := syscall.CreateFile(ptr, 0, syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, nil, syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT, 0) if err != nil || handle == syscall.InvalidHandle { return "", protocol.FlagSymlinkMissingTarget, err } defer syscall.Close(handle) var ret uint16 var data reparseData r1, _, err := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), FSCTL_GET_REPARSE_POINT, 0, 0, uintptr(unsafe.Pointer(&data)), unsafe.Sizeof(data), uintptr(unsafe.Pointer(&ret)), 0, 0) if r1 == 0 { return "", protocol.FlagSymlinkMissingTarget, err } var flags uint32 = 0 attr, err := syscall.GetFileAttributes(ptr) if err != nil { flags = protocol.FlagSymlinkMissingTarget } else if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 { flags = protocol.FlagDirectory } return osutil.NormalizedFilename(data.PrintName()), flags, nil }
func (s *FileSet) GetGlobalTruncated(file string) (FileInfoTruncated, bool) { fi, ok := ldbGetGlobal(s.db, []byte(s.folder), []byte(osutil.NormalizedFilename(file)), true) if !ok { return FileInfoTruncated{}, false } f := fi.(FileInfoTruncated) f.Name = osutil.NativeFilename(f.Name) return f, true }
func (s *FileSet) GetGlobal(file string) (protocol.FileInfo, bool) { fi, ok := ldbGetGlobal(s.db, []byte(s.folder), []byte(osutil.NormalizedFilename(file)), false) if !ok { return protocol.FileInfo{}, false } f := fi.(protocol.FileInfo) f.Name = osutil.NativeFilename(f.Name) return f, true }
func Read(path string) (string, uint32, error) { var mode uint32 stat, err := os.Stat(path) if err != nil { mode = protocol.FlagSymlinkMissingTarget } else if stat.IsDir() { mode = protocol.FlagDirectory } path, err = os.Readlink(path) return osutil.NormalizedFilename(path), mode, err }
func normalizeFilenames(fs []protocol.FileInfo) { for i := range fs { fs[i].Name = osutil.NormalizedFilename(fs[i].Name) } }
func (s *FileSet) Availability(file string) []protocol.DeviceID { return ldbAvailability(s.db, []byte(s.folder), []byte(osutil.NormalizedFilename(file))) }
func (s *FileSet) Get(device protocol.DeviceID, file string) (protocol.FileInfo, bool) { f, ok := ldbGet(s.db, []byte(s.folder), device[:], []byte(osutil.NormalizedFilename(file))) f.Name = osutil.NativeFilename(f.Name) return f, ok }
func (s *Set) GetGlobal(file string) protocol.FileInfo { f := ldbGetGlobal(s.db, []byte(s.folder), []byte(osutil.NormalizedFilename(file))) f.Name = osutil.NativeFilename(f.Name) return f }
func (s *FileSet) WithPrefixedGlobalTruncated(prefix string, fn Iterator) { if debug { l.Debugf("%s WithPrefixedGlobalTruncated()", s.folder, prefix) } ldbWithGlobal(s.db, []byte(s.folder), []byte(osutil.NormalizedFilename(prefix)), true, nativeFileIterator(fn)) }