Created
June 10, 2010 13:37
-
-
Save uasi/433005 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
# module OSUtils; | |
# Removed 'is export's | |
multi sub cwd() { | |
Q:PIR { | |
$P0 = root_new ['parrot';'OS'] | |
push_eh cwd_catch | |
$S0 = $P0.'cwd'() | |
%r = box $S0 | |
goto cwd_finally | |
cwd_catch: | |
%r = get_hll_global 'Any' | |
cwd_finally: | |
}; | |
} | |
multi sub chdir(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh chdir_catch | |
$P1.'chdir'($S0) | |
%r = get_hll_global 'True' | |
goto chdir_finally | |
chdir_catch: | |
%r = get_hll_global 'False' | |
chdir_finally: | |
}; | |
} | |
multi sub rm(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh rm_catch | |
$P1.'rm'($S0) | |
%r = get_hll_global 'True' | |
goto rm_finally | |
rm_catch: | |
%r = get_hll_global 'False' | |
rm_finally: | |
}; | |
} | |
multi sub mkdir(Str $path, Int $mode where { 0o000 <= $_ <= 0o777 }) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = find_lex '$mode' | |
$I0 = $P1 | |
$P2 = root_new ['parrot';'OS'] | |
push_eh mkdir_catch | |
$P2.'mkdir'($S0, $I0) | |
%r = get_hll_global 'True' | |
goto mkdir_finally | |
mkdir_catch: | |
%r = get_hll_global 'False' | |
mkdir_finally: | |
}; | |
} | |
multi sub stat(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh stat_catch | |
$P2 = $P1.'stat'($S0) | |
%r = '&infix:<,>'($P2 :flat) | |
goto stat_finally | |
stat_catch: | |
%r = get_hll_global 'Any' | |
stat_finally: | |
}; | |
} | |
multi sub lstat(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh lstat_catch | |
$P2 = $P1.'lstat'($S0) | |
%r = '&infix:<,>'($P2 :flat) | |
goto lstat_finally | |
lstat_catch: | |
%r = get_hll_global 'Any' | |
lstat_finally: | |
}; | |
} | |
multi sub symlink(Str $from, Str $to) { | |
Q:PIR { | |
$P0 = find_lex '$from' | |
$S0 = $P0 | |
$P1 = find_lex '$to' | |
$S1 = $P1 | |
$P2 = root_new ['parrot';'OS'] | |
push_eh symlink_catch | |
$P2.'symlink'($S0, $S1) | |
%r = get_hll_global 'True' | |
goto symlink_finally | |
symlink_catch: | |
%r = get_hll_global 'False' | |
symlink_finally: | |
}; | |
} | |
multi sub link(Str $from, Str $to) { | |
Q:PIR { | |
$P0 = find_lex '$from' | |
$S0 = $P0 | |
$P1 = find_lex '$to' | |
$S1 = $P1 | |
$P2 = root_new ['parrot';'OS'] | |
push_eh link_catch | |
$P2.'link'($S0, $S1) | |
%r = get_hll_global 'True' | |
goto link_finally | |
link_catch: | |
%r = get_hll_global 'False' | |
link_finally: | |
}; | |
} | |
multi sub umask(Int $mask where { 0o000 <= $_ <= 0o777 }) { | |
Q:PIR { | |
$P0 = find_lex '$mask' | |
$I0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh umask_catch | |
$P1.'umask'($I0) | |
%r = get_hll_global 'True' | |
goto umask_finally | |
umask_catch: | |
%r = get_hll_global 'False' | |
umask_finally: | |
}; | |
} | |
multi sub chroot(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh chroot_catch | |
$P1.'chroot'($S0) | |
%r = get_hll_global 'True' | |
goto chroot_finally | |
chroot_catch: | |
%r = get_hll_global 'False' | |
chroot_finally: | |
}; | |
} | |
multi sub readdir(Str $path) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = root_new ['parrot';'OS'] | |
push_eh readdir_catch | |
$P2 = $P1.'readdir'($S0) | |
%r = '&infix:<,>'($P2 :flat) | |
goto readdir_finally | |
readdir_catch: | |
%r = get_hll_global 'Any' | |
readdir_finally: | |
}; | |
} | |
multi sub rename(Str $oldpath, Str $newpath) { | |
Q:PIR { | |
$P0 = find_lex '$oldpath' | |
$S0 = $P0 | |
$P1 = find_lex '$newpath' | |
$S1 = $P1 | |
$P2 = root_new ['parrot';'OS'] | |
push_eh rename_catch | |
$P2.'rename'($S0, $S1) | |
%r = get_hll_global 'True' | |
goto rename_finally | |
rename_catch: | |
%r = get_hll_global 'False' | |
rename_finally: | |
}; | |
} | |
multi sub chmod(Str $path, Int $mode where { 0o000 <= $_ <= 0o777 }) { | |
Q:PIR { | |
$P0 = find_lex '$path' | |
$S0 = $P0 | |
$P1 = find_lex '$mode' | |
$I0 = $P1 | |
$P2 = root_new ['parrot';'OS'] | |
push_eh chmod_catch | |
$P2.'chmod'($S0, $I0) | |
%r = get_hll_global 'True' | |
goto chmod_finally | |
chmod_catch: | |
%r = get_hll_global 'False' | |
chmod_finally: | |
}; | |
} | |
# vim: ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment