The Storage Kit: BNodeInfo

Derived from: (none)

Declared in: be/nustorage/NodeInfo.h

Library: libbe.so


Overview

BNodeInfo provides file type information about a particular node; specifically:

Except for the Tracker icon, all this information can also be set through the BNodeInfo class. None of the information is passed on to the File Type database; if you want to record a node's file type information with the database, you have to create a BMimeType object (based on the node's file type) and go from there.


Initialization

You initialize a BNodeInfo object by passing it a BNode object. Although you can pass any flavor of node, you typically only care about files; passing a BFile object (or any subclass of BNode) is, of course, acceptable. The BNodeInfo object maintains its own pointer to the BNode you pass in. You don't have to avoid touching the BNode while a BNodeInfo is looking at it (or changing it); the only thing you shouldn't do is delete the BNode.

BNodeInfo doesn't care if the BNode is locked--there's no particular reason to lock the BNode before passing it in, but the BNodeInfo won't balk if you do. If you pass in a BFile object, BNodeInfo does not obey the BFile's read/write flags. For example, you can set the node info for a BFile even if you've opened it in read-only mode.


Node Info equals Attributes

The BNodeInfo class does nothing more than look in a node's attributes for the information it sets or gets. The attribute names for the various information particles are given in the function descriptions, below. If you want, you can bypass BNodeInfo and get the node information directly by passing the attribute names to BNode's ReadAttr() and WriteAttr() functions.

The one exception to this is GetTrackerIcon(): This function starts by looking in the node's attributes, but then it goes out hunting if it has to (if the icon isn't found in the attributes).


BAppFileInfo

BNodeInfo has a single subclass: BAppFileInfo. You use a BAppFileInfo object to get more information about a specific executable image (file).


Errors

Unlike most of the other Storage Kit classes, when you ask a BNodeInfo to retrieve some information by reference, the object doesn't clear the reference argument if it fails. Because of this, you should always check the error code that's returned by the Get... functions.


Constructor and Destructor


BNodeInfo()


      BNodeInfo(void)
      BNodeInfo(BNode *node)

The default constructor creates a new, uninitialized BNodeInfo object. To initialize you have to follow this construction with a call to SetTo().

The BNode version intializes the BNodeInfo by passing the argument to SetTo(); see SetTo() for details(and error codes).


~BNodeInfo()


      ~BNodeInfo(void)

Destroys the object. The BNode object that was used to initialize the object isn't touched.


Member Functions


GetIcon(), SetIcon(), GetTrackerIcon()


      virtual status_t GetIcon(BBitmap *icon, icon_size which = B_LARGE_ICON) const
      virtual status_t SetIcon(const BBitmap *icon, icon_size which = B_LARGE_ICON) 

      status_t GetTracker Icon(BBitmap *icon, icon_size which = B_LARGE_ICON)
      static status_t GetTracker Icon(entry_ref *ref, 
         BBitmap *icon, 
         icon_size which = B_LARGE_ICON)

GetIcon() and SetIcon() get and set the icon data that's stored in the node's attributes. You specify which icon you want (large or small) by passing B_LARGE_ICON or B_SMALL_ICON as the which argument. The icon is passed in or returned through the icon argument. The icon data is copied out of or into the BBitmap object.

If you're setting the icon, the bitmap must be the proper size: 32x32 for the large icon, 16x16 for the small one. If you want to erase the node's icon, pass NULL as the icon argument to SetIcon().

The icon attributes are stored as "BEOS: L:STD_ICON" (large icon) and "BEOS: M:STD_ICON" (small, or "mini" icon).

GetTrackerIcon() finds the icon that the Tracker uses to display the node. The static version lets you identify the node as an entry_ref. Both versions follow the same ordered path in trying to find the icon:

The function doesn't tell you which branch of the path it found the icon in.

RETURN CODES


GetPreferredApp(), SetPreferredApp()


      status_t GetPreferredApp(char *signature, app_verb verb = B_OPEN) const
      status_t SetPreferredApp(const char *signature, app_verb verb = B_OPEN)

These functions get and set the node's "preferred app." This is the application that's used to access the node when, for example, the user double-clicks the node in a Tracker window.

If a node doesn't have a preferred app, the Tracker looks in the File Type database for an app that can open the node's file type.

The attribute that stores the preferred app is named "BEOS:PREF_APP".

RETURN CODES


GetType(), SetType()


      virtual status_t GetType(char *type) const
      virtual status_t SetType(const char *type)

These functions get and set the node's file type. The file type, passed in or returned through type, is a MIME string.

The attribute that stores the file type is named "BEOS:TYPE".

RETURN CODES


InitCheck()


      status_t InitCheck(void) const

Returns the status of the most recent initialization.

RETURN CODES


SetTo()


      status_t SetTo(BNode *node)

Initializes the BNodeInfo object by pointing it to node, which must be a valid (initialized) BNode object. The BNodeInfo maintains its own BNode pointer: You shouldn't delete node while the BNodeInfo is accessing it; other changes to the BNode are permitted, but you may want to avoid such antics. Re-initializing a BNodeInfo doesn't affect the previous BNode object.

RETURN CODES






The Be Book, in lovely HTML, for the BeOS Preview Release.

Copyright © 1997 Be, Inc. All rights reserved.

Be is a registered trademark; BeOS, BeBox, BeWare, GeekPort, the Be logo, and the BeOS logo are trademarks of Be, Inc.

Last modified July 17, 1997.