I have written a program using Qt libraries for an embedded device that runs on Linux generated by Buildroot. To start my program I've created a script called S80custom
and placed it in /etc/init.d/
directory. The content of the script is:
#!/bin/sh
if [ ! -d "/root/files/" ]; then
mkdir /root/files/
fi
if [ ! -d "/root/Test/" ]; then
mkdir /root/Test/
fi
if [ ! -d "/root/Test/Log/" ]; then
mkdir /root/Test/Log/
fi
export TSLIB_CONSOLEDEVICE='none'
export TSLIB_FBDEVICE='/dev/fb0'
export TSLIB_TSDEVICE='/dev/input/event1'
export TSLIB_PLUGINDIR='/usr/lib/ts'
export TSLIB_CONFFILE='/etc/ts.conf'
export TSLIB_CALIBFILE='/etc/pointercal'
export QWS_MOUSE_PROTO=tslib:'/dev/input/event1'
/root/Test/Test -qws
However when my program runs at system start-up, it can't access the files placed at /root/files
. I've used QFile
class and its member functions for the same. I’ve tried Standard C++ Libraries and they work, but strangely QFile is unable to open the files and I must use QFile for this task.
What am I doing wrong here?
I should also mention here that when I run my application from command prompt after I login, it works perfectly.
EDIT
As requested in the comments this is the portion of the code that is suppose to open a file:
QDir directory = QDir::home();
if(!directory.cd("files")){
LOG << directory << "does not exist or path incorrect. trying to make it";
if(directory.mkdir("files"))
{
LOG << "made directory \"files\" at" << directory.absolutePath();
directory.cd("files");
}
else
LOG << "couldn't make diretory... do we have enough priviledges?";
}
fileName = directory.absoluteFilePath("PARMLIST.BIN");
qDebug() << "filename to open:" << fileName;
QFile file(fileName);
QDataStream in(&file);
if(!file.open(QIODevice::ReadOnly))
{
if(CONF_INT("rdu.active") != 1)
AlarmManager::getInstance().setAlarm(102, true);
else
AlarmManager::getInstance().setAlarm(184, true);
paramMissing = true;
return;
}
The mechanism for setting alarms is activated, and that code tells me the files are missing or corrupted. Apart from that I get no errors. Also I tried giving the full path as file name but that didn't work either.