Skip to content

Commit

Permalink
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 7 additions & 4 deletions truffle/src/main/ruby/core/file.rb
Original file line number Diff line number Diff line change
@@ -345,11 +345,14 @@ def self.lchown(owner, group, *paths)
paths.size
end

def self.mkfifo(path, mode = undefined)
mode = if undefined.equal?(mode)
0666
def self.mkfifo(*args)
arg_count = args.size
Rubinius::Type.check_arity(arg_count, 1, 2)
path = args[0]
mode = if arg_count > 1
Rubinius::Type.coerce_to args[1], Integer, :to_int
else
Rubinius::Type.coerce_to mode, Integer, :to_int
0666
end
path = Rubinius::Type.coerce_to_path(path)
status = Truffle::POSIX.mkfifo(path, mode)
14 changes: 14 additions & 0 deletions truffle/src/main/ruby/core/type.rb
Original file line number Diff line number Diff line change
@@ -441,5 +441,19 @@ def self.object_respond_to_marshal_dump?(obj)
def self.object_respond_to_marshal_load?(obj)
object_respond_to? obj, :marshal_load, true
end

def self.check_arity(arg_count, min, max)
if arg_count < min || (max != -1 && arg_count > max)
error_message = if min == max
"wrong number of arguments (given %d, expected %d)" % [arg_count, min]
elsif max == -1
"wrong number of arguments (given %d, expected %d+)" % [arg_count, min]
else
"wrong number of arguments (given %d, expected %d..%d)" % [arg_count, min, max]
end
raise ArgumentError, error_message
end
end

end
end

0 comments on commit decc1a3

Please sign in to comment.