1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-03 09:03:50 +00:00

vendor: update dependencies to latest

This commit is contained in:
Nick Craig-Wood
2018-11-24 15:31:25 +00:00
parent 58f7141c96
commit 89625e54cf
173 changed files with 4954 additions and 2224 deletions

View File

@@ -1,8 +1,8 @@
language: go
go:
- 1.5
- tip
before_install:
- go get github.com/golang/lint/golint
- go get -u golang.org/x/lint/golint
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover;

View File

@@ -7,6 +7,7 @@ times
[![Build Status](https://travis-ci.org/djherbis/times.svg?branch=master)](https://travis-ci.org/djherbis/times)
[![Coverage Status](https://coveralls.io/repos/djherbis/times/badge.svg?branch=master)](https://coveralls.io/r/djherbis/times?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/djherbis/times)](https://goreportcard.com/report/github.com/djherbis/times)
[![Sourcegraph](https://sourcegraph.com/github.com/djherbis/times/-/badge.svg)](https://sourcegraph.com/github.com/djherbis/times?badge)
Usage
------------

View File

@@ -7,6 +7,26 @@ import (
"unsafe"
)
// Stat returns the Timespec for the given filename.
func Stat(name string) (Timespec, error) {
ts, err := platformSpecficStat(name)
if err == nil {
return ts, err
}
return stat(name, os.Stat)
}
// Lstat returns the Timespec for the given filename, and does not follow Symlinks.
func Lstat(name string) (Timespec, error) {
ts, err := platformSpecficLstat(name)
if err == nil {
return ts, err
}
return stat(name, os.Lstat)
}
type timespecEx struct {
atime
mtime
@@ -33,20 +53,54 @@ func statFile(h syscall.Handle) (Timespec, error) {
return t, nil
}
const hasPlatformSpecificStat = true
func platformSpecficLstat(name string) (Timespec, error) {
if findProcErr != nil {
return nil, findProcErr
}
isSym, err := isSymlink(name)
if err != nil {
return nil, err
}
var attrs = uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS)
if isSym {
attrs |= syscall.FILE_FLAG_OPEN_REPARSE_POINT
}
return openHandleAndStat(name, attrs)
}
func isSymlink(name string) (bool, error) {
fi, err := os.Lstat(name)
if err != nil {
return false, err
}
return fi.Mode()&os.ModeSymlink != 0, nil
}
func platformSpecficStat(name string) (Timespec, error) {
if findProcErr != nil {
return nil, findProcErr
}
f, err := os.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
return openHandleAndStat(name, syscall.FILE_FLAG_BACKUP_SEMANTICS)
}
return statFile(syscall.Handle(f.Fd()))
func openHandleAndStat(name string, attrs uint32) (Timespec, error) {
pathp, e := syscall.UTF16PtrFromString(name)
if e != nil {
return nil, e
}
h, e := syscall.CreateFile(pathp,
syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil,
syscall.OPEN_EXISTING, attrs, 0)
if e != nil {
return nil, e
}
defer syscall.Close(h)
return statFile(h)
}
var (

View File

@@ -11,15 +11,10 @@ func Get(fi os.FileInfo) Timespec {
return getTimespec(fi)
}
// Stat returns the Timespec for the given filename.
func Stat(name string) (Timespec, error) {
if hasPlatformSpecificStat {
if ts, err := platformSpecficStat(name); err == nil {
return ts, nil
}
}
type statFunc func(string) (os.FileInfo, error)
fi, err := os.Stat(name)
func stat(name string, sf statFunc) (Timespec, error) {
fi, err := sf(name)
if err != nil {
return nil, err
}

View File

@@ -2,9 +2,14 @@
package times
const hasPlatformSpecificStat = false
import "os"
// do not use, only here to prevent "undefined" method error.
func platformSpecficStat(name string) (Timespec, error) {
return nil, nil
// Stat returns the Timespec for the given filename.
func Stat(name string) (Timespec, error) {
return stat(name, os.Stat)
}
// Lstat returns the Timespec for the given filename, and does not follow Symlinks.
func Lstat(name string) (Timespec, error) {
return stat(name, os.Lstat)
}