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
37
38
39
|
# File 'lib/train/file/local.rb', line 37
def block_device?
::File.blockdev?(@path)
end
|
#character_device? ⇒ Boolean
41
42
43
|
# File 'lib/train/file/local.rb', line 41
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
29
|
# 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
72
73
74
|
# File 'lib/train/file/local.rb', line 72
def linked_to?(dst)
link_path == dst
end
|
#mode?(sth) ⇒ Boolean
68
69
70
|
# File 'lib/train/file/local.rb', line 68
def mode?(sth)
mode == sth
end
|
#shallow_link_path ⇒ Object
31
32
33
34
35
|
# File 'lib/train/file/local.rb', line 31
def shallow_link_path
return nil unless symlink?
@link_path ||= ::File.readlink(@path)
end
|
#type ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/train/file/local.rb', line 45
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
|