summaryrefslogtreecommitdiff
path: root/src/pkg/os/file_unix.go
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2010-04-26 23:17:14 -0700
committerAlex Brainman <alex.brainman@gmail.com>2010-04-26 23:17:14 -0700
commit6b2d5e7aa8b0f420b202812dd9f80fa6483d75d0 (patch)
tree1fbceb9f4e66688bc480c5dd97ba410d39ca82c4 /src/pkg/os/file_unix.go
parentd20df719a6abdc1bdf85a85aa3f86b449683c78d (diff)
downloadgolang-6b2d5e7aa8b0f420b202812dd9f80fa6483d75d0.tar.gz
os, syscall: more mingw
R=rsc, rsc1 CC=golang-dev http://codereview.appspot.com/878046 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/os/file_unix.go')
-rw-r--r--src/pkg/os/file_unix.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go
index 84ca48064..6cf266140 100644
--- a/src/pkg/os/file_unix.go
+++ b/src/pkg/os/file_unix.go
@@ -53,6 +53,17 @@ func (file *File) Close() Error {
return err
}
+// Stat returns the FileInfo structure describing file.
+// It returns the FileInfo and an error, if any.
+func (file *File) Stat() (fi *FileInfo, err Error) {
+ var stat syscall.Stat_t
+ e := syscall.Fstat(file.fd, &stat)
+ if e != 0 {
+ return nil, &PathError{"stat", file.name, Errno(e)}
+ }
+ return fileInfoFromStat(file.name, new(FileInfo), &stat, &stat), nil
+}
+
// Readdir reads the contents of the directory associated with file and
// returns an array of up to count FileInfo structures, as would be returned
// by Stat, in directory order. Subsequent calls on the same file will yield
@@ -80,3 +91,12 @@ func (file *File) Readdir(count int) (fi []FileInfo, err Error) {
}
return
}
+
+// Truncate changes the size of the named file.
+// If the file is a symbolic link, it changes the size of the link's target.
+func Truncate(name string, size int64) Error {
+ if e := syscall.Truncate(name, size); e != 0 {
+ return &PathError{"truncate", name, Errno(e)}
+ }
+ return nil
+}