Method: Tinkerforge::BrickRED#open_file

Defined in:
lib/tinkerforge/brick_red.rb

#open_file(name_string_id, flags, permissions, uid, gid, session_id) ⇒ Object

Opens an existing file or creates a new file and allocates a new file object for it.

FIXME: name has to be absolute

The reference count of the name string object is increased by one. When the file object gets destroyed then the reference count of the name string object is decreased by one. Also the name string object is locked and cannot be modified while the file object holds a reference to it.

The flags parameter takes a ORed combination of the following possible file flags (in hexadecimal notation):

  • ReadOnly = 0x0001 (O_RDONLY)

  • WriteOnly = 0x0002 (O_WRONLY)

  • ReadWrite = 0x0004 (O_RDWR)

  • Append = 0x0008 (O_APPEND)

  • Create = 0x0010 (O_CREAT)

  • Exclusive = 0x0020 (O_EXCL)

  • NonBlocking = 0x0040 (O_NONBLOCK)

  • Truncate = 0x0080 (O_TRUNC)

  • Temporary = 0x0100

  • Replace = 0x0200

FIXME: explain Temporary and Replace flag

The permissions parameter takes a ORed combination of the following possible file permissions (in octal notation) that match the common UNIX permission bits:

  • UserRead = 00400

  • UserWrite = 00200

  • UserExecute = 00100

  • GroupRead = 00040

  • GroupWrite = 00020

  • GroupExecute = 00010

  • OthersRead = 00004

  • OthersWrite = 00002

  • OthersExecute = 00001

Returns the object ID of the new file object and the resulting error code.



478
479
480
481
482
# File 'lib/tinkerforge/brick_red.rb', line 478

def open_file(name_string_id, flags, permissions, uid, gid, session_id)
  check_validity

  send_request FUNCTION_OPEN_FILE, [name_string_id, flags, permissions, uid, gid, session_id], 'S L S L L S', 11, 'C S'
end