Class: RubySMB::Server::Share::Provider::VirtualDisk::VirtualMappedFile
- Inherits:
-
VirtualPathname
- Object
- VirtualPathname
- RubySMB::Server::Share::Provider::VirtualDisk::VirtualMappedFile
- Defined in:
- lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb
Overview
A mapped file is one who is backed by an entry on disk. The path need not be present, but if it does exist, it must be a file.
Constant Summary
Constants inherited from VirtualPathname
RubySMB::Server::Share::Provider::VirtualDisk::VirtualPathname::SEPARATOR
Instance Attribute Summary
Attributes inherited from VirtualPathname
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(disk, path, mapped_path) ⇒ VirtualMappedFile
constructor
A new instance of VirtualMappedFile.
- #open(mode = 'r', &block) ⇒ Object
- #stat ⇒ Object
Methods inherited from VirtualPathname
#<=>, #==, #absolute?, basename, #basename, #children, cleanpath, #cleanpath, #dirname, dirname, #entries, #extname, #join, #relative?, #split, #to_s
Constructor Details
#initialize(disk, path, mapped_path) ⇒ VirtualMappedFile
Returns a new instance of VirtualMappedFile.
58 59 60 61 62 63 64 65 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 58 def initialize(disk, path, mapped_path) mapped_path = Pathname.new(File.(mapped_path)) if mapped_path.is_a?(String) raise ArgumentError.new('mapped_path must be absolute') unless mapped_path.absolute? # it needs to be absolute so it is independent of the cwd @virtual_disk = disk @path = path @mapped_path = mapped_path end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RubySMB::Server::Share::Provider::VirtualDisk::VirtualPathname
Instance Method Details
#exist? ⇒ Boolean
67 68 69 70 71 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 67 def exist? # filter out anything that's not a directory but allow the file to be missing, this prevents exposing # directories which could yield path confusion errors @mapped_path.exist? && @mapped_path.file? end |
#open(mode = 'r', &block) ⇒ Object
77 78 79 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 77 def open(mode = 'r', &block) @mapped_path.open(mode, &block) end |
#stat ⇒ Object
73 74 75 |
# File 'lib/ruby_smb/server/share/provider/virtual_disk/virtual_file.rb', line 73 def stat @mapped_path.stat end |