pax_global_header00006660000000000000000000000064140412734010014506gustar00rootroot0000000000000052 comment=ba95caf97c0b346727855dcc13d9cee7d44180e5 atime-1.1.0/000077500000000000000000000000001404127340100126045ustar00rootroot00000000000000atime-1.1.0/.travis.yml000066400000000000000000000013171404127340100147170ustar00rootroot00000000000000language: go go: - tip before_install: - 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; fi script: - '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || $HOME/gopath/bin/goveralls -service=travis-ci -repotoken $COVERALLS_TOKEN' - "$HOME/gopath/bin/golint ./..." - go vet - go test -bench=.* -v ./... notifications: email: on_success: never on_failure: change env: global: secure: MnwmqgePnDx0t5Ehrp2kLqnuaOh8JxQ9ebaA3KFE3q1TAGVJlv6mHJGFsP+gtC6DIpqosPlZf4JeuMHN+9eLOpa/8E+c9Rl0gctgMpZssgNEAfsqwy7+KBhqLsWKa9NetSB3ZhZit9KLknx8AmjpQCYUcc+n2KN6W4bkbebIp3o= atime-1.1.0/LICENSE000066400000000000000000000020641404127340100136130ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Dustin H Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. atime-1.1.0/README.md000066400000000000000000000024751404127340100140730ustar00rootroot00000000000000atime ========== [![GoDoc](https://godoc.org/github.com/djherbis/atime?status.svg)](https://godoc.org/github.com/djherbis/atime) [![Release](https://img.shields.io/github/release/djherbis/atime.svg)](https://github.com/djherbis/atime/releases/latest) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.txt) [![Build Status](https://travis-ci.org/djherbis/atime.svg?branch=master)](https://travis-ci.org/djherbis/atime) [![Coverage Status](https://coveralls.io/repos/djherbis/atime/badge.svg?branch=master)](https://coveralls.io/r/djherbis/atime?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/djherbis/atime)](https://goreportcard.com/report/github.com/djherbis/atime) [![Sourcegraph](https://sourcegraph.com/github.com/djherbis/atime/-/badge.svg)](https://sourcegraph.com/github.com/djherbis/atime?badge) Usage ------------ File Access Times for #golang Looking for ctime or btime? Checkout https://github.com/djherbis/times Go has a hidden atime function for most platforms, this repo makes it accessible. ```go package main import ( "log" "github.com/djherbis/atime" ) func main() { at, err := atime.Stat("myfile") if err != nil { log.Fatal(err.Error()) } log.Println(at) } ``` Installation ------------ ```sh go get github.com/djherbis/atime ``` atime-1.1.0/atime_darwin.go000066400000000000000000000007171404127340100156030ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_darwin.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec) } atime-1.1.0/atime_dragonfly.go000066400000000000000000000007151404127340100163020ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_dragonfly.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) } atime-1.1.0/atime_freebsd.go000066400000000000000000000007201404127340100157230ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_freebsd.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec) } atime-1.1.0/atime_linux.go000066400000000000000000000007111404127340100154500ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_linux.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) } atime-1.1.0/atime_nacl.go000066400000000000000000000007111404127340100152260ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_nacl.go package atime import ( "os" "syscall" "time" ) func timespecToTime(sec, nsec int64) time.Time { return time.Unix(sec, nsec) } func atime(fi os.FileInfo) time.Time { st := fi.Sys().(*syscall.Stat_t) return timespecToTime(st.Atime, st.AtimeNsec) } atime-1.1.0/atime_netbsd.go000066400000000000000000000007171404127340100155760ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_netbsd.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atimespec) } atime-1.1.0/atime_openbsd.go000066400000000000000000000007131404127340100157450ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_openbsd.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) } atime-1.1.0/atime_plan9.go000066400000000000000000000005301404127340100153330ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_plan9.go package atime import ( "os" "time" ) func atime(fi os.FileInfo) time.Time { return time.Unix(int64(fi.Sys().(*syscall.Dir).Atime), 0) } atime-1.1.0/atime_solaris.go000066400000000000000000000007131404127340100157670ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_solaris.go package atime import ( "os" "syscall" "time" ) func timespecToTime(ts syscall.Timespec) time.Time { return time.Unix(int64(ts.Sec), int64(ts.Nsec)) } func atime(fi os.FileInfo) time.Time { return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) } atime-1.1.0/atime_test.go000066400000000000000000000016201404127340100152700ustar00rootroot00000000000000package atime import ( "io/ioutil" "os" "testing" "time" ) func TestStat(t *testing.T) { f, err := ioutil.TempFile("", "") et := time.Now().Add(-time.Second) if err != nil { t.Error(err.Error()) } defer os.Remove(f.Name()) defer f.Close() at, err := Stat(f.Name()) if err != nil { t.Error(err.Error()) } if at.Before(et) { t.Errorf("expected atime to be recent: got %v instead of ~%v", at, et) } } func TestGet(t *testing.T) { f, err := ioutil.TempFile("", "") et := time.Now().Add(-time.Second) if err != nil { t.Error(err.Error()) } defer os.Remove(f.Name()) defer f.Close() fi, err := os.Stat(f.Name()) if err != nil { t.Error(err.Error()) } at := Get(fi) if at.Before(et) { t.Errorf("expected atime to be recent: got %v instead of ~%v", at, et) } } func TestStatErr(t *testing.T) { _, err := Stat("badfile?") if err == nil { t.Error("expected an error") } } atime-1.1.0/atime_wasm.go000066400000000000000000000007151404127340100152640ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_js.go package atime import ( "os" "syscall" "time" ) func timespecToTime(sec, nsec int64) time.Time { return time.Unix(sec, nsec) } func atime(fi os.FileInfo) time.Time { stat := fi.Sys().(*syscall.Stat_t) return timespecToTime(stat.Atime, stat.AtimeNsec) } atime-1.1.0/atime_windows.go000066400000000000000000000006101404127340100160010ustar00rootroot00000000000000// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // http://golang.org/src/os/stat_windows.go package atime import ( "os" "syscall" "time" ) func atime(fi os.FileInfo) time.Time { return time.Unix(0, fi.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds()) } atime-1.1.0/go.mod000066400000000000000000000000521404127340100137070ustar00rootroot00000000000000module github.com/djherbis/atime go 1.16 atime-1.1.0/stat.go000066400000000000000000000006651404127340100141150ustar00rootroot00000000000000// Package atime provides a platform-independent way to get atimes for files. package atime import ( "os" "time" ) // Get returns the Last Access Time for the given FileInfo func Get(fi os.FileInfo) time.Time { return atime(fi) } // Stat returns the Last Access Time for the given filename func Stat(name string) (time.Time, error) { fi, err := os.Stat(name) if err != nil { return time.Time{}, err } return atime(fi), nil }