Derived From:BNodeInfo
Mix-in Classes:None
Declared In:storage/AppFileInfo.h
Class Overview

Constructor and Destructor


BAppFileInfo(); BAppFileInfo(BFilefile);

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

The BFile version intializes the BAppFileInfo by passing the argument to SetTo().



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

Member Functions

GetAppFlags(), SetAppFlags()

status_t GetAppFlags(uint32* flags) const;status_t SetAppFlags(uint32 flags);

These functions get and set the executable's "app flags." These are the constants that determine whether an executable can only be launched once, whether it runs in the background, and so on. The app flag constants are defined in app/Roster.h; the flags must include one of the following…




…plus either of these two:



See the BApplication class for details on the meanings of these constants.

Return CodeDescription


Everything went fine.


The object is not properly initialized.


NULL flags.


The attribute/resources the flags are stored in have the wrong type.


No application flags are set on the file.

GetIcon(), SetIcon(), GetIconForType(), SetIconForType()

status_t GetIcon(BBitmapicon,
                 icon_size which) const;
status_t SetIcon(BBitmapicon,
                 icon_size which);
status_t GetIconForType(const char* file_type,
                        icon_size which) const;
status_t SetIconForType(const char* file_type,
                        icon_size which);

GetIcon() and SetIcon() get and set the icons that are represent the executable. GetIconForType() and SetIconForType() get and set the icons that the executable uses when it writes (or otherwise "takes possession of") a file of the given type, identified by file_type. You specify which icon you want (large or small) by passing B_LARGE_ICON or B_MINI_ICON as the which argument.

The icon is passed in or returned through the icon argument. The bitmap must be the proper size: 32x32 for the large icon, 16x16 for the small one. In BRect lingo, that's BRect(0, 0, 31, 31) and BRect(0, 0, 15, 15). The bitmap's color space must be B_CMAP8. For example:

BBitmap* bitmap = new BBitmap(BRect(0,0,31,31), B_CMAP8);
appFileInfo.GetIcon(bitmap, B_LARGE_ICON);

You can remove an icon by passing NULL as the icon argument to SetIcon().


To create a BBitmap you must have a be_app object ; the object needn't be running.

Return CodeDescription




(Get…()) NULL BBitmap, or invalid file_type.


(Set…()) The bitmap data isn't the proper size.


The object is not properly initialized.

GetPreferredApp(), SetPreferredApp()

An application's preferred app must be itself; an add-on is more flexible. For syntax, see BNodeInfo::SetPreferredApp().

GetSignature() , SetSignature()

status_t GetSignature(char* signature) const;status_t SetSignature(const char* signature);

These functions get and set the executable's MIME type signature. The signature buffer you pass to GetSignature() should be at least B_MIME_TYPE_LENGTH characters long; the SetSignature() buffer must be no longer than that.

When you set an executable's signature, the signature is installed in the File Type database if it's not there already. The old signature isn't removed from the database.

Return CodeDescription




(Get…()) The executable doesn't have a signature.


(Set…()) signature is too long.

GetSupportedTypes(), SetSupportedTypes()

status_t GetSupportedTypes(BMessagetypes) const;
status_t SetSupportedTypes(const BMessagetypes); status_t SetSupportedTypes(const BMessagetypes,
                           bool sync_all);

These functions get and set the MIME file types that this executable can read and/or write. The types BMessage that you pass in looks like this:

types (array)B_STRING_TYPEAn array of MIME strings.

GetSupportedTypes() copies the types into the types field; SetSupportedTypes() reads them from the field. The message's command constants (its what value) is ignored.

Here we print an executable's supported types:

BMessage msg;
uint32 i=0;
char* ptr;

if (appFileInfo.GetSupportedTypes(&msg) != B_OK)
   /* Handle the error. */

while (msg.FindString("types", i++, &ptr) == B_OK)
   printf("> Supported Type: %sn", ptr);

If SetSupportedTypes() names a type that doesn't already appear in the File Type database, the new type is added to the database and its preferred handler is set to the executable that this BAppFileInfo object represents.


SetSupportedTypes() clobbers an executable's existing set of supported types. If you want to augment an executable's supported types, you should retrieve the existing set, add the new ones, and then call SetSupportedTypes().

Return CodeDescription




Insufficient memory to copy the types.

See Also: Supports()

GetType(), SetType()

Implementation detail; see "Functions Inherited From BNodeInfo". An executable's default file type (for both applications and add-ons) is B_APP_MIME_TYPE. This value mustn't be changed. For syntax, see BNodeInfo::SetType().

GetVersionInfo(), SetVersionInfo()

status_t GetVersionInfo(version_info* info,
                        version_kind kind) const;
status_t SetVersionInfo(const version_info* info,
                        version_kind kind);

The functions get and set the application's "version info." The information is recorded in the version_info structure:

struct version_info {
   uint32 major;
   uint32 middle;
   uint32 minor;
   uint32 variety;
   uint32 internal;
   char short_info[64];
   char long_info[256];

The field names (and types) provide suggestions for the type of info they want to store.

There are two kinds of version info, as specified by the kind argument:



Provides information about this specific app.


Provides information about the "suite," or other grouping of apps, that this app belongs to.

Again, the uses of the two kinds is up to the app developer—currently, nothing in the BeOS depends on any information being stored in either version_info structure.

Return CodeDescription


The version_info was found or set.


(Get…()) the app doesn't have the requested version info.


status_t InitCheck() const;

Returns the status of the most recent initialization.

Return CodeDescription


The object was successfully initialized.


The object is uninitialized.

IsSupportedType(), Supports()

bool IsSupportedType(const char* type) const;bool Supports(BMimeTypetype) const;

Returns true if the app supports the given MIME type and false if it doesn't. IsSupportedType() always returns true if the application supports "application/octet-stream", while Supports() returns true only if type is explicitly supported.

See Also: GetSupportedTypes(), SetSupportedTypes()

SetInfoLocation(), IsUsingAttributes(), IsUsingResources()

void SetInfoLocation(info_location loc);bool IsUsingAttributes() const;bool IsUsingResources() const;

SetInfoLocation() sets the location where the BAppFileInfo object stores its information. It can store them as either attributes, resources, or both. loc takes the following values:




IsUsingAttributes() and IsUsingResources() return true if the BAppFileInfo object is storing information in the designated location and false otherwise.


status_t SetTo(BFilefile);

Initializes the BAppFileInfo object by pointing it to file, which must be a valid (initialized) BFile object, and must not be locked. The BFile is not copied, or re-opened by BAppFileInfo. In particular, the BAppFileInfo uses file's file descriptor, and doesn't destroy the BFile object when it (the BAppFileInfo) is destroyed or reinitialized.


The BAppFileInfo object doesn't check to make sure that the file that you pass in really is an executable. Passing in a non-executable (a plain file, a directory, etc.) could corrupt the file.

Return CodeDescription


The object was successfully initialized.


file is invalid (uninitialized).


Version Kinds

Declared in: storage/AppFileInfo.h



Records information about a specific application.


Records information about a "suite," or other grouping of applications, that the application belongs to.

These constants are used when setting or retrieving the version information attached to an application. There are two version information records for each application, and these two constants select which one you wish to reference. Although there is no prescribed use for these structures or their constants, it is suggested that B_APP_VERSION_KIND be used for application-specific version information, and B_SYSTEM_VERSION_KIND be used for information about the suite of applications to which the application belongs.

Defined Types


Declared in: storage/AppFileInfo.h

struct version_info {
    uint32    major;
    uint32    middle;
    uint32    minor;
    uint32    variety;
    uint32    internal;
    char      short_info[64];
    char      long_info[256];

The version_info structure is used to contain version information about an application. Although none of these fields have prescribed uses, and you can use them for anything you want, their names do hint at their suggested uses.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.