class File
Represents a file in a translation unit.
Definitions
attr_reader :translation_unit
Signature
-
attribute
TranslationUnit The translation unit this file belongs to.
def initialize(pointer, translation_unit)
Initialize a file with a pointer and translation unit.
Signature
-
parameter
pointerFFI::Pointer The file pointer.
-
parameter
translation_unitTranslationUnit The parent translation unit.
Implementation
def initialize(pointer, translation_unit)
super pointer
@translation_unit = translation_unit
pointer = MemoryPointer.new(Lib::CXFileUniqueID)
Lib.get_file_unique_id(self, pointer)
@unique_id = Lib::CXFileUniqueID.new(pointer)
end
def to_s
Get the file name as a string.
Signature
-
returns
String The file name.
Implementation
def to_s
name
end
def name
Get the file name.
Signature
-
returns
String The file name.
Implementation
def name
Lib.extract_string Lib.get_file_name(self)
end
def time
Get the file modification time.
Signature
-
returns
Time The file modification time.
Implementation
def time
Time.at(Lib.get_file_time(self))
end
def include_guarded?
Check if the file has include guards.
Signature
-
returns
Boolean True if the file is include guarded.
Implementation
def include_guarded?
Lib.is_file_multiple_include_guarded(@translation_unit, self) != 0
end
def device
Get the device ID of the file.
Signature
-
returns
Integer The device ID.
Implementation
def device
@unique_id[:device]
end
def inode
Get the inode number of the file.
Signature
-
returns
Integer The inode number.
Implementation
def inode
@unique_id[:inode]
end
def modification
Get the modification time from the unique ID.
Signature
-
returns
Time The modification time.
Implementation
def modification
Time.at(@unique_id[:modification])
end