lib/fuse/rfusefs-fuse.rb
def truncate(ctx,path,offset)
        return wrap_context(ctx,__method__,path,offset) if ctx

        unless @root.can_write?(path)
          raise Errno::EACESS.new(path)
        end

        current_size = size(path)
        unless @root.raw_truncate(path,offset)
          contents = @root.read_file(path)
          if (offset <= 0)
            @root.write_to(path,"")
          elsif offset < contents.length
            @root.write_to(path,contents[0..offset] )
          end
        end
        @adj_size = @adj_size - current_size + (offset <= 0 ? 0 : offset)
      end
#truncate a file outside of open files
truncate a file outside of open files
truncate a file outside of open files
def truncate(ctx,path,offset)
        return wrap_context(ctx,__method__,path,offset) if ctx
        unless @root.can_write?(path)
          raise Errno::EACESS.new(path)
        end
        current_size = size(path)
        unless @root.raw_truncate(path,offset)
          contents = @root.read_file(path)
          if (offset <= 0)
            @root.write_to(path,"")
          elsif offset < contents.length
            @root.write_to(path,contents[0..offset] )
          end
        end
        @adj_size = @adj_size - current_size + (offset <= 0 ? 0 : offset)
      end
def truncate ( ctx , path , offset ) return wrap_context ( ctx , __method__ , path , offset ) if ctx unless @root . can_write? ( path ) raise Errno :: EACESS . new ( path ) end current_size = size ( path ) unless @root . raw_truncate ( path , offset ) contents = @root . read_file ( path ) if ( offset <= 0 ) @root . write_to ( path , "" ) elsif offset < contents . length @root . write_to ( path , contents [ 0 .. offset ] ) end end @adj_size = @adj_size - current_size + ( offset <= 0 ? 0 : offset ) end
truncate a file outside of open files
truncate a file outside of open files
ctx
path
offset