Haiku API Bindings
Node
Not logged in

Documentation | StorageKit | Node

SYNOPSIS

Perl

use HaikuR1::Node;

my $attr_data = $node->ReadAttr(
    name => $name,
    type => $type,
    offset => $offset,
    len => $len,
);

Python

from HaikuR1.StorageKit import Node

atr_data = node.ReadAttr(
    name = name,
    type = type,
    offset = offset,
    len = len,
)

DESCRIPTION

Exposes the BNode object.

For more information on Node, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a Node.

Perl

HaikuR1::Node->new();
HaikuR1::Node->new($path);
HaikuR1::Node->new($node);

Python

Node()
Node(path)
Node(node)

copy

Copies the contents of another object into this object.

Perl

$node->copy($copy_from);

Python

node.copy(copy_from)

Attributes

WriteAttr

ReadAttr

WriteAttrString

ReadAttrString

RemoveAttr

RenameAttr

GetAttrInfo

Attrs

GetNextAttrName

RewindAttrs

These methods do what you expect.

GetAttrInfo returns a native map with two fields: type and size.

Attrs is not part of the Haiku API. It is a convenience method implemented in the glue code, allowing you to get all the attribute names at once, wrapped up in a native list. (Internally it uses RewindAttrs and GetNextAttrName.)

The glue code will automatically convert data types for you, so from the point of view of your code, there is little difference between ReadAttr and ReadAttrString, or between WriteAttr and WriteAttrString, when you know that the attribute in question is a string. The String versions are slightly more efficient, but unless you're using a really slow computer, you would never notice the difference.

Perl

$node->WriteAttr($name, $data, $type, $offset);
$node->ReadAttr($name, $type, $offset);
$node->WriteAttrString($name, $data);
$node->ReadAttrString($name);
$node->RemoveAttr($name);
$node->RenameAttr($oldname, $newname);
$node->GetAttrInfo($name);
$node->Attrs();
$node->GetNextAttrName();
$node->RewindAttrs();

Python

node.WriteAttr(name, data, type, offset)
node.ReadAttr(name, type, offset)
node.WriteAttrString(name, data)
node.ReadAttrString(name)
node.RemoveAttr(name)
node.RenameAttr(oldname, newname)
node.GetAttrInfo(name)
node.Attrs()
node.GetNextAttrName()
node.RewindAttrs()

Dup

Returns a duplicated copy of the file descriptor. You probably won't have much use for this in native code.

Perl

$node->Dup();

Python

node.Dup()

Lock

Unlock

Locks or unlocks the underlying node. Locking a node means that no open calls can be made on it. This means no one else (besides the Node object that locked it) can read or write the node's data or attributes.

If someone else already has this node open, then the call to Lock will fail.

Perl

$node->Lock();
$node->Unlock();

Python

node.Lock()
node.Unlock()

SetTo

Unset

SetTo Updates the Node object to refer to the node underlying the given file, directory, or symlink. Unset "empties" the Node, so that it no longer refers to any node.

Perl

$node->SetTo($path);
$node->Unset();

Python

node.SetTo(path)
node.Unset()

Sync

If there are any pending disk operations for the underlying node, this forces them to be completed.

Perl

$node->Sync();

Python

node.Sync()

STATABLE INTERFACE

Node inherits the methods and hooks of Statable.

OPERATORS

==

Returns true if the Node objects refer to the same node.

!=

Returns true if the Node objects do not refer to the same node.