Class: Train::Extras::AixFile

Inherits:
LinuxFile show all
Defined in:
lib/train/extras/aix_file.rb

Instance Attribute Summary

Attributes inherited from LinuxFile

#path

Instance Method Summary collapse

Methods inherited from LinuxFile

#exist?, #file_version, #link_target, #product_version, #stat

Methods inherited from FileCommon

#block_device?, #character_device?, #directory?, #file?, #grouped_into?, #linked_to?, #md5sum, #mode?, #mounted?, #owned_by?, #pipe?, #sha256sum, #socket?, #symlink?, #type, #unix_mode_mask, #version?

Constructor Details

#initialize(backend, path) ⇒ AixFile

Returns a new instance of AixFile.



8
9
10
# File 'lib/train/extras/aix_file.rb', line 8

def initialize(backend, path)
  super(backend, path)
end

Instance Method Details

#contentObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/train/extras/aix_file.rb', line 12

def content
  return @content if defined?(@content)
  @content = case
             when !exist?, directory?
               nil
             when size.nil?, size == 0
               ''
             else
               @backend.run_command("cat #{@spath}").stdout || ''
             end
end


24
25
26
27
28
29
# File 'lib/train/extras/aix_file.rb', line 24

def link_path
  return nil unless symlink?
  @link_path ||= (
    @backend.run_command("perl -e 'print readlink shift' #{@spath}").stdout.chomp
  )
end

#mountedObject



31
32
33
34
35
# File 'lib/train/extras/aix_file.rb', line 31

def mounted
  @mounted ||= (
    @backend.run_command("lsfs -c #{@spath}")
  )
end