2019-02-24 10:02:02 -07:00
|
|
|
// Copyright (C) 2017 The Syncthing Authors.
|
2019-01-25 01:52:21 -07:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2020-05-13 12:46:24 -07:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
)
|
2019-01-25 01:52:21 -07:00
|
|
|
|
2019-02-24 10:02:02 -07:00
|
|
|
func (e basicFileInfo) Mode() FileMode {
|
|
|
|
return FileMode(e.FileInfo.Mode())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e basicFileInfo) Owner() int {
|
2019-01-25 01:52:21 -07:00
|
|
|
if st, ok := e.Sys().(*syscall.Stat_t); ok {
|
|
|
|
return int(st.Uid)
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2019-02-24 10:02:02 -07:00
|
|
|
func (e basicFileInfo) Group() int {
|
2019-01-25 01:52:21 -07:00
|
|
|
if st, ok := e.Sys().(*syscall.Stat_t); ok {
|
|
|
|
return int(st.Gid)
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
2020-05-13 12:46:24 -07:00
|
|
|
|
|
|
|
// fileStat converts e to os.FileInfo that is suitable
|
|
|
|
// to be passed to os.SameFile. Non-trivial on Windows.
|
|
|
|
func (e *basicFileInfo) osFileInfo() os.FileInfo {
|
|
|
|
return e.FileInfo
|
|
|
|
}
|