针对中标麒麟特别处理sane的加载目录
This commit is contained in:
parent
6b157ee7d0
commit
0fee24d878
|
@ -1,5 +1,6 @@
|
||||||
#include "HGSaneImpl.hpp"
|
#include "HGSaneImpl.hpp"
|
||||||
#include "../base/HGInc.h"
|
#include "../base/HGInc.h"
|
||||||
|
#include "../base/HGUtility.h"
|
||||||
|
|
||||||
HGSaneManagerImpl::HGSaneManagerImpl()
|
HGSaneManagerImpl::HGSaneManagerImpl()
|
||||||
{
|
{
|
||||||
|
@ -31,11 +32,32 @@ HGResult HGSaneManagerImpl::Create()
|
||||||
pclose(file);
|
pclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (archName.empty())
|
std::string osName;
|
||||||
|
FILE* fp = popen("cat /etc/issue | cut -d\' \' -f1", "r");
|
||||||
|
if (NULL != fp)
|
||||||
|
{
|
||||||
|
char buff[1024] = { 0 };
|
||||||
|
fread(buff, 1024, 1, fp);
|
||||||
|
|
||||||
|
int len = (int)strlen(buff);
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
if (buff[i] == '\n')
|
||||||
|
buff[i] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
osName = buff;
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archName.empty() || osName.empty())
|
||||||
{
|
{
|
||||||
return HGBASE_ERR_FAIL;
|
return HGBASE_ERR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (archName == "mips64")
|
||||||
|
archName += "el";
|
||||||
|
|
||||||
char manuPath[] = "/etc/sane.d/dll.d";
|
char manuPath[] = "/etc/sane.d/dll.d";
|
||||||
|
|
||||||
DIR* dir = opendir(manuPath);
|
DIR* dir = opendir(manuPath);
|
||||||
|
@ -93,9 +115,14 @@ HGResult HGSaneManagerImpl::Create()
|
||||||
pr.first = manuName;
|
pr.first = manuName;
|
||||||
|
|
||||||
char sanePath[256];
|
char sanePath[256];
|
||||||
if (archName == "mips64")
|
if (osName == "NeoKylin")
|
||||||
archName += "el";
|
{
|
||||||
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str());
|
sprintf(sanePath, "/usr/lib64/sane/libsane-%s.so.1", manuName.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(sanePath, "/usr/lib/%s-linux-gnu/sane/libsane-%s.so.1", archName.c_str(), manuName.c_str());
|
||||||
|
}
|
||||||
pr.second = sanePath;
|
pr.second = sanePath;
|
||||||
|
|
||||||
if(!filterDeviceSource(pr.first.c_str()))
|
if(!filterDeviceSource(pr.first.c_str()))
|
||||||
|
@ -325,11 +352,18 @@ HGResult HGSaneSourceImpl::Open(const HGChar* saneManu, const HGChar* sanePath)
|
||||||
return HGBASE_ERR_INVALIDARG;
|
return HGBASE_ERR_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HGChar fileName[260];
|
||||||
|
HGBase_GetFileName(sanePath, fileName, 260);
|
||||||
|
|
||||||
HGDll dll = NULL;
|
HGDll dll = NULL;
|
||||||
HGResult ret = HGBase_CreateDll(sanePath, &dll);
|
HGResult ret = HGBase_CreateDll(fileName, &dll);
|
||||||
if (HGBASE_ERR_OK != ret)
|
if (HGBASE_ERR_OK != ret)
|
||||||
{
|
{
|
||||||
return ret;
|
ret = HGBase_CreateDll(sanePath, &dll);
|
||||||
|
if (HGBASE_ERR_OK != ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SANEAPI saneAPI;
|
SANEAPI saneAPI;
|
||||||
|
|
|
@ -54,12 +54,19 @@ void Dialog_Source_Select::on_pushButton_OK_clicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HGChar fileName[260];
|
||||||
|
HGBase_GetFileName(m_vSource[index].second.c_str(), fileName, 260);
|
||||||
|
|
||||||
HGDll dll = nullptr;
|
HGDll dll = nullptr;
|
||||||
HGResult ret = HGBase_CreateDll(m_vSource[index].second.c_str(), &dll);
|
HGResult ret = HGBase_CreateDll(fileName, &dll);
|
||||||
if (HGBASE_ERR_OK != ret)
|
if (HGBASE_ERR_OK != ret)
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, tr("tips"), tr("Load library failed"));
|
ret = HGBase_CreateDll(m_vSource[index].second.c_str(), &dll);
|
||||||
return;
|
if (HGBASE_ERR_OK != ret)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("tips"), tr("Load library failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SANEAPI saneAPI;
|
SANEAPI saneAPI;
|
||||||
|
|
Loading…
Reference in New Issue