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)
path
A string, the full path to the file system object (file, directory, symlink) for which to find a Node.
node
A Node to copy.
copy
Copies the contents of another object into this object.
Perl
$node->copy($copy_from);
Python
node.copy(copy_from)
copy_from
A Node to copy.
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()
name
,oldname
,newname
The attribute name.
data
The value to store.
type
The type if the data. If not provided to
WriteAttr
, it will be guessed using the guess_type algorithm. If not provided toReadAttr
, the type of the stored data will be used.offset
The offset to write to. The Be Book recommends to always leave this at
0
, but according to a comment in the Haiku source code, this can cause problems if the attribute data is "backed up by a real file". I'm not sure what "backed up by a real file" means (stored in a real file, as opposed to stored in the attribute block, maybe?), but I would imagine0
is okay in most cases.
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()
path
A full path.
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.