Skip to content

Commit

Permalink
Showing 17 changed files with 74 additions and 59 deletions.
15 changes: 0 additions & 15 deletions spec/truffle/tags/core/file/constants/constants_tags.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
fails:File::Constants::APPEND is defined
fails:File::Constants::CREAT is defined
fails:File::Constants::EXCL is defined
fails:File::Constants::FNM_SYSCASE is defined
fails:File::Constants::LOCK_EX is defined
fails:File::Constants::LOCK_NB is defined
fails:File::Constants::LOCK_SH is defined
fails:File::Constants::LOCK_UN is defined
fails:File::Constants::NONBLOCK is defined
fails:File::Constants::RDONLY is defined
fails:File::Constants::RDWR is defined
fails:File::Constants::TRUNC is defined
fails:File::Constants::WRONLY is defined
fails:File::Constants::NOCTTY is defined
fails:File::Constants::SYNC is defined
fails(windows):File::Constants::BINARY is defined
1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/delete_tags.txt

This file was deleted.

8 changes: 0 additions & 8 deletions spec/truffle/tags/core/file/directory_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/truffle/tags/core/file/executable_real_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/truffle/tags/core/file/executable_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/file/expand_path_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fails:File.expand_path does not replace multiple '/' at the beginning of the path
fails:File.expand_path raises an ArgumentError if the path is not valid
fails:File.expand_path expands ~ENV['USER'] to the user's home directory
fails(windows):File.expand_path expands C:/./dir to C:/dir
windows:File.expand_path converts a pathname to an absolute pathname, Ruby-Talk:18512
windows:File.expand_path converts a pathname to an absolute pathname, using a complete path
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/file/grpowned_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:File.grpowned? takes non primary groups into account
fails(windows):File.grpowned? returns false if the file exist
fails:File.grpowned? returns true if the file exist
fails:File.grpowned? accepts an object that has a #to_path method
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/file/identical_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fails:File.identical? returns true for a file and its link
fails:File.identical? returns false if any of the files doesn't exist
fails:File.identical? accepts an object that has a #to_path method
fails:File.identical? raises an ArgumentError if not passed two arguments
fails:File.identical? raises a TypeError if not passed String types
fails:File.identical? returns true if both named files are identical
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/file/initialize_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/lstat_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:File.lstat returns a File::Stat object if the given file exists
fails:File.lstat returns a File::Stat object when called on an instance of File
fails:File.lstat returns a File::Stat object with symlink properties for a symlink
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/file/new_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:File.new returns a new File with modus num and permissions
fails:File.new opens the existing file, does not change permissions even when they are specified
fails:File.new raises an Errorno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL
fails:File.new raises an Errno::EBADF if the first parameter is an invalid file descriptor
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/file/open_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fails:File.open opens the file when passed mode, num and permissions
fails:File.open opens the file when passed mode, num, permissions and block
fails:File.open opens the existing file, does not change permissions even when they are specified
fails:File.open raises an Errorno::EEXIST if the file exists when open with File::CREAT|File::EXCL
fails:File.open raises an Errno::EACCES when opening non-permitted file
fails:File.open raises an Errno::EACCES when opening read-only file
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/filetest/directory_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/filetest/identical_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fails:FileTest.identical? returns true for a file and its link
fails:FileTest.identical? returns false if any of the files doesn't exist
fails:FileTest.identical? accepts an object that has a #to_path method
fails:FileTest.identical? raises an ArgumentError if not passed two arguments
fails:FileTest.identical? raises a TypeError if not passed String types
fails:FileTest.identical? returns true if both named files are identical
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/filetest/size_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -186,6 +186,22 @@ public RubyBasicObject memset(RubyBasicObject pointer, int c, long length) {

}

@CoreMethod(names = "link", isModuleFunction = true, required = 2)
public abstract static class LinkNode extends PointerPrimitiveNodes.ReadAddressPrimitiveNode {

public LinkNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public int link(RubyString path, RubyString other) {
final String pathString = RubyEncoding.decodeUTF8(path.getByteList().getUnsafeBytes(), path.getByteList().getBegin(), path.getByteList().getRealSize());
final String otherString = RubyEncoding.decodeUTF8(other.getByteList().getUnsafeBytes(), other.getByteList().getBegin(), other.getByteList().getRealSize());
return posix().link(pathString, otherString);
}

}

@CoreMethod(names = "unlink", isModuleFunction = true, required = 1)
public abstract static class UnlinkNode extends PointerPrimitiveNodes.ReadAddressPrimitiveNode {

Original file line number Diff line number Diff line change
@@ -24,6 +24,35 @@ public abstract class StatPrimitiveNodes {

public static final HiddenKey STAT_IDENTIFIER = new HiddenKey("stat");


@RubiniusPrimitive(name = "stat_dev")
public static abstract class StatDevPrimitiveNode extends StatReadPrimitiveNode {

public StatDevPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public long dev(RubyBasicObject rubyStat) {
return getStat(rubyStat).dev();
}

}

@RubiniusPrimitive(name = "stat_ino")
public static abstract class StatInoPrimitiveNode extends StatReadPrimitiveNode {

public StatInoPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public long ino(RubyBasicObject rubyStat) {
return getStat(rubyStat).ino();
}

}

@RubiniusPrimitive(name = "stat_stat")
public static abstract class StatStatPrimitiveNode extends RubiniusPrimitiveNode {

@@ -54,6 +83,35 @@ public Object stat(RubyBasicObject rubyStat, Object path) {

}

@RubiniusPrimitive(name = "stat_fstat")
public static abstract class StatFStatPrimitiveNode extends RubiniusPrimitiveNode {

@Child private WriteHeadObjectFieldNode writeStatNode;

public StatFStatPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
writeStatNode = new WriteHeadObjectFieldNode(STAT_IDENTIFIER);
}

@Specialization
public int fstat(RubyBasicObject rubyStat, int fd) {
final FileStat stat = posix().allocateStat();
final int code = posix().fstat(fd, stat);

if (code == 0) {
writeStatNode.execute(rubyStat, stat);
}

return code;
}

@Specialization(guards = "!isRubyString(path)")
public Object stat(RubyBasicObject rubyStat, Object path) {
return null;
}

}

@RubiniusPrimitive(name = "stat_lstat")
public static abstract class StatLStatPrimitiveNode extends RubiniusPrimitiveNode {

0 comments on commit d8a4c18

Please sign in to comment.