Module: FFI::OpenMPT
- Defined in:
- lib/ffi/openmpt.rb,
lib/ffi/openmpt/api.rb,
lib/ffi/openmpt/module.rb,
lib/ffi/openmpt/string.rb,
lib/ffi/openmpt/openmpt.rb,
lib/ffi/openmpt/version.rb
Defined Under Namespace
Modules: API, String
Classes: Module
Constant Summary
collapse
- VERSION =
'0.5.0'
Class Method Summary
collapse
Class Method Details
.core_version ⇒ Object
14
15
16
|
# File 'lib/ffi/openmpt/openmpt.rb', line 14
def self.core_version
[API.openmpt_get_core_version].pack('L>').unpack('CCCC')
end
|
.error_string(error) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/ffi/openmpt/openmpt.rb', line 33
def self.error_string(error)
ptr = API.openmpt_error_string(error)
ptr.read_string
ensure
API.openmpt_free_string(ptr)
end
|
.extension_supported?(ext) ⇒ Boolean
25
26
27
|
# File 'lib/ffi/openmpt/openmpt.rb', line 25
def self.extension_supported?(ext)
API.openmpt_is_extension_supported(ext.to_s) == 1
end
|
.library_version ⇒ Object
9
10
11
12
|
# File 'lib/ffi/openmpt/openmpt.rb', line 9
def self.library_version
maj, min, pat = [API.openmpt_get_library_version].pack('L>').unpack('CCS')
[maj, min, pat >> 8]
end
|
.probe_file(filename) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ffi/openmpt/openmpt.rb', line 40
def self.probe_file(filename)
probe_size = API.
data = ::File.binread(filename, probe_size)
data_size = ::File.size(filename)
probe_result = API.(
API::OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT,
data,
data.bytesize,
data_size,
API::LogSilent, nil, API::ErrorIgnore, nil, nil, nil
)
probe_result == API::OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS
end
|
.supported_extensions ⇒ Object
18
19
20
21
22
23
|
# File 'lib/ffi/openmpt/openmpt.rb', line 18
def self.supported_extensions
ptr = API.openmpt_get_supported_extensions
ptr.read_string.split(';').map(&:to_sym)
ensure
API.openmpt_free_string(ptr)
end
|
.transient_error?(error) ⇒ Boolean
29
30
31
|
# File 'lib/ffi/openmpt/openmpt.rb', line 29
def self.transient_error?(error)
API.openmpt_error_is_transient(error) == 1
end
|