Class: Train::File::Local
- Inherits:
-
Train::File
show all
- Defined in:
- lib/train/file/local.rb,
lib/train/file/local/unix.rb,
lib/train/file/local/windows.rb
Defined Under Namespace
Classes: Unix, Windows
Constant Summary
Constants inherited
from Train::File
DATA_FIELDS
Instance Method Summary
collapse
Methods inherited from Train::File
#directory?, #file?, #file_version, #initialize, #md5sum, #mounted?, #owned_by?, #path, #pipe?, #product_version, #sanitize_filename, #sha256sum, #socket?, #source, #source_path, #symlink?, #to_json, #version?
Constructor Details
This class inherits a constructor from Train::File
Instance Method Details
#block_device? ⇒ Boolean
35
36
37
|
# File 'lib/train/file/local.rb', line 35
def block_device?
::File.blockdev?(@path)
end
|
#character_device? ⇒ Boolean
39
40
41
|
# File 'lib/train/file/local.rb', line 39
def character_device?
::File.chardev?(@path)
end
|
#content ⇒ Object
14
15
16
17
18
|
# File 'lib/train/file/local.rb', line 14
def content
@content ||= ::File.read(@path, encoding: 'UTF-8')
rescue StandardError => _
nil
end
|
#link_path ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/train/file/local.rb', line 20
def link_path
return nil unless symlink?
begin
@link_path ||= ::File.realpath(@path)
rescue Errno::ELOOP => _
@link_path = ''
end
end
|
#linked_to?(dst) ⇒ Boolean
70
71
72
|
# File 'lib/train/file/local.rb', line 70
def linked_to?(dst)
link_path == dst
end
|
#mode?(sth) ⇒ Boolean
66
67
68
|
# File 'lib/train/file/local.rb', line 66
def mode?(sth)
mode == sth
end
|
#shallow_link_path ⇒ Object
30
31
32
33
|
# File 'lib/train/file/local.rb', line 30
def shallow_link_path
return nil unless symlink?
@link_path ||= ::File.readlink(@path)
end
|
#type ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/train/file/local.rb', line 43
def type
case ::File.ftype(@path)
when 'blockSpecial'
:block_device
when 'characterSpecial'
:character_device
when 'link'
:symlink
when 'fifo'
:pipe
else
::File.ftype(@path).to_sym
end
end
|