-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dd3970
commit abb4792
Showing
10 changed files
with
653 additions
and
1 deletion.
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
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
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,29 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "diskcas", | ||
srcs = [ | ||
"atim_darwin.go", | ||
"atim_linux.go", | ||
"atim_windows.go", | ||
"diskcas.go", | ||
], | ||
importpath = "github.com/bazelbuild/remote-apis-sdks/go/pkg/diskcas", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//go/pkg/digest", | ||
"@com_github_golang_glog//:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "diskcas_test", | ||
srcs = ["diskcas_test.go"], | ||
embed = [":diskcas"], | ||
deps = [ | ||
"//go/pkg/digest", | ||
"//go/pkg/testutil", | ||
"@com_github_pborman_uuid//:go_default_library", | ||
"@org_golang_x_sync//errgroup:go_default_library", | ||
], | ||
) |
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,16 @@ | ||
// Utility to get the last accessed time on Darwin. | ||
package diskcas | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func GetLastAccessTime(path string) (time.Time, error) { | ||
info, err := os.Stat(path) | ||
if err != nil { | ||
return time.Time{}, err | ||
} | ||
return time.Unix(info.Sys().(*syscall.Stat_t).Atimespec.Unix()), 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Utility to get the last accessed time on Linux. | ||
package diskcas | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func GetLastAccessTime(path string) (time.Time, error) { | ||
info, err := os.Stat(path) | ||
if err != nil { | ||
return time.Time{}, err | ||
} | ||
return time.Unix(info.Sys().(*syscall.Stat_t).Atim.Unix()), 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Utility to get the last accessed time on Windows. | ||
package diskcas | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
// This will return correct values only if `fsutil behavior set disablelastaccess 0` is set. | ||
// Tracking of last access time is disabled by default on Windows. | ||
func GetLastAccessTime(path string) (time.Time, error) { | ||
info, err := os.Stat(path) | ||
if err != nil { | ||
return time.Time{}, err | ||
} | ||
return time.Unix(0, info.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds()), nil | ||
} |
Oops, something went wrong.