* 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:
+47
-39
@@ -2114,92 +2114,100 @@ BRoster::_TranslateRef(entry_ref *ref, BMimeType *appMeta,
|
||||
// resolve ref, if necessary
|
||||
BEntry entry;
|
||||
status_t error = entry.SetTo(ref, false);
|
||||
if (error == B_OK && entry.IsSymLink()) {
|
||||
// ref refers to a link
|
||||
error = entry.SetTo(ref, true);
|
||||
if (error == B_OK)
|
||||
error = entry.GetRef(ref);
|
||||
if (error != B_OK)
|
||||
error = B_LAUNCH_FAILED_NO_RESOLVE_LINK;
|
||||
return error;
|
||||
|
||||
if (entry.IsSymLink()) {
|
||||
// ref refers to a link
|
||||
if (entry.SetTo(ref, true) != B_OK || entry.GetRef(ref) != B_OK)
|
||||
return B_LAUNCH_FAILED_NO_RESOLVE_LINK;
|
||||
}
|
||||
|
||||
// init node
|
||||
BNode node;
|
||||
if (error == B_OK)
|
||||
error = node.SetTo(ref);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// get permissions
|
||||
mode_t permissions;
|
||||
if (error == B_OK)
|
||||
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);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// get the app's signature via a BAppFileInfo
|
||||
BAppFileInfo appFileInfo;
|
||||
if (error == B_OK)
|
||||
error = appFileInfo.SetTo(appFile);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
char type[B_MIME_TYPE_LENGTH];
|
||||
bool isDocument = true;
|
||||
|
||||
if (error == B_OK) {
|
||||
// don't worry, if the file doesn't have a signature, just
|
||||
// unset the supplied object
|
||||
if (appFileInfo.GetSignature(type) == B_OK)
|
||||
if (appFileInfo.GetSignature(type) == B_OK) {
|
||||
error = appMeta->SetTo(type);
|
||||
else
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
} else
|
||||
appMeta->Unset();
|
||||
|
||||
if (appFileInfo.GetType(type) == B_OK
|
||||
&& !strcasecmp(type, B_APP_MIME_TYPE))
|
||||
&& !strcasecmp(type, B_APP_MIME_TYPE)) {
|
||||
isDocument = false;
|
||||
}
|
||||
|
||||
if (_wasDocument)
|
||||
*_wasDocument = isDocument;
|
||||
} else {
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// 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 (error != B_OK)
|
||||
return error;
|
||||
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
|
||||
if (!foundPreferredApp) {
|
||||
// no preferred app or existing one was not found -- we
|
||||
// need to get the file's type
|
||||
|
||||
error = B_OK; // reset error.
|
||||
|
||||
char fileType[B_MIME_TYPE_LENGTH];
|
||||
|
||||
// get the type from the file, or guess a type
|
||||
if (nodeInfo.GetType(fileType) != B_OK)
|
||||
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
|
||||
if (error == B_OK) {
|
||||
error = _TranslateType(fileType, appMeta, appRef,
|
||||
appFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
error = _TranslateType(fileType, appMeta, appRef, appFile);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
if (_wasDocument)
|
||||
*_wasDocument = true;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _TranslateType
|
||||
|
||||
Reference in New Issue
Block a user