PDA

View Full Version : open large file in qt?



vishal.chauhan
24th May 2007, 12:28
Hi All,

I m using Qt 4.1.5 on my Mac Tiger.
I want to open my HardDisk as file in qt.
I m using QFILE for that but it is working only on small size when I m opening Hardisk of 160 GB the open function return false.


If anybody knows how I can open large file then plz help me.

Thanks.

marcel
24th May 2007, 12:34
The "HardDisk" is actually the root of the filesystem( "/" ). Therefore you cannot open it as a file.

What are you trying to do? Compress it, back it up?
Whatever you want, you must use 64 bytes for file sizes and offsets because the result will get pretty big.

Regards

vishal.chauhan
24th May 2007, 12:41
Thanks for reply.



Whatever you want, you must use 64 bytes for file sizes and offsets because the result will get pretty big.

How can I use 64 bytes for file sizes?
open64 function is not there in the Mac.

wysota
24th May 2007, 12:42
I think he means something like /dev/hda which is the harddisk itself.

First of all try checking if you have all required permissions to do that, for example if you can open the file as a regular user using something like hexedit or simmilar.

vishal.chauhan
24th May 2007, 12:51
Thanks for Reply.

Ya I just want to open file like /dev/rdisk0 from the qt application and I have all the permission for that but donot know how to open it on Mac.

wysota
24th May 2007, 13:04
It works for me on Linux (I have to be root to do that though):

#include <QFile>


int main(){
QFile file("/dev/hda");
if(!file.open(QFile::ReadOnly)){
qDebug("FAILED");
} else {
qDebug("OPENED");
}
return 0;
}

vishal.chauhan
24th May 2007, 13:18
This function always return false on My MAC.

marcel
24th May 2007, 13:28
What does Get Info in Finder has to say about /dev?
I mean, do you have any permissions at all?

patrik08
24th May 2007, 14:14
What does Get Info in Finder has to say about /dev?
I mean, do you have any permissions at all?

Normal ist /Volumes



#if defined Q_WS_MAC
/* apple + K */
label_webdav->setText(tr("Mac OS: Mount Disk Webdav Root"));
QString listdiron ="/Volumes/";
webdav_root->addItem(disksetting);
/* webdav_root->addItem(listdiron);*/
QDir dir(listdiron);
if (dir.exists()) {
const QFileInfoList list = dir.entryInfoList();
QFileInfo fi;
for (int i = 0; i < list.size(); i++)
{
fi = list.at(i);
if (fi.isDir() && fi.fileName() != "." && fi.fileName() != "..") {
QString disker = fi.absoluteFilePath();
QString diskeree = disker.append("/");
webdav_root->addItem(diskeree);
}
}
}
webdav_root->setEditable(false);
#endif

vishal.chauhan
24th May 2007, 14:35
Thanks for Reply.

But Actually I want to open the HardDisk not to read Dir or File Actually I have to Read the Bytes from the HardDisk.
I have a function to do that but Actually It can not able to open the file. I have also used c function open("/dev/rdisk0",O_RDONLY) but it also not able to open the Drives.

It is showing that it has read write permission when I see from Getinfo in finder.
Actually I have tried on other system but it doesnot work.

It is working when I open a removable media but not in case of Hard disk.

wysota
24th May 2007, 15:27
What does ls -l /dev/rdisk0 return?

vishal.chauhan
29th May 2007, 07:25
Hey guys I got it.
Actually I am login as admin but it have some file system permission to root user.

So I just enabled user root and now it is running correctly.

Guys Thanks for reply.