improved the dir class

git-svn-id: file:///home/svn/incoming/trunk@2366 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-04-11 05:49:59 +00:00
parent 7556674686
commit a247682500
1 changed files with 78 additions and 0 deletions

View File

@ -15,6 +15,15 @@ class Dir < Rex::Post::Dir
attr_accessor :client
end
def initialize(path)
self.path = path
self.client = self.class.client
end
def each(&block)
client.dir.foreach(self.path, &block)
end
=begin
entries(name)
@ -35,6 +44,75 @@ class Dir < Rex::Post::Dir
return files
end
=begin
chdir(path)
Changes the working directory of the remote process.
=end
def Dir.chdir(path)
request = Packet.create_request('stdapi_fs_chdir')
request.add_tlv(TLV_TYPE_DIRECTORY_PATH, path)
response = client.send_request(request)
return 0
end
=begin
pwd
Returns the current working directory of the remote process.
=end
def Dir.pwd
request = Packet.create_request('stdapi_fs_getwd')
response = client.send_request(request)
return response.get_tlv(TLV_TYPE_DIRECTORY_PATH).value
end
=begin
Synonym for pwd
=end
def Dir.getwd
pwd
end
=begin
delete
Removes the supplied directory if it's empty
=end
def Dir.delete(path)
request = Packet.create_request('stdapi_fs_delete_dir')
request.add_tlv(TLV_TYPE_DIRECTORY_PATH, path)
response = client.send_request(request)
return 0
end
=begin
rmdir, unlink
Synonyms for delete
=end
def Dir.rmdir(path)
delete(path)
end
def Dir.unlink(path)
delete(path)
end
attr_reader :path
protected
attr_accessor :client
attr_writer :path
end
end; end; end; end; end