sysfs: return st instead of accepting it (#1261)

This returns stat as a value instead of a pointer param. This is both
more efficient and faster. It is also more efficient than returning a
pointer to a stat.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-03-21 10:57:19 +08:00
committed by GitHub
parent 57c887113e
commit c46a6eb4ae
24 changed files with 333 additions and 308 deletions

View File

@@ -140,9 +140,9 @@ func testChmod(t *testing.T, testFS FS, path string) {
}
func requireMode(t *testing.T, testFS FS, path string, mode fs.FileMode) {
var stat platform.Stat_t
require.NoError(t, testFS.Stat(path, &stat))
require.Equal(t, mode, stat.Mode.Perm())
st, err := testFS.Stat(path)
require.NoError(t, err)
require.Equal(t, mode, st.Mode.Perm())
}
func TestDirFS_Rename(t *testing.T) {
@@ -638,8 +638,8 @@ func TestDirFS_Utimesns(t *testing.T) {
panic(tc)
}
var oldSt platform.Stat_t
require.NoError(t, testFS.Lstat(statPath, &oldSt))
oldSt, err := testFS.Lstat(statPath)
require.NoError(t, err)
err = testFS.Utimens(path, tc.times, !symlinkNoFollow)
if symlinkNoFollow && !platform.SupportsSymlinkNoFollow {
@@ -648,8 +648,8 @@ func TestDirFS_Utimesns(t *testing.T) {
}
require.NoError(t, err)
var newSt platform.Stat_t
require.NoError(t, testFS.Lstat(statPath, &newSt))
newSt, err := testFS.Lstat(statPath)
require.NoError(t, err)
if platform.CompilerSupported() {
if tc.times != nil && tc.times[0].Nsec == platform.UTIME_OMIT {
@@ -711,8 +711,8 @@ func TestDirFS_Stat(t *testing.T) {
name := `e:xperi\ment.txt`
require.NoError(t, os.WriteFile(path.Join(tmpDir, name), nil, 0o600))
var st platform.Stat_t
require.NoError(t, testFS.Stat(name, &st))
_, err := testFS.Stat(name)
require.NoError(t, err)
})
}
}