mirror of
https://github.com/xiaoqidun/symfs.git
synced 2026-05-12 01:30:58 +08:00
Compare commits
2 Commits
3759059f3f
...
eeff36d167
| Author | SHA1 | Date | |
|---|---|---|---|
| eeff36d167 | |||
| 6612fcca2e |
@@ -253,7 +253,13 @@ func (s *SymFS) Write(path string, buff []byte, ofst int64, fh uint64) int {
|
|||||||
// 入参: path 路径, fh 文件句柄
|
// 入参: path 路径, fh 文件句柄
|
||||||
// 返回: int 错误码
|
// 返回: int 错误码
|
||||||
func (s *SymFS) Flush(path string, fh uint64) int {
|
func (s *SymFS) Flush(path string, fh uint64) int {
|
||||||
syscall.FlushFileBuffers(syscall.Handle(fh))
|
err := syscall.FlushFileBuffers(syscall.Handle(fh))
|
||||||
|
if err != nil {
|
||||||
|
if sysErr, ok := err.(syscall.Errno); ok && sysErr == syscall.ERROR_ACCESS_DENIED {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return errno(err)
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,9 +465,16 @@ func (s *SymFS) watch() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
headerSize := uint32(unsafe.Offsetof(FileNotifyInformation{}.FileName))
|
||||||
var offset uint32
|
var offset uint32
|
||||||
for {
|
for {
|
||||||
|
if offset+headerSize > bytesReturned {
|
||||||
|
break
|
||||||
|
}
|
||||||
info := (*FileNotifyInformation)(unsafe.Pointer(&buf[offset]))
|
info := (*FileNotifyInformation)(unsafe.Pointer(&buf[offset]))
|
||||||
|
if offset+headerSize+info.FileNameLength > bytesReturned {
|
||||||
|
break
|
||||||
|
}
|
||||||
length := info.FileNameLength / 2
|
length := info.FileNameLength / 2
|
||||||
nameSlice := (*[1 << 16]uint16)(unsafe.Pointer(&info.FileName[0]))[:length:length]
|
nameSlice := (*[1 << 16]uint16)(unsafe.Pointer(&info.FileName[0]))[:length:length]
|
||||||
fileName := syscall.UTF16ToString(nameSlice)
|
fileName := syscall.UTF16ToString(nameSlice)
|
||||||
|
|||||||
Reference in New Issue
Block a user