OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris | 5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris |
6 | 6 |
7 package os | 7 package os |
8 | 8 |
9 import ( | 9 import ( |
10 "runtime" | 10 "runtime" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 b = b[:maxRW] | 235 b = b[:maxRW] |
236 } | 236 } |
237 return fixCount(syscall.Pwrite(f.fd, b, off)) | 237 return fixCount(syscall.Pwrite(f.fd, b, off)) |
238 } | 238 } |
239 | 239 |
240 // seek sets the offset for the next Read or Write on file to offset, interprete
d | 240 // seek sets the offset for the next Read or Write on file to offset, interprete
d |
241 // according to whence: 0 means relative to the origin of the file, 1 means | 241 // according to whence: 0 means relative to the origin of the file, 1 means |
242 // relative to the current offset, and 2 means relative to the end. | 242 // relative to the current offset, and 2 means relative to the end. |
243 // It returns the new offset and an error, if any. | 243 // It returns the new offset and an error, if any. |
244 func (f *File) seek(offset int64, whence int) (ret int64, err error) { | 244 func (f *File) seek(offset int64, whence int) (ret int64, err error) { |
245 » return fixCount(syscall.Seek(f.fd, offset, whence)) | 245 » return syscall.Seek(f.fd, offset, whence) |
246 } | 246 } |
247 | 247 |
248 // Truncate changes the size of the named file. | 248 // Truncate changes the size of the named file. |
249 // If the file is a symbolic link, it changes the size of the link's target. | 249 // If the file is a symbolic link, it changes the size of the link's target. |
250 // If there is an error, it will be of type *PathError. | 250 // If there is an error, it will be of type *PathError. |
251 func Truncate(name string, size int64) error { | 251 func Truncate(name string, size int64) error { |
252 if e := syscall.Truncate(name, size); e != nil { | 252 if e := syscall.Truncate(name, size); e != nil { |
253 return &PathError{"truncate", name, e} | 253 return &PathError{"truncate", name, e} |
254 } | 254 } |
255 return nil | 255 return nil |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 // Symlink creates newname as a symbolic link to oldname. | 330 // Symlink creates newname as a symbolic link to oldname. |
331 // If there is an error, it will be of type *LinkError. | 331 // If there is an error, it will be of type *LinkError. |
332 func Symlink(oldname, newname string) error { | 332 func Symlink(oldname, newname string) error { |
333 e := syscall.Symlink(oldname, newname) | 333 e := syscall.Symlink(oldname, newname) |
334 if e != nil { | 334 if e != nil { |
335 return &LinkError{"symlink", oldname, newname, e} | 335 return &LinkError{"symlink", oldname, newname, e} |
336 } | 336 } |
337 return nil | 337 return nil |
338 } | 338 } |
OLD | NEW |