Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/file.rb
Views: 11779
# -*- coding: binary -*-12require 'rex/post/io'34module Rex5module Post67# make this a module so we can mix it in, and have inheritance like..8# => [Rex::Post::DispatchNinja::File, Rex::Post::File,9# Rex::Post::DispatchNinja::IO, Rex::Post::IO, Object, Kernel]1011###12#13# This module simulates the behavior that one would expect from the Ruby File14# class against a remote entity. Refer to the ruby documentation for expected15# behavior.16#17###18module File1920protected21# inherits fd and mode from IO22attr_accessor :filename23public2425# f = File.new("testfile", "r")26# f = File.new("newfile", "w+")27# f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)28# !!! I suppose I should figure out the correct default for perm..29def initialize(name, mode='r', perm=0)30end3132def path33filename34end3536# ctime/atime blah need fstat..37# need lchown/chown/fchown, etc, etc3839# proxy these methods40def File.basename(*a)41::File.basename(*a)42end43def File.dirname(*a)44::File.dirname(*a)45end46def File.extname(*a)47::File.extname(*a)48end49# !!! we might actually want to handle this File::SEPARATOR stuff50# for win32 support, etc.51def File.join(*a)52::File.join(*a)53end5455def File.chmod56raise NotImplementedError57end58def File.chown59raise NotImplementedError60end61def File.delete(*a)62unlink(*a)63end64def File.unlink65raise NotImplementedError66end67def File.lchmod68raise NotImplementedError69end70def File.lchown71raise NotImplementedError72end73def File.link74raise NotImplementedError75end76def File.lstat77raise NotImplementedError78end7980# this, along with all the other globbing/search stuff, probably81# won't get implemented, at least for a bit...82def File.expand_path83raise NotImplementedError84end85def File.fnmatch(*a)86fnmatch?(*a)87end88def File.fnmatch?89raise NotImplementedError90end9192#93# autogen'd stat passthroughs94#95def File.atime(name)96stat(name).atime97end98def File.blockdev?(name)99stat(name).blockdev?100end101def File.chardev?(name)102stat(name).chardev?103end104def File.ctime(name)105stat(name).ctime106end107def File.directory?(name)108stat(name).directory?109end110def File.executable?(name)111stat(name).executable?112end113def File.executable_real?(name)114stat(name).executable_real?115end116def File.file?(name)117stat(name).file?118end119def File.ftype(name)120stat(name).ftype121end122def File.grpowned?(name)123stat(name).grpowned?124end125def File.mtime(name)126stat(name).mtime127end128def File.owned?(name)129stat(name).owned?130end131def File.pipe?(name)132stat(name).pipe?133end134def File.readable?(name)135stat(name).readable?136end137def File.readable_real?(name)138stat(name).readable_real?139end140def File.setuid?(name)141stat(name).setuid?142end143def File.setgid?(name)144stat(name).setgid?145end146def File.size(name)147stat(name).size148end149def File.socket?(name)150stat(name).socket?151end152def File.sticky?(name)153stat(name).sticky?154end155def File.symlink?(name)156stat(name).symlink?157end158def File.writeable?(name)159stat(name).writeable?160end161def File.writeable_real?(name)162stat(name).writeable_real?163end164def File.zero?(name)165stat(name).zero?166end167168end169170end; end # Post/Rex171172173174