libprint.a: check the transport add-on file actually exists before trying to load it
This should fix runtime_loader "cannot open file" errors logged into syslog because every standard locations were attempted without checking for actual existance of a file to attempt to open. There messages were misleading users about their criticity. Change-Id: I621b122a4eee1cc7ad2ff1c03f5146809657e7d4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/11175 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Directory.h>
|
||||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <Path.h>
|
||||
#include <image.h>
|
||||
|
||||
@@ -48,11 +49,19 @@ Transport::Transport(const PrinterData *printerData)
|
||||
B_BEOS_ADDONS_DIRECTORY,
|
||||
};
|
||||
BPath path;
|
||||
BEntry entry;
|
||||
for (uint32 i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) {
|
||||
if (find_directory(paths[i], &path) != B_OK)
|
||||
continue;
|
||||
path.Append("Print/transport");
|
||||
path.Append(printerData->GetTransport().c_str());
|
||||
|
||||
entry.SetTo(path.Path(), true);
|
||||
if (!entry.IsFile()) {
|
||||
// doesn't exists or is not a file
|
||||
continue;
|
||||
}
|
||||
|
||||
DBGMSG(("load_add_on: %s\n", path.Path()));
|
||||
fImage = load_add_on(path.Path());
|
||||
if (fImage >= 0)
|
||||
|
||||
Reference in New Issue
Block a user