Sends the String
msg
to the source
returns the socket level as an integer.
p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level #=> 41
— Registry.create
(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
— Registry.create
(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| … }
Create or open the registry key subkey under key. You can use predefined key HKEY_* (see Constants
)
If subkey is already exists, key is opened and Registry#created?
method will return false.
If block is given, the key is closed automatically.
Returns if key is created ((newly)). (see Registry.create
) – basically you call create then when you call created? on the instance returned it will tell if it was successful or not
Same as Win32::Registry.create
(self, subkey, desired, opt)
Read a registry value named name and return array of [ type, data ]. When name is nil, the ‘default’ value is read. type is value type. (see Win32::Registry::Constants
module) data is value data, its class is: :REG_SZ, REG_EXPAND_SZ
String
:REG_MULTI_SZ
Array of String
:REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD
Integer
:REG_BINARY, REG_NONE
String (contains binary data)
When rtype is specified, the value type must be included by rtype array, or TypeError
is raised.
Read a REG_SZ(read_s
), REG_DWORD(read_i
), or REG_BINARY(read_bin
) registry value named name.
If the values type does not match, TypeError
is raised.
Read a REG_SZ(read_s
), REG_DWORD(read_i
), or REG_BINARY(read_bin
) registry value named name.
If the values type does not match, TypeError
is raised.
Resets and initializes the stream. All data in both input and output buffer are discarded.
Returns compression level.
Resets the position of the file pointer to the point created the GzipReader
object. The associated IO
object needs to respond to the seek
method.
See Zlib::GzipReader
documentation for a description.
Reads at most maxlen bytes from the gzipped stream but it blocks only if gzipreader has no data immediately available. If the optional outbuf argument is present, it must reference a String
, which will receive the data. It raises EOFError
on end of file.
See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
See Zlib::GzipReader
documentation for a description.
Returns an integer representing the permission bits of stat. The meaning of the bits is platform dependent; on Unix systems, see stat(2)
.
File.chmod(0644, "testfile") #=> 1 s = File.stat("testfile") sprintf("%o", s.mode) #=> "100644"
Returns true
if stat is a directory, false
otherwise.
File.stat("testfile").directory? #=> false File.stat(".").directory? #=> true
Returns true
if stat is readable by the effective user id of this process.
File.stat("testfile").readable? #=> true
If the buffer has 0 size: it is created by ::new
with size 0, or with ::for
from an empty string. (Note that empty files can’t be mapped, so the buffer created with ::map
will never be empty.)
If the buffer is shared, meaning it references memory that can be shared with other processes (and thus might change without being modified locally).
# Create a test file: File.write('test.txt', 'test') # Create a shared mapping from the given file, the file must be opened in # read-write mode unless we also specify IO::Buffer::READONLY: buffer = IO::Buffer.map(File.open('test.txt', 'r+'), nil, 0) # => #<IO::Buffer 0x00007f1bffd5e000+4 EXTERNAL MAPPED SHARED> # Write to the buffer, which will modify the mapped file: buffer.set_string('b', 0) # => 1 # The file itself is modified: File.read('test.txt') # => "best"
Resizes a buffer to a new_size
bytes, preserving its content. Depending on the old and new size, the memory area associated with the buffer might be either extended, or rellocated at different address with content being copied.
buffer = IO::Buffer.new(4) buffer.set_string("test", 0) buffer.resize(8) # resize to 8 bytes # => # #<IO::Buffer 0x0000555f5d1a1630+8 INTERNAL> # 0x00000000 74 65 73 74 00 00 00 00 test....
External buffer (created with ::for
), and locked buffer can not be resized.
If the buffer references memory, release it back to the operating system.
for a mapped buffer (e.g. from file): unmap.
for a buffer created from scratch: free memory.
for a buffer created from string: undo the association.
After the buffer is freed, no further operations can’t be performed on it.
You can resize a freed buffer to re-allocate it.
buffer = IO::Buffer.for('test') buffer.free # => #<IO::Buffer 0x0000000000000000+0 NULL> buffer.get_value(:U8, 0) # in `get_value': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.get_string # in `get_string': The buffer is not allocated! (IO::Buffer::AllocationError) buffer.null? # => true
Read at least length
bytes from the io
, into the buffer starting at offset
. If an error occurs, return -errno
.
If length
is not given or nil
, it defaults to the size of the buffer minus the offset, i.e. the entire buffer.
If length
is zero, exactly one read
operation will occur.
If offset
is not given, it defaults to zero, i.e. the beginning of the buffer.
IO::Buffer.for('test') do |buffer| p buffer # => # <IO::Buffer 0x00007fca40087c38+4 SLICE> # 0x00000000 74 65 73 74 test buffer.read(File.open('/dev/urandom', 'rb'), 2) p buffer # => # <IO::Buffer 0x00007f3bc65f2a58+4 EXTERNAL SLICE> # 0x00000000 05 35 73 74 .5st end