From c2a2369d4947373f08ef45a3c97d974d6379f1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 16 May 2006 01:05:43 +0000 Subject: [PATCH] BAppFileInfo::SetTo() no longer fails in case the resources couldn't be initialized. This allows it to read the attributes (if any) from scripts as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17473 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/AppFileInfo.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/kits/storage/AppFileInfo.cpp b/src/kits/storage/AppFileInfo.cpp index ceb9fae4c0..6964881e0d 100644 --- a/src/kits/storage/AppFileInfo.cpp +++ b/src/kits/storage/AppFileInfo.cpp @@ -122,31 +122,46 @@ BAppFileInfo::SetTo(BFile *file) delete fResources; fResources = NULL; } + // check param status_t error = (file && file->InitCheck() == B_OK ? B_OK : B_BAD_VALUE); + + info_location where = B_USE_BOTH_LOCATIONS; + // create resources if (error == B_OK) { fResources = new(nothrow) BResources(); - if (fResources) + if (fResources) { error = fResources->SetTo(file); - else + if (error != B_OK) { + // no resources - this is no critical error, we'll just use + // attributes only, then + where = B_USE_ATTRIBUTES; + error = B_OK; + } + } else error = B_NO_MEMORY; } + // set node info if (error == B_OK) error = BNodeInfo::SetTo(file); + + if (error != B_OK || (where & B_USE_RESOURCES) == 0) { + delete fResources; + fResources = NULL; + } + // clean up on error if (error != B_OK) { - if (fResources) { - delete fResources; - fResources = NULL; - } if (InitCheck() == B_OK) BNodeInfo::SetTo(NULL); } + // set data location if (error == B_OK) - SetInfoLocation(B_USE_BOTH_LOCATIONS); + SetInfoLocation(where); + // set error fCStatus = error; return error;