Follow the InitCheck() model.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8537 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2004-08-04 16:39:09 +00:00
parent c92d05cf40
commit 1d90c31ea2

View File

@ -50,7 +50,7 @@ class UsbPort : public BDataIO {
UsbPort(BDirectory* printer, BMessage* msg);
~UsbPort();
bool IsOk() { return fFile > -1; }
bool InitCheck() { return fFile > -1; }
ssize_t Read(void* buffer, size_t size);
ssize_t Write(const void* buffer, size_t size);
@ -64,13 +64,11 @@ class UsbPort : public BDataIO {
BDataIO* instanciate_transport(BDirectory* printer, BMessage* msg) {
UsbPort* transport = new UsbPort(printer, msg);
if (transport->IsOk()) {
if (msg)
msg->what = 'okok';
if (transport->InitCheck())
return transport;
} else {
delete transport; return NULL;
}
delete transport;
return NULL;
}
@ -111,6 +109,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg)
return;
// Fill up the message
msg->what = 'okok';
msg->AddBool("bidirectional", bidirectional);
msg->AddString("device_id", device_id);
@ -131,10 +131,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg)
UsbPort::~UsbPort()
{
if (IsOk()) {
if (fFile > -1)
close(fFile);
fFile = -1;
}
}