-
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.
Merge pull request #13 from essentialkaos/develop
Version 1.4.1
- Loading branch information
Showing
13 changed files
with
136 additions
and
8 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 |
---|---|---|
|
@@ -9,6 +9,7 @@ sudo: false | |
os: | ||
- linux | ||
- osx | ||
- freebsd | ||
|
||
env: | ||
- EK_TEST_PORT=8080 | ||
|
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
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 | ||
|
||
|
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
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
File renamed without changes.
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 system | ||
|
||
|
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,63 @@ | ||
// +build freebsd | ||
|
||
package system | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
// // | ||
// Copyright (c) 2009-2016 Essential Kaos // | ||
// Essential Kaos Open Source License <http://essentialkaos.com/ekol?en> // | ||
// // | ||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os/exec" | ||
"strconv" | ||
"strings" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
// ////////////////////////////////////////////////////////////////////////////////// // | ||
|
||
// getTimes is copy of fsutil.GetTimes | ||
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 | ||
} | ||
|
||
// getUserInfo return user info by name or id (name, id, gid, comment, home, shell) | ||
// | ||
func getUserInfo(nameOrID string) (string, int, int, string, string, string, error) { | ||
cmd := exec.Command("getent", "passwd", nameOrID) | ||
|
||
out, err := cmd.Output() | ||
|
||
if err != nil { | ||
return "", -1, -1, "", "", "", fmt.Errorf("User with this name/id %s is not exist", nameOrID) | ||
} | ||
|
||
sOut := string(out[:]) | ||
sOut = strings.Trim(sOut, "\n") | ||
aOut := strings.Split(sOut, ":") | ||
|
||
uid, _ := strconv.Atoi(aOut[2]) | ||
gid, _ := strconv.Atoi(aOut[3]) | ||
|
||
return aOut[0], uid, gid, aOut[4], aOut[5], aOut[6], 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 system | ||
|
||
|
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 windows | ||
|
||
package system | ||
|
||
|