Files
metasploit-gs/lib/rex/post/file.rb
T

173 lines
3.3 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
2005-04-03 21:52:10 +00:00
2005-07-09 21:18:49 +00:00
require 'rex/post/io'
2005-04-04 01:33:26 +00:00
2005-04-03 21:52:10 +00:00
module Rex
module Post
2005-04-04 01:33:26 +00:00
# make this a module so we can mix it in, and have inheritence like..
# => [Rex::Post::DispatchNinja::File, Rex::Post::File,
# Rex::Post::DispatchNinja::IO, Rex::Post::IO, Object, Kernel]
2005-04-03 21:52:10 +00:00
2005-11-15 05:22:13 +00:00
###
#
# This module simulates the behavior that one would expect from the Ruby File
# class against a remote entity. Refer to the ruby documentation for expected
# behavior.
#
###
2005-04-04 01:33:26 +00:00
module File
2013-08-30 16:28:33 -05:00
protected
# inherits fd and mode from IO
attr_accessor :filename
public
2009-11-16 15:16:08 +00:00
2013-08-30 16:28:33 -05:00
# f = File.new("testfile", "r")
# f = File.new("newfile", "w+")
# f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
# !!! I suppose I should figure out the correct default for perm..
def initialize(name, mode='r', perm=0)
end
2005-04-04 01:33:26 +00:00
2013-08-30 16:28:33 -05:00
def path
filename
end
2005-04-03 21:52:10 +00:00
2013-08-30 16:28:33 -05:00
# ctime/atime blah need fstat..
# need lchown/chown/fchown, etc, etc
2005-04-03 21:52:10 +00:00
2013-08-30 16:28:33 -05:00
# proxy these methods
def File.basename(*a)
::File.basename(*a)
end
def File.dirname(*a)
::File.dirname(*a)
end
def File.extname(*a)
::File.extname(*a)
end
# !!! we might actually want to handle this File::SEPERATOR stuff
# for win32 support, etc.
def File.join(*a)
::File.join(*a)
end
2005-04-04 01:33:26 +00:00
2013-08-30 16:28:33 -05:00
def File.chmod
raise NotImplementedError
end
def File.chown
raise NotImplementedError
end
def File.delete(*a)
unlink(*a)
end
def File.unlink
raise NotImplementedError
end
def File.lchmod
raise NotImplementedError
end
def File.lchown
raise NotImplementedError
end
def File.link
raise NotImplementedError
end
def File.lstat
raise NotImplementedError
end
2005-04-03 21:52:10 +00:00
2013-08-30 16:28:33 -05:00
# this, along with all the other globbing/search stuff, probably
# won't get implemented, atleast for a bit...
def File.expand_path
raise NotImplementedError
end
def File.fnmatch(*a)
fnmatch?(*a)
end
def File.fnmatch?
raise NotImplementedError
end
2005-04-03 21:52:10 +00:00
2013-08-30 16:28:33 -05:00
#
# autogen'd stat passthroughs
#
def File.atime(name)
stat(name).atime
end
def File.blockdev?(name)
stat(name).blockdev?
end
def File.chardev?(name)
stat(name).chardev?
end
def File.ctime(name)
stat(name).ctime
end
def File.directory?(name)
stat(name).directory?
end
def File.executable?(name)
stat(name).executable?
end
def File.executable_real?(name)
stat(name).executable_real?
end
def File.file?(name)
stat(name).file?
end
def File.ftype(name)
stat(name).ftype
end
def File.grpowned?(name)
stat(name).grpowned?
end
def File.mtime(name)
stat(name).mtime
end
def File.owned?(name)
stat(name).owned?
end
def File.pipe?(name)
stat(name).pipe?
end
def File.readable?(name)
stat(name).readable?
end
def File.readable_real?(name)
stat(name).readable_real?
end
def File.setuid?(name)
stat(name).setuid?
end
def File.setgid?(name)
stat(name).setgid?
end
def File.size(name)
stat(name).size
end
def File.socket?(name)
stat(name).socket?
end
def File.sticky?(name)
stat(name).sticky?
end
def File.symlink?(name)
stat(name).symlink?
end
def File.writeable?(name)
stat(name).writeable?
end
def File.writeable_real?(name)
stat(name).writeable_real?
end
def File.zero?(name)
stat(name).zero?
end
2005-04-03 21:52:10 +00:00
end
2009-11-16 15:16:08 +00:00
end; end # Post/Rex