-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added partial FreeBSD support for fsutil and system packages
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build darwin, !linux, !windows | ||
// +build darwin | ||
|
||
package fsutil | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// +build freebsd | ||
|
||
package fsutil | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2009-2016 Essential Kaos // | ||
// Essential Kaos Open Source License <http://essentialkaos.com/ekol?en> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"errors" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// GetTimes return time of access, modification and creation at once | ||
func GetTimes(path string) (time.Time, time.Time, time.Time, error) { | ||
if path == "" { | ||
return time.Time{}, time.Time{}, time.Time{}, errors.New("Path is empty") | ||
} | ||
|
||
var stat = &syscall.Stat_t{} | ||
|
||
err := syscall.Stat(path, stat) | ||
|
||
if err != nil { | ||
return time.Time{}, time.Time{}, time.Time{}, err | ||
} | ||
|
||
return time.Unix(int64(stat.Atimespec.Sec), int64(stat.Atimespec.Nsec)), | ||
time.Unix(int64(stat.Mtimespec.Sec), int64(stat.Mtimespec.Nsec)), | ||
time.Unix(int64(stat.Ctimespec.Sec), int64(stat.Ctimespec.Nsec)), | ||
nil | ||
} | ||
|
||
// GetTimestamps return time of access, modification and creation at once as linux timestamp | ||
func GetTimestamps(path string) (int64, int64, int64, error) { | ||
if path == "" { | ||
return -1, -1, -1, errors.New("Path is empty") | ||
} | ||
|
||
var stat = &syscall.Stat_t{} | ||
|
||
err := syscall.Stat(path, stat) | ||
|
||
if err != nil { | ||
return -1, -1, -1, err | ||
} | ||
|
||
return int64(stat.Atimespec.Sec), | ||
int64(stat.Mtimespec.Sec), | ||
int64(stat.Ctimespec.Sec), | ||
nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build linux, !darwin, !windows | ||
// +build linux | ||
|
||
package fsutil | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build windows, !linux, !darwin | ||
// +build windows | ||
|
||
package fsutil | ||
|
||
|