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:
parent
c92d05cf40
commit
1d90c31ea2
@ -50,7 +50,7 @@ class UsbPort : public BDataIO {
|
|||||||
UsbPort(BDirectory* printer, BMessage* msg);
|
UsbPort(BDirectory* printer, BMessage* msg);
|
||||||
~UsbPort();
|
~UsbPort();
|
||||||
|
|
||||||
bool IsOk() { return fFile > -1; }
|
bool InitCheck() { return fFile > -1; }
|
||||||
|
|
||||||
ssize_t Read(void* buffer, size_t size);
|
ssize_t Read(void* buffer, size_t size);
|
||||||
ssize_t Write(const 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) {
|
BDataIO* instanciate_transport(BDirectory* printer, BMessage* msg) {
|
||||||
UsbPort* transport = new UsbPort(printer, msg);
|
UsbPort* transport = new UsbPort(printer, msg);
|
||||||
if (transport->IsOk()) {
|
if (transport->InitCheck())
|
||||||
if (msg)
|
|
||||||
msg->what = 'okok';
|
|
||||||
return transport;
|
return transport;
|
||||||
} else {
|
|
||||||
delete transport; return NULL;
|
delete transport;
|
||||||
}
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -111,6 +109,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Fill up the message
|
// Fill up the message
|
||||||
|
msg->what = 'okok';
|
||||||
|
|
||||||
msg->AddBool("bidirectional", bidirectional);
|
msg->AddBool("bidirectional", bidirectional);
|
||||||
msg->AddString("device_id", device_id);
|
msg->AddString("device_id", device_id);
|
||||||
|
|
||||||
@ -131,10 +131,8 @@ UsbPort::UsbPort(BDirectory* printer, BMessage *msg)
|
|||||||
|
|
||||||
UsbPort::~UsbPort()
|
UsbPort::~UsbPort()
|
||||||
{
|
{
|
||||||
if (IsOk()) {
|
if (fFile > -1)
|
||||||
close(fFile);
|
close(fFile);
|
||||||
fFile = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user