Skip to content
Permalink
Browse files

einval

  • Loading branch information
alex committed Jun 22, 2013
1 parent 08934c2 commit c831386811229bd08c5cf10c22209686fa2a1487
Showing with 8 additions and 3 deletions.
  1. +3 −0 lib-topaz/errno.rb
  2. +0 −2 spec/tags/core/file/truncate_tags.txt
  3. +1 −0 topaz/error.py
  4. +4 −1 topaz/objects/fileobject.py
@@ -17,6 +17,9 @@ class ENOTDIR < SystemCallError
class EISDIR < SystemCallError
end

class EINVAL < SystemCallError
end

class ENOTEMPTY < SystemCallError
end
end
@@ -14,6 +14,4 @@ fails:File#truncate truncates a file size to 0
fails:File#truncate truncates a file size to 5
fails:File#truncate truncates a file to a larger size than the original file
fails:File#truncate truncates a file to the same size as the original file
fails:File#truncate raises an Errno::EINVAL if the length argument is not valid
fails:File#truncate raises an IOError if file is not opened for writing
fails:File#truncate raises a TypeError if not passed an Integer type for the for the argument
@@ -33,6 +33,7 @@ def print_traceback(space, w_exc, top_filepath=None):
errno.EEXIST: "EEXIST",
errno.ENOTDIR: "ENOTDIR",
errno.EISDIR: "EISDIR",
errno.EINVAL: "EINVAL",
errno.ENOTEMPTY: "ENOTEMPTY",
}

@@ -249,7 +249,10 @@ def method_umask(self, space, mask=-1):
@classdef.method("truncate", length="int")
def method_truncate(self, space, length):
self.ensure_not_closed(space)
ftruncate(self.fd, length)
try:
ftruncate(self.fd, length)
except OSError as e:
raise error_for_oserror(space, e)
return space.newint(0)

@classdef.method("chmod", mode="int")

0 comments on commit c831386

Please sign in to comment.
You can’t perform that action at this time.