Skip to content

Commit 57da120

Browse files
committed
Add :tc to signatures for file ops.
1 parent 360e781 commit 57da120

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,15 +1900,15 @@ QAST::OperationsJAST.map_classlib_core_op('readallfh', $TYPE_OPS, 'readallfh', [
19001900
QAST::OperationsJAST.map_classlib_core_op('eoffh', $TYPE_OPS, 'eoffh', [$RT_OBJ], $RT_INT, :tc);
19011901
QAST::OperationsJAST.map_classlib_core_op('closefh', $TYPE_OPS, 'closefh', [$RT_OBJ], $RT_OBJ, :tc);
19021902

1903-
QAST::OperationsJAST.map_classlib_core_op('chmod', $TYPE_OPS, 'chmod', [$RT_STR, $RT_INT], $RT_INT);
1904-
QAST::OperationsJAST.map_classlib_core_op('unlink', $TYPE_OPS, 'unlink', [$RT_STR], $RT_INT);
1905-
QAST::OperationsJAST.map_classlib_core_op('rmdir', $TYPE_OPS, 'rmdir', [$RT_STR], $RT_INT);
1903+
QAST::OperationsJAST.map_classlib_core_op('chmod', $TYPE_OPS, 'chmod', [$RT_STR, $RT_INT], $RT_INT, :tc);
1904+
QAST::OperationsJAST.map_classlib_core_op('unlink', $TYPE_OPS, 'unlink', [$RT_STR], $RT_INT, :tc);
1905+
QAST::OperationsJAST.map_classlib_core_op('rmdir', $TYPE_OPS, 'rmdir', [$RT_STR], $RT_INT, :tc);
19061906
QAST::OperationsJAST.map_classlib_core_op('cwd', $TYPE_OPS, 'cwd', [], $RT_STR);
19071907
QAST::OperationsJAST.map_classlib_core_op('chdir', $TYPE_OPS, 'chdir', [$RT_STR], $RT_STR, :tc);
1908-
QAST::OperationsJAST.map_classlib_core_op('mkdir', $TYPE_OPS, 'mkdir', [$RT_STR, $RT_INT], $RT_INT);
1909-
QAST::OperationsJAST.map_classlib_core_op('rename', $TYPE_OPS, 'rename', [$RT_STR, $RT_STR], $RT_INT);
1910-
QAST::OperationsJAST.map_classlib_core_op('copy', $TYPE_OPS, 'copy', [$RT_STR, $RT_STR], $RT_INT);
1911-
QAST::OperationsJAST.map_classlib_core_op('link', $TYPE_OPS, 'link', [$RT_STR, $RT_STR], $RT_INT);
1908+
QAST::OperationsJAST.map_classlib_core_op('mkdir', $TYPE_OPS, 'mkdir', [$RT_STR, $RT_INT], $RT_INT, :tc);
1909+
QAST::OperationsJAST.map_classlib_core_op('rename', $TYPE_OPS, 'rename', [$RT_STR, $RT_STR], $RT_INT, :tc);
1910+
QAST::OperationsJAST.map_classlib_core_op('copy', $TYPE_OPS, 'copy', [$RT_STR, $RT_STR], $RT_INT, :tc);
1911+
QAST::OperationsJAST.map_classlib_core_op('link', $TYPE_OPS, 'link', [$RT_STR, $RT_STR], $RT_INT, :tc);
19121912

19131913
# Two variants of shell until we deprecate shell1
19141914
QAST::OperationsJAST.map_classlib_core_op('shell1', $TYPE_OPS, 'shell1', [$RT_STR], $RT_INT, :tc);
@@ -1920,7 +1920,7 @@ QAST::OperationsJAST.add_core_op('shell', -> $qastcomp, $op {
19201920
!! QAST::Op.new( :op('shell3'), |@operands ));
19211921
});
19221922

1923-
QAST::OperationsJAST.map_classlib_core_op('symlink', $TYPE_OPS, 'symlink', [$RT_STR, $RT_STR], $RT_INT);
1923+
QAST::OperationsJAST.map_classlib_core_op('symlink', $TYPE_OPS, 'symlink', [$RT_STR, $RT_STR], $RT_INT, :tc);
19241924

19251925
QAST::OperationsJAST.map_classlib_core_op('opendir', $TYPE_OPS, 'opendir', [$RT_STR], $RT_OBJ, :tc);
19261926
QAST::OperationsJAST.map_classlib_core_op('nextfiledir', $TYPE_OPS, 'nextfiledir', [$RT_OBJ], $RT_STR, :tc);

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,10 @@ public static Set<PosixFilePermission> modeToPosixFilePermission(long mode) {
604604
}
605605

606606
public static long chmod(String path, long mode) {
607+
return chmod(path, mode, null);
608+
}
609+
610+
public static long chmod(String path, long mode, ThreadContext tc) {
607611
Path path_o;
608612
try {
609613
path_o = Paths.get(path);
@@ -623,6 +627,10 @@ public static long chmod(String path, long mode) {
623627
}
624628

625629
public static long unlink(String path) {
630+
return unlink(path, null);
631+
}
632+
633+
public static long unlink(String path, ThreadContext tc) {
626634
try {
627635
if(!Files.deleteIfExists(Paths.get(path))) {
628636
return -2;
@@ -635,6 +643,10 @@ public static long unlink(String path) {
635643
}
636644

637645
public static long rmdir(String path) {
646+
return rmdir(path, null);
647+
}
648+
649+
public static long rmdir(String path, ThreadContext tc) {
638650
Path path_o = Paths.get(path);
639651
try {
640652
if (!Files.isDirectory(path_o)) {
@@ -656,8 +668,12 @@ public static String chdir(String path, ThreadContext tc) {
656668
die_s("chdir is not available on JVM", tc);
657669
return null;
658670
}
659-
671+
660672
public static long mkdir(String path, long mode) {
673+
return mkdir(path, mode, null);
674+
}
675+
676+
public static long mkdir(String path, long mode, ThreadContext tc) {
661677
try {
662678
Files.createDirectory(Paths.get(path),
663679
PosixFilePermissions.asFileAttribute(modeToPosixFilePermission(mode)));
@@ -670,6 +686,10 @@ public static long mkdir(String path, long mode) {
670686
}
671687

672688
public static long rename(String before, String after) {
689+
return rename(before, after, null);
690+
}
691+
692+
public static long rename(String before, String after, ThreadContext tc) {
673693
Path before_o = Paths.get(before);
674694
Path after_o = Paths.get(after);
675695
try {
@@ -682,18 +702,27 @@ public static long rename(String before, String after) {
682702
}
683703

684704
public static long copy(String before, String after) {
705+
return copy(before, after, null);
706+
}
707+
708+
public static long copy(String before, String after, ThreadContext tc) {
685709
Path before_o = Paths.get(before);
686710
Path after_o = Paths.get(after);
687711
try {
688712
Files.copy(before_o, after_o);
689713
}
690714
catch (Exception e) {
691715
return -1;
716+
// die_s(e.getMessage(), tc);
692717
}
693718
return 0;
694719
}
695720

696721
public static long link(String before, String after) {
722+
return link(before, after, null);
723+
}
724+
725+
public static long link(String before, String after, ThreadContext tc) {
697726
Path before_o = Paths.get(before);
698727
Path after_o = Paths.get(after);
699728
try {
@@ -747,6 +776,10 @@ public static long shell3(String cmd, String dir, SixModelObject envObj, ThreadC
747776
}
748777

749778
public static long symlink(String before, String after) {
779+
return symlink(before, after, null);
780+
}
781+
782+
public static long symlink(String before, String after, ThreadContext tc) {
750783
Path before_o = Paths.get(before);
751784
Path after_o = Paths.get(after);
752785
try {

0 commit comments

Comments
 (0)