Skip to content

Commit

Permalink
cwd plus crude implementations of $*CWD, chdir.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Jan 17, 2012
1 parent ad5617d commit 3649559
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/Builtins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,14 @@ public static void path_unlink(string path) {
File.Delete(path);
}

public static string cwd_path() {
return Directory.GetCurrentDirectory();
}

public static void path_chdir(string path) {
Directory.SetCurrentDirectory(path);
}

public static void path_mkdir(string path) {
Directory.CreateDirectory(path);
}
Expand Down
15 changes: 14 additions & 1 deletion lib/CORE.setting
Original file line number Diff line number Diff line change
Expand Up @@ -2955,9 +2955,21 @@ sub unlink(*@filenames) is unsafe {
True; # is there a way to actually detect problems with File.Delete?
}
sub cwd() is unsafe {
Q:CgOp { (box Str (cwd_path)) };
}
sub chdir($filename) is unsafe {
my $ok_code = True;
Q:CgOp { (rnull (path_chdir (obj_getstr {$filename}))) };
$PROCESS::CWD ::= Q:CgOp { (box Str (cwd_path)) };
CATCH { $ok_code = False; }
$ok_code;
}
sub mkdir($filename) is unsafe {
Q:CgOp { (rnull (path_mkdir (obj_getstr {$filename}))) };
True; # is there a way to actually detect problems with File.Delete?
True; # is there a way to actually detect problems with path_mkdir?
}
sub shell($command) is unsafe {
Expand Down Expand Up @@ -3045,6 +3057,7 @@ INIT {
$PROCESS::PROGRAM_NAME ::= Q:CgOp { (sysquery (i 1)) };
$PROCESS::BASE_DIRECTORY ::= Q:CgOp { (sysquery (i 3)) };
$PROCESS::OS ::= Q:CgOp { (sysquery (i 5)) };
$PROCESS::CWD ::= Q:CgOp { (box Str (cwd_path)) };
@GLOBAL::INC = ();
}
# }}}
Expand Down

0 comments on commit 3649559

Please sign in to comment.