Class: LLDB::FileSpec

Inherits:
Object
  • Object
show all
Includes:
NativeLifecycle
Defined in:
lib/lldb/file_spec.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NativeLifecycle

#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object

Constructor Details

#initialize(path = nil, resolve: false, context: nil, pointer: nil) ⇒ FileSpec

Returns a new instance of FileSpec.

RBS:

  • path: String?

  • resolve: bool

  • context: Context?

  • pointer: FFI::Pointer?

  • return: void



14
15
16
17
18
19
20
21
22
# File 'lib/lldb/file_spec.rb', line 14

def initialize(path = nil, resolve: false, context: nil, pointer: nil)
  NativeStringArray.validate!(path) if path
  ptr = pointer || FFIBindings.lldb_file_spec_create(path, resolve ? 1 : 0)
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_file_spec_destroy(released) },
    context: context
  )
end

Class Method Details

.from_ptr(ptr, context: nil) ⇒ Object

RBS:

  • ptr: FFI::Pointer

  • context: Context?

  • return: FileSpec



27
28
29
# File 'lib/lldb/file_spec.rb', line 27

def self.from_ptr(ptr, context: nil)
  new(context: context, pointer: ptr)
end

Instance Method Details

#directoryObject

RBS:

  • return: String?



49
50
51
52
53
# File 'lib/lldb/file_spec.rb', line 49

def directory
  return nil unless valid?

  FFIBindings.lldb_file_spec_get_directory(@ptr)
end

#directory=(value) ⇒ Object

RBS:

  • value: String

  • return: void



74
75
76
77
78
# File 'lib/lldb/file_spec.rb', line 74

def directory=(value)
  ensure_open!
  NativeStringArray.validate!(value)
  FFIBindings.lldb_file_spec_set_directory(@ptr, value)
end

#exists?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


37
38
39
# File 'lib/lldb/file_spec.rb', line 37

def exists?
  valid? && FFIBindings.lldb_file_spec_exists(@ptr) != 0
end

#filenameObject

RBS:

  • return: String?



42
43
44
45
46
# File 'lib/lldb/file_spec.rb', line 42

def filename
  return nil unless valid?

  FFIBindings.lldb_file_spec_get_filename(@ptr)
end

#filename=(value) ⇒ Object

RBS:

  • value: String

  • return: void



66
67
68
69
70
# File 'lib/lldb/file_spec.rb', line 66

def filename=(value)
  ensure_open!
  NativeStringArray.validate!(value)
  FFIBindings.lldb_file_spec_set_filename(@ptr, value)
end

#pathObject

RBS:

  • return: String



56
57
58
59
60
61
62
# File 'lib/lldb/file_spec.rb', line 56

def path
  return '' unless valid?

  NativeBuffer.read_c_string do |buffer, length|
    FFIBindings.lldb_file_spec_get_path(@ptr, buffer, length)
  end
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



86
87
88
# File 'lib/lldb/file_spec.rb', line 86

def to_ptr
  @ptr
end

#to_sObject

RBS:

  • return: String



81
82
83
# File 'lib/lldb/file_spec.rb', line 81

def to_s
  path
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


32
33
34
# File 'lib/lldb/file_spec.rb', line 32

def valid?
  !@ptr.null? && FFIBindings.lldb_file_spec_is_valid(@ptr) != 0
end