To create a BBitmap
you must have a be_app
object ; the object needn't be running.
| Class Overview |
BAppFileInfo();
BAppFileInfo(BFile
* file);
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()
.
~BAppFileInfo();
Destroys the object. The BFile
that was used to initialize this object isn't touched.
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…
B_SINGLE_LAUNCH
B_MULTIPLE_LAUNCH
B_EXCLUSIVE_LAUNCH
…plus either of these two:
B_BACKGROUND_APP
B_ARGV_ONLY
See the BApplication
class for details on the meanings of these constants.
Return Code | Description |
---|---|
| Everything went fine. |
| The object is not properly initialized. |
|
|
| The attribute/resources the flags are stored in have the wrong type. |
| No application flags are set on the file. |
status_t GetIcon(BBitmap
* icon,
icon_size which) const;
status_t SetIcon(BBitmap
* icon,
icon_size which);
status_t GetIconForType(const char* file_type,
BBitmap
* icon,
icon_size which) const;
status_t SetIconForType(const char* file_type,
BBitmap
* icon,
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
= newBBitmap
(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()
.
Return Code | Description |
---|---|
| Success |
|
( |
|
( |
| The object is not properly initialized. |
An application's preferred app must be itself; an add-on is more flexible. For syntax, see
BNodeInfo::SetPreferredApp()
.
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 Code | Description |
---|---|
| Success. |
|
( |
|
( |
status_t GetSupportedTypes(BMessage
* types) const;
status_t SetSupportedTypes(const BMessage
* types);
status_t SetSupportedTypes(const BMessage
* types,
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:
Field | Type | Description |
---|---|---|
types (array) | B_STRING_TYPE | An 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
; uint32i
=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 Code | Description |
---|---|
| Success. |
| Insufficient memory to copy the types. |
See Also:
Supports()
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()
.
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 { uint32major
; uint32middle
; uint32minor
; uint32variety
; uint32internal
; charshort_info
[64]; charlong_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:
Constant | Description |
---|---|
| 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 Code | Description |
---|---|
| The version_info was found or set. |
|
( |
status_t InitCheck() const;
Returns the status of the most recent initialization.
Return Code | Description |
---|---|
| The object was successfully initialized. |
| The object is uninitialized. |
bool IsSupportedType(const char* type) const;
bool Supports(BMimeType
* type) 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()
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:
B_USE_ATTRIBUTES
B_USE_RESOURCES
B_USE_BOTH
IsUsingAttributes()
and IsUsingResources()
return true
if the
BAppFileInfo
object is storing information in the designated location and
false
otherwise.
status_t SetTo(BFile
* file);
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 Code | Description |
---|---|
| The object was successfully initialized. |
|
|
Declared in: storage/AppFileInfo.h
Constant | Description |
---|---|
| 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.
Declared in: storage/AppFileInfo.h
struct version_info { uint32major
; uint32middle
; uint32minor
; uint32variety
; uint32internal
; charshort_info
[64]; charlong_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.