]> Cypherpunks repositories - gostls13.git/commitdiff
Chdir
authorRuss Cox <rsc@golang.org>
Tue, 7 Apr 2009 07:40:36 +0000 (00:40 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 7 Apr 2009 07:40:36 +0000 (00:40 -0700)
R=r
DELTA=17  (17 added, 0 deleted, 0 changed)
OCL=27146
CL=27153

src/lib/os/file.go
src/lib/syscall/file_darwin.go
src/lib/syscall/file_linux.go

index 3010deeab71e7015d2a17d97e2b1788af616e2c9..48daf0bce474b8548d40b17c6306ae0245d28d7d 100644 (file)
@@ -261,3 +261,9 @@ func (file *File) Readdir(count int) (dirs []Dir, err *os.Error) {
        return
 }
 
+// Chdir changes the current working directory to the named directory.
+func Chdir(dir string) *os.Error {
+       r, e := syscall.Chdir(dir);
+       return ErrnoToError(e);
+}
+
index 5d128f743ce4d38ea6a04565a9baf09d2b912b7f..b0777b5df4aeda70d58e3d4b3be23f6623fdd690 100644 (file)
@@ -98,3 +98,9 @@ func Getdirentries(fd int64, buf *byte, nbytes int64, basep *int64) (ret int64,
        r1, r2, err := Syscall6(SYS_GETDIRENTRIES64, fd, int64(uintptr(unsafe.Pointer(buf))), nbytes, int64(uintptr(unsafe.Pointer(basep))), 0, 0);
        return r1, err;
 }
+
+func Chdir(dir string) (ret int64, errno int64) {
+       namebuf := StringBytePtr(dir);
+       r1, r2, err := Syscall(SYS_CHDIR, int64(uintptr(unsafe.Pointer(namebuf))), 0, 0);
+       return r1, err;
+}
index ceb0a85d7694312618de059c07701941facbe8ef..9bf4408846d5e64c32710279e03f82e012301fa6 100644 (file)
@@ -100,3 +100,8 @@ func Getdents(fd int64, buf *Dirent, nbytes int64) (ret int64, errno int64) {
        return r1, err;
 }
 
+func Chdir(dir string) (ret int64, errno int64) {
+       namebuf := StringBytePtr(dir);
+       r1, r2, err := Syscall(SYS_CHDIR, int64(uintptr(unsafe.Pointer(namebuf))), 0, 0);
+       return r1, err;
+}