Giter VIP home page Giter VIP logo

times's People

Contributors

aklyachkin avatar djherbis avatar dthadi3 avatar flavio avatar gleich avatar golint-fixer avatar mateusz834 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

times's Issues

Return FileFinfo as well as TimeSpec with Stat and LStat functions.

Hello,
I have a usecase where i'm already calling Stat on the files on wich i have to also get the times for.
Would it be possible to add another set of Stat and LStat wich also return the Fileinfo they used?
Thanks!

I can help with the PR if you think this would be usefull.

times.Stat silently falls back to regular stat on Windows

If the platform specific stat fails, the error is silently swallowed and a regular (i.e noctime) stat result is returned:

times/ctime_windows.go

Lines 12 to 17 in fd6b033

ts, err := platformSpecficStat(name)
if err == nil {
return ts, err
}
return stat(name, os.Stat)

This can cause unexpected panics if the caller assumes the return value will be the platform-specific result:

panic: ctime not available

goroutine 108 [running]:
github.com/djherbis/times.noctime.ChangeTime(0xc000be0730, 0x0, 0x0)
	github.com/djherbis/[email protected]/times.go:68 +0x45
github.com/tmm1/myApp/app.createdAtFor(0xc002758075, 0x10, 0xc00138bd51, 0xf3, 0x30)

Any consideration to adding time updates to times package?

I have a need to update times on a file when I run and produce a log file. That is:

  • Look up a time,
  • Modify it in some way (compress it like logrotate might do), and
  • Change compressed file time to show original time

Basically, I want to be able to rotate old logs but preserve their time. While times allows me to look up the times, it does not allow me to update the times. Has this been considered?

Use Lstat instead of Stat?

Any thoughts on using os.Lstat instead of os.Stat? Stat tries to follow symlinks, giving the information about the target, as opposed to the file itself. This means:

  • you miss info about the link
  • if the target doesn't exist, error

Or maybe have it as an option?

Get(os.FileInfo) on Windows (7+) opens the file

Get(os.FileInfo) opens the file on Win 7+ in order to obtain the ChangeTime via a file handle (which is not directly available on the Go struct). This is both expensive, and potentially problematic (my tests so far show that it doesn't seem to affect any of the file times, but I don't really want to do excessive actions behind the scenes).

I'm considering turning this off for Get and only having it active for Stat. I think this makes sense since Get should not have to Open the file, and Get should only make use of the data inside os.FileInfo.

I'm considering making this a version change as well.

Any suggestions? Complaints? Comments?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.