93 lines
14 KiB
HTML
93 lines
14 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Storage Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheStorageKit_Overview.html" title="The Storage Kit" /><link rel="prev" href="TheStorageKit_Overview_Mime_And_File_Types.html" title="Mime And File Types" /><link rel="next" href="BDirectory_Overview.html" title="BDirectory" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheStorageKit_Overview_Mime_And_File_Types.html" title="Mime And File Types"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BDirectory_Overview.html" title="BDirectory"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Storage Kit</div></div><div id="headerB">Prev: <a href="TheStorageKit_Overview_Mime_And_File_Types.html">Mime And File Types</a> Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a> Next: <a href="BDirectory_Overview.html">BDirectory</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BAppFileInfo_Overview"></a>BAppFileInfo</h2></div></div></div><a id="id601382" class="indexterm"></a><p>
|
||
<a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> lets you get and set the signature, supported types, icons,
|
||
app flags, and version info that's stored in an executable file's
|
||
attributes and/or resources. The object also knows how to write certain
|
||
particles of information into the File Type database and, if the
|
||
executable is the progenitor of a running application, into the app
|
||
roster (<a class="link" href="BRoster.html#BRoster_be_roster" title="be_roster"><code class="varname">be_roster</code></a>).
|
||
</p><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p>Most apps won't ever need to create or use a
|
||
<a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> object.
|
||
Setting an executable's info is best left to the file's creator, through
|
||
the use of resource data that's compiled into the executable. Even the
|
||
act of looking at a file's info should be rare for a normal application.</p></div></div></div><div class="admonition warning"><div class="title">Warning</div><div class="graphic"><img class="icon" alt="Warning" width="32" src="./images/admonitions/Stop_32.png" /><div class="text"><p><a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a>
|
||
objects should only be used to examine and set the
|
||
characteristics of applications and add-ons. Using the object on a
|
||
non-executable file could corrupt the file.</p></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BAppFileInfo_Initialization"></a>Initialization</h3></div></div></div><p>
|
||
You initialize a <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> object by passing it a
|
||
<a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a>
|
||
object that represents an application or add-on. The
|
||
<a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a> needn't be open for
|
||
reading, but it must be open for writing if you want to set information.
|
||
The <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> object doesn't take over ownership of the
|
||
<a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a> that you
|
||
pass it; in particular, deleting a <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> doesn't cause the
|
||
underlying <a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a> to be deleted.
|
||
</p><p>
|
||
To initialize a <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> to point to the executable of
|
||
<a class="link" href="BApplication.html#BApplication_be_app" title="be_app"><code class="varname">be_app</code></a>, you do
|
||
this:
|
||
</p><pre class="programlisting example cpp"><span class="comment">/* To get app file info for be_app. */</span>
|
||
<span class="type"><a class="link" href="BRoster.html#app_info" title="app_info"><span class="type">app_info</span></a></span> <code class="varname">appInfo</code>;
|
||
<code class="classname">BFile</code> <code class="varname">file</code>;
|
||
<a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> <code class="varname">appFileInfo</code>;
|
||
|
||
<code class="varname">be_app</code>-><code class="methodname">GetAppInfo</code>(&<code class="varname">appInfo</code>);
|
||
<code class="varname">file</code>.<code class="methodname">SetTo</code>(&<code class="varname">appInfo.ref</code>, <code class="constant">B_READ_WRITE</code>);
|
||
<code class="varname">appFileInfo</code>.<code class="methodname">SetTo</code>(&<code class="varname">file</code>);</pre></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BAppFileInfo_Attributes_Resources_File_Type_Database"></a>Attributes, Resources, and the File Type Database</h3></div></div></div><p>
|
||
When you ask a <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> object to get some information, it looks in
|
||
its <a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a>'s
|
||
attributes; if the information isn't there, it then looks in
|
||
the file's resources. When you ask it to set some information, the info
|
||
is written as an attribute and also stored as a resource. You can modify
|
||
this behavior through
|
||
<a class="link" href="BAppFileInfo.html#BAppFileInfo_SetInfoLocation" title="SetInfoLocation(), IsUsingAttributes(), IsUsingResources()"><code class="methodname">SetInfoLocation()</code></a>:
|
||
You can tell the object to only access the file's attributes, or to only access the resources.
|
||
</p><p>
|
||
The signature, icons, and supported types that you set through the
|
||
functions provided here (
|
||
<a class="link" href="BAppFileInfo.html#BAppFileInfo_SetSignature"><code class="methodname">SetSignature()</code></a>,
|
||
<a class="link" href="BAppFileInfo.html#BAppFileInfo_SetIcon"><code class="methodname">SetIcon()</code></a>,
|
||
<a class="link" href="BAppFileInfo.html#BAppFileInfo_SetIconForType"><code class="methodname">SetIconForType()</code></a>,
|
||
<a class="link" href="BAppFileInfo.html#BAppFileInfo_SetSupportedTypes"><code class="methodname">SetSupportedTypes()</code></a>)
|
||
are also recorded in the File Types database, as
|
||
described in the various functions.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BAppFileInfo_Functions_Inherited_From_BNodeInfo"></a>Functions Inherited From BNodeInfo</h3></div></div></div><p>
|
||
You should take care when using the following functions (inherited from
|
||
<a class="link" href="BNodeInfo.html" title="BNodeInfo"><code class="classname">BNodeInfo</code></a>):
|
||
</p><dl class="variablelist"><dt><span class="term"><a class="link" href="BNodeInfo.html#BNodeInfo_SetPreferredApp"><code class="methodname">SetPreferredApp()</code></a></span></dt><dd><p>
|
||
Never set an application's preferred app; an
|
||
application is automatically set to be its own preferred app&mdash;it
|
||
won't work otherwise. An add-on's preferred app is usually itself, but
|
||
it doesn't have to be. For example, you could set an add-on's preferred
|
||
app to be the server or application that loads the add-on.
|
||
</p></dd><dt><span class="term"><a class="link" href="BNodeInfo.html#BNodeInfo_SetType"><code class="methodname">SetType()</code></a></span></dt><dd><p>Never set the type of an application or add-on. The type
|
||
is automatically set to be <code class="constant">B_APP_MIME_TYPE</code> (a platform-dependent
|
||
value). If you change the type, your application or add-on will still
|
||
run (probably), but other parts of the system (double-clicked
|
||
documents, for example) may have a hard time finding it.</p></dd></dl></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BAppFileInfo_Errors"></a>Errors</h3></div></div></div><p>
|
||
When you ask a <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> to retrieve 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 <code class="methodname">Get…()</code>
|
||
functions.
|
||
</p><p>
|
||
The common errors that <code class="classname">BAppFileInfo</code> functions return are these:
|
||
</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_OK</code></span></p></td><td><p>Success.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_NO_INIT</code></span></p></td><td><p>The <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a> is uninitialized,
|
||
or its <a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a> isn't open
|
||
for writing.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_ERROR</code></span></p></td><td><p>
|
||
The <a class="link" href="BFile.html" title="BFile"><code class="classname">BFile</code></a> was locked when you
|
||
initialized the <a class="link" href="BAppFileInfo.html" title="BAppFileInfo"><code class="classname">BAppFileInfo</code></a>.
|
||
</p></td></tr></tbody></table><p>
|
||
The info-reading and -writing functions may also return the error codes
|
||
declared by
|
||
<a class="link" href="BNode.html#BNode_ReadAttr" title="ReadAttr(), WriteAttr(), RemoveAttr()"><code class="methodname">BNode::ReadAttr()</code></a> and
|
||
<a class="link" href="BNode.html#BNode_WriteAttr"><code class="methodname">BNode::WriteAttr()</code></a>
|
||
, and by
|
||
<a class="link" href="BResources.html#BResources_WriteTo" title="WriteTo()"><code class="methodname">BResources::WriteTo()</code></a>.
|
||
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheStorageKit_Overview_Mime_And_File_Types.html">Mime And File Types</a> Up: <a href="TheStorageKit_Overview.html">The Storage Kit</a> Next: <a href="BDirectory_Overview.html">BDirectory</a> </div><div id="footerB"><div id="footerBL"><a href="TheStorageKit_Overview_Mime_And_File_Types.html" title="Mime And File Types"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheStorageKit_Overview.html" title="The Storage Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BDirectory_Overview.html" title="BDirectory"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|