Windows: Archive package changes for Windows daemon
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
24fd826fc0
commit
f883e81d79
11 changed files with 166 additions and 56 deletions
|
@ -2,7 +2,28 @@
|
|||
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Some explanation for my own sanity, and hopefully maintainers in the
|
||||
// future.
|
||||
//
|
||||
// Lstat calls os.Lstat to get a fileinfo interface back.
|
||||
// This is then copied into our own locally defined structure.
|
||||
// Note the Linux version uses fromStatT to do the copy back,
|
||||
// but that not strictly necessary when already in an OS specific module.
|
||||
|
||||
func Lstat(path string) (*Stat_t, error) {
|
||||
// should not be called on cli code path
|
||||
return nil, ErrNotSupportedPlatform
|
||||
fi, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Stat_t{
|
||||
name: fi.Name(),
|
||||
size: fi.Size(),
|
||||
mode: fi.Mode(),
|
||||
modTime: fi.ModTime(),
|
||||
isDir: fi.IsDir()}, nil
|
||||
}
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
package system
|
||||
|
||||
func Mknod(path string, mode uint32, dev int) error {
|
||||
// should not be called on cli code path
|
||||
return ErrNotSupportedPlatform
|
||||
}
|
||||
|
||||
func Mkdev(major int64, minor int64) uint32 {
|
||||
panic("Mkdev not implemented on windows, should not be called on cli code")
|
||||
panic("Mkdev not implemented on Windows.")
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// +build !windows
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
|
|
|
@ -3,15 +3,34 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func fromStatT(s *syscall.Win32FileAttributeData) (*Stat_t, error) {
|
||||
return nil, errors.New("fromStatT should not be called on windows path")
|
||||
type Stat_t struct {
|
||||
name string
|
||||
size int64
|
||||
mode os.FileMode
|
||||
modTime time.Time
|
||||
isDir bool
|
||||
}
|
||||
|
||||
func Stat(path string) (*Stat_t, error) {
|
||||
// should not be called on cli code path
|
||||
return nil, ErrNotSupportedPlatform
|
||||
func (s Stat_t) Name() string {
|
||||
return s.name
|
||||
}
|
||||
|
||||
func (s Stat_t) Size() int64 {
|
||||
return s.size
|
||||
}
|
||||
|
||||
func (s Stat_t) Mode() os.FileMode {
|
||||
return s.mode
|
||||
}
|
||||
|
||||
func (s Stat_t) ModTime() time.Time {
|
||||
return s.modTime
|
||||
}
|
||||
|
||||
func (s Stat_t) IsDir() bool {
|
||||
return s.isDir
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue