Class: Train::Transports::Local::Connection::File

Inherits:
Extras::LinuxFile show all
Defined in:
lib/train/transports/local_file.rb

Constant Summary

Constants inherited from Extras::FileCommon

Extras::FileCommon::DATA_FIELDS

Instance Attribute Summary

Attributes inherited from Extras::UnixFile

#path

Instance Method Summary collapse

Methods inherited from Extras::UnixFile

#exist?, #file_version, #initialize, #mounted, #product_version

Methods inherited from Extras::FileCommon

#basename, #directory?, #file?, #grouped_into?, #initialize, #linked_to?, #md5sum, #mode?, #mounted?, #owned_by?, #pipe?, #sha256sum, #socket?, #source, #source_path, #symlink?, #to_json, #type, #unix_mode_mask, #version?

Constructor Details

This class inherits a constructor from Train::Extras::UnixFile

Instance Method Details

#block_device?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/train/transports/local_file.rb', line 34

def block_device?
  ::File.blockdev?(@path)
end

#character_device?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/train/transports/local_file.rb', line 38

def character_device?
  ::File.chardev?(@path)
end

#contentObject



10
11
12
13
14
# File 'lib/train/transports/local_file.rb', line 10

def content
  @content ||= ::File.read(@path, encoding: 'UTF-8')
rescue StandardError => _
  nil
end


24
25
26
27
28
29
30
31
32
# File 'lib/train/transports/local_file.rb', line 24

def link_path
  return nil unless symlink?
  begin
    @link_path ||= ::File.realpath(@path)
  rescue Errno::ELOOP => _
    # Leave it blank on symbolic loop, same as readlink
    @link_path = ''
  end
end