Class: NTFS::FileName
- Inherits:
-
Object
- Object
- NTFS::FileName
- Defined in:
- lib/fs/ntfs/attrib_file_name.rb
Constant Summary collapse
- NS_POSIX =
0
- NS_WIN32 =
1
- NS_DOS =
2
- NS_DOSWIN =
3
- UNNAMED =
'[unnamed]'.AsciiToUtf8.freeze
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#refParent ⇒ Object
readonly
Returns the value of attribute refParent.
Instance Method Summary collapse
- #aTime ⇒ Object
- #cTime ⇒ Object
- #dump ⇒ Object
-
#initialize(buf) ⇒ FileName
constructor
A new instance of FileName.
-
#isDir? ⇒ Boolean
Returns nil if not directory.
- #mTime ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(buf) ⇒ FileName
Returns a new instance of FileName.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 55 def initialize(buf) raise "MIQ(NTFS::FileName.initialize) Nil buffer" if buf.nil? buf = buf.read(buf.length) if buf.kind_of?(DataRun) @afn = ATTRIB_FILE_NAME.decode(buf) buf = buf[SIZEOF_ATTRIB_FILE_NAME, buf.size] # Set accessor data. @permissions = @afn['flags'] @length = @afn['data_size'] @namespace = @afn['namespace'] @refParent = NTFS::Utils.MkRef(@afn['ref_to_parent_dir']) # If there's a name get it. len = @afn['name_length'] * 2 @name = buf[0, len].UnicodeToUtf8 if len > 0 # If name is nil use NT standard unnamed. @name ||= UNNAMED.dup end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
46 47 48 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 46 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 46 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
46 47 48 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 46 def namespace @namespace end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
46 47 48 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 46 def @permissions end |
#refParent ⇒ Object (readonly)
Returns the value of attribute refParent.
46 47 48 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 46 def refParent @refParent end |
Instance Method Details
#aTime ⇒ Object
83 84 85 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 83 def aTime @aTime ||= NtUtil.nt_filetime_to_ruby_time(@afn['time_read']) end |
#cTime ⇒ Object
87 88 89 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 87 def cTime @cTime ||= NtUtil.nt_filetime_to_ruby_time(@afn['time_created']) end |
#dump ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 96 def dump out = "\#<#{self.class}:0x#{'%08x' % object_id}>\n" out << " Parent dir : seq #{@refParent[0]}, entry #{@refParent[1]}\n" out << " Created : #{@cTime}\n" out << " Modified : #{@mTime}\n" out << " MFT changed: #{NtUtil.nt_filetime_to_ruby_time(@afn['time_mft_changed'])}\n" out << " Accessed : #{@aTime}\n" out << " Allocated : #{@afn['allocated_size']}\n" out << " Real size : #{@length}\n" out << " Flags : 0x#{'%08x' % @flags}\n" out << " Reparse : #{@afn['reparse_point_tag']}\n" out << " Name length: #{@afn['name_length']}\n" out << " Namespace : #{@namespace}\n" out << " Name : #{@name}\n" out << "---\n" end |
#isDir? ⇒ Boolean
Returns nil if not directory.
92 93 94 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 92 def isDir? NTFS::Utils.gotBit?(@permissions, StandardInformation.FP_DIRECTORY) end |
#mTime ⇒ Object
79 80 81 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 79 def mTime @mTime ||= NtUtil.nt_filetime_to_ruby_time(@afn['time_altered']) end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/fs/ntfs/attrib_file_name.rb', line 75 def to_s @name end |