* BRoster::_TranslateRef(): Changed error handling style. No functional change.
* Automatic white space cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30623 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+80
-72
@@ -2114,92 +2114,100 @@ BRoster::_TranslateRef(entry_ref *ref, BMimeType *appMeta,
|
|||||||
// resolve ref, if necessary
|
// resolve ref, if necessary
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
status_t error = entry.SetTo(ref, false);
|
status_t error = entry.SetTo(ref, false);
|
||||||
if (error == B_OK && entry.IsSymLink()) {
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (entry.IsSymLink()) {
|
||||||
// ref refers to a link
|
// ref refers to a link
|
||||||
error = entry.SetTo(ref, true);
|
if (entry.SetTo(ref, true) != B_OK || entry.GetRef(ref) != B_OK)
|
||||||
if (error == B_OK)
|
return B_LAUNCH_FAILED_NO_RESOLVE_LINK;
|
||||||
error = entry.GetRef(ref);
|
|
||||||
if (error != B_OK)
|
|
||||||
error = B_LAUNCH_FAILED_NO_RESOLVE_LINK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init node
|
// init node
|
||||||
BNode node;
|
BNode node;
|
||||||
if (error == B_OK)
|
error = node.SetTo(ref);
|
||||||
error = node.SetTo(ref);
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
// get permissions
|
// get permissions
|
||||||
mode_t permissions;
|
mode_t permissions;
|
||||||
if (error == B_OK)
|
error = node.GetPermissions(&permissions);
|
||||||
error = node.GetPermissions(&permissions);
|
if (error != B_OK)
|
||||||
if (error == B_OK) {
|
return error;
|
||||||
if ((permissions & S_IXUSR) && node.IsFile()) {
|
|
||||||
// node is executable and a file -- we're done
|
|
||||||
*appRef = *ref;
|
|
||||||
error = appFile->SetTo(appRef, B_READ_ONLY);
|
|
||||||
|
|
||||||
// get the app's signature via a BAppFileInfo
|
if ((permissions & S_IXUSR) && node.IsFile()) {
|
||||||
BAppFileInfo appFileInfo;
|
// node is executable and a file -- we're done
|
||||||
if (error == B_OK)
|
*appRef = *ref;
|
||||||
error = appFileInfo.SetTo(appFile);
|
error = appFile->SetTo(appRef, B_READ_ONLY);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
char type[B_MIME_TYPE_LENGTH];
|
// get the app's signature via a BAppFileInfo
|
||||||
bool isDocument = true;
|
BAppFileInfo appFileInfo;
|
||||||
|
error = appFileInfo.SetTo(appFile);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
if (error == B_OK) {
|
char type[B_MIME_TYPE_LENGTH];
|
||||||
// don't worry, if the file doesn't have a signature, just
|
bool isDocument = true;
|
||||||
// unset the supplied object
|
|
||||||
if (appFileInfo.GetSignature(type) == B_OK)
|
|
||||||
error = appMeta->SetTo(type);
|
|
||||||
else
|
|
||||||
appMeta->Unset();
|
|
||||||
if (appFileInfo.GetType(type) == B_OK
|
|
||||||
&& !strcasecmp(type, B_APP_MIME_TYPE))
|
|
||||||
isDocument = false;
|
|
||||||
}
|
|
||||||
if (_wasDocument)
|
|
||||||
*_wasDocument = isDocument;
|
|
||||||
} else {
|
|
||||||
// the node is not exectuable or not a file
|
|
||||||
// init a node info
|
|
||||||
BNodeInfo nodeInfo;
|
|
||||||
if (error == B_OK)
|
|
||||||
error = nodeInfo.SetTo(&node);
|
|
||||||
char preferredApp[B_MIME_TYPE_LENGTH];
|
|
||||||
if (error == B_OK) {
|
|
||||||
// if the file has a preferred app, let _TranslateType() find
|
|
||||||
// it for us
|
|
||||||
bool foundPreferredApp = false;
|
|
||||||
if (nodeInfo.GetPreferredApp(preferredApp) == B_OK) {
|
|
||||||
error = _TranslateType(preferredApp, appMeta, appRef,
|
|
||||||
appFile);
|
|
||||||
if (error == B_OK)
|
|
||||||
foundPreferredApp = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundPreferredApp) {
|
// don't worry, if the file doesn't have a signature, just
|
||||||
// no preferred app or existing one was not found -- we
|
// unset the supplied object
|
||||||
// need to get the file's type
|
if (appFileInfo.GetSignature(type) == B_OK) {
|
||||||
|
error = appMeta->SetTo(type);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
} else
|
||||||
|
appMeta->Unset();
|
||||||
|
|
||||||
error = B_OK; // reset error.
|
if (appFileInfo.GetType(type) == B_OK
|
||||||
|
&& !strcasecmp(type, B_APP_MIME_TYPE)) {
|
||||||
char fileType[B_MIME_TYPE_LENGTH];
|
isDocument = false;
|
||||||
|
|
||||||
// get the type from the file, or guess a type
|
|
||||||
if (nodeInfo.GetType(fileType) != B_OK)
|
|
||||||
error = _SniffFile(ref, &nodeInfo, fileType);
|
|
||||||
|
|
||||||
// now let _TranslateType() do the actual work
|
|
||||||
if (error == B_OK) {
|
|
||||||
error = _TranslateType(fileType, appMeta, appRef,
|
|
||||||
appFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_wasDocument)
|
|
||||||
*_wasDocument = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_wasDocument)
|
||||||
|
*_wasDocument = isDocument;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
|
// the node is not exectuable or not a file
|
||||||
|
// init a node info
|
||||||
|
BNodeInfo nodeInfo;
|
||||||
|
error = nodeInfo.SetTo(&node);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
// if the file has a preferred app, let _TranslateType() find
|
||||||
|
// it for us
|
||||||
|
char preferredApp[B_MIME_TYPE_LENGTH];
|
||||||
|
if (nodeInfo.GetPreferredApp(preferredApp) == B_OK
|
||||||
|
&& _TranslateType(preferredApp, appMeta, appRef, appFile) == B_OK) {
|
||||||
|
if (_wasDocument)
|
||||||
|
*_wasDocument = true;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no preferred app or existing one was not found -- we
|
||||||
|
// need to get the file's type
|
||||||
|
|
||||||
|
// get the type from the file, or guess a type
|
||||||
|
char fileType[B_MIME_TYPE_LENGTH];
|
||||||
|
if (nodeInfo.GetType(fileType) != B_OK) {
|
||||||
|
error = _SniffFile(ref, &nodeInfo, fileType);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now let _TranslateType() do the actual work
|
||||||
|
error = _TranslateType(fileType, appMeta, appRef, appFile);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (_wasDocument)
|
||||||
|
*_wasDocument = true;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _TranslateType
|
// _TranslateType
|
||||||
|
|||||||
Reference in New Issue
Block a user