mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
parent
ecc24428ac
commit
b628ec5054
@ -1,13 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Syncthing Authors.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package fs
|
|
||||||
|
|
||||||
func newBasicRealCaser(fs Filesystem) realCaser {
|
|
||||||
return newDefaultRealCaser(fs)
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
// Copyright (C) 2020 The Syncthing Authors.
|
|
||||||
//
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package fs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
type basicRealCaserWindows struct {
|
|
||||||
uri string
|
|
||||||
}
|
|
||||||
|
|
||||||
func newBasicRealCaser(fs Filesystem) realCaser {
|
|
||||||
return &basicRealCaserWindows{fs.URI()}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RealCase returns the correct case for the given name, which is a relative
|
|
||||||
// path below root, as it exists on disk.
|
|
||||||
func (r *basicRealCaserWindows) realCase(name string) (string, error) {
|
|
||||||
if name == "." {
|
|
||||||
return ".", nil
|
|
||||||
}
|
|
||||||
path := r.uri
|
|
||||||
comps := strings.Split(name, string(PathSeparator))
|
|
||||||
var err error
|
|
||||||
for i, comp := range comps {
|
|
||||||
path = filepath.Join(path, comp)
|
|
||||||
comps[i], err = r.realCaseBase(path)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filepath.Join(comps...), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*basicRealCaserWindows) realCaseBase(path string) (string, error) {
|
|
||||||
p, err := syscall.UTF16PtrFromString(fixLongPath(path))
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
var fd syscall.Win32finddata
|
|
||||||
h, err := syscall.FindFirstFile(p, &fd)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
syscall.FindClose(h)
|
|
||||||
return syscall.UTF16ToString(fd.FileName[:]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *basicRealCaserWindows) dropCache() {}
|
|
@ -74,12 +74,7 @@ func NewCaseFilesystem(fs Filesystem) Filesystem {
|
|||||||
}
|
}
|
||||||
caseFs := &caseFilesystem{
|
caseFs := &caseFilesystem{
|
||||||
Filesystem: fs,
|
Filesystem: fs,
|
||||||
}
|
realCaser: newDefaultRealCaser(fs),
|
||||||
switch k.fstype {
|
|
||||||
case FilesystemTypeBasic:
|
|
||||||
caseFs.realCaser = newBasicRealCaser(fs)
|
|
||||||
default:
|
|
||||||
caseFs.realCaser = newDefaultRealCaser(fs)
|
|
||||||
}
|
}
|
||||||
caseFilesystems[k] = caseFs
|
caseFilesystems[k] = caseFs
|
||||||
return caseFs
|
return caseFs
|
||||||
|
Loading…
Reference in New Issue
Block a user