Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, July 2007
why fopen() cannot open a qt-resource file?


Message 1 in thread

Quick question:
why fopen() cannot open a qt-resource file?

FILE *fp = fopen(“:/images/open.png”, “rb”); // NULL !!!!

Thanks,
Lingfa


--
 [ signature omitted ] 

Message 2 in thread

> Quick question:
> why fopen() cannot open a qt-resource file?
> FILE *fp = fopen(“:/images/open.png”, “rb”); // NULL !!!!

I believe that to be pretty normal. Since fopen is below the Qt architecture 
it doesn't know anything about Qt's resource system.

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

Werner Van Belle wrote:

>>Quick question:
>>why fopen() cannot open a qt-resource file?
>>FILE *fp = fopen(“:/images/open.png”, “rb”); // NULL !!!!
>>    
>>
>
>I believe that to be pretty normal. Since fopen is below the Qt architecture 
>it doesn't know anything about Qt's resource system.
>
>  
>
Yes, my real problem comes from zlib, where I am trying to unzip a zipFile.
This zipFile has to go with my release, that is why I treat it as a 
qt-resource file.
Then, problem turns into zlib cannot open a qt-resource file, because 
the implimentation of zlib uses fopen().

Do you have suggestion on this issue?
Thanks,
Lingfa


--
 [ signature omitted ] 

Message 4 in thread

On 28 jul 2007, at 00.07, Lingfa Yang wrote:

> Werner Van Belle wrote:
>
>>> Quick question:
>>> why fopen() cannot open a qt-resource file?
>>> FILE *fp = fopen(“:/images/open.png”, “rb”); // NULL !!!!
>>>
>>
>> I believe that to be pretty normal. Since fopen is below the Qt  
>> architecture it doesn't know anything about Qt's resource system.
>>
>>
> Yes, my real problem comes from zlib, where I am trying to unzip a  
> zipFile.
> This zipFile has to go with my release, that is why I treat it as a  
> qt-resource file.
> Then, problem turns into zlib cannot open a qt-resource file,  
> because the implimentation of zlib uses fopen().
>
> Do you have suggestion on this issue?
> Thanks,
> Lingfa
	Use Qt File classes to copy the resource file to a temp file.
Then you can unzip it.
------
What is a woman that you forsake her, and the hearth fire and the  
home acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the  
Dane women
Tommy Nordgren
tommy.nordgren@xxxxxxxxx



--
 [ signature omitted ] 

Message 5 in thread

> > Yes, my real problem comes from zlib, where I am trying to unzip a
> > zipFile. This zipFile has to go with my release, that is why I treat it as
> > a qt-resource file. Then, problem turns into zlib cannot open a
> > qt-resource file,  because the implimentation of zlib uses fopen().
>
> Use Qt File classes to copy the resource file to a temp file.
> Then you can unzip it.

I believe that the qt resource system already compresses files (i'm not sure 
though), so maybe it's even unnecessary to gzip them yourself.

Werner,-

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 6 in thread

Werner Van Belle wrote:

>>>Yes, my real problem comes from zlib, where I am trying to unzip a
>>>zipFile. This zipFile has to go with my release, that is why I treat it as
>>>a qt-resource file. Then, problem turns into zlib cannot open a
>>>qt-resource file,  because the implimentation of zlib uses fopen().
>>>      
>>>
>>Use Qt File classes to copy the resource file to a temp file.
>>Then you can unzip it.
>>    
>>
>
>I believe that the qt resource system already compresses files (i'm not sure 
>though), so maybe it's even unnecessary to gzip them yourself.
>
>Werner,-
>
>  
>
Werner,

Thank you for your reply. I am programming OpenXml (Office 2007) using 
Qt,  where document files are zipped following OPC.  So I have to work 
with gzip.

Lingfa


--
 [ signature omitted ] 

Message 7 in thread

>     Use Qt File classes to copy the resource file to a temp file.
> Then you can unzip it.

Tommy, Girish, and Werner,

Thank you providing solutions of copying the resource file to a temp 
file or using QResource::data.
That solves my problem.

Cheers,
Lingfa


--
 [ signature omitted ] 

Message 8 in thread

Lingfa Yang wrote:
> Werner Van Belle wrote:
> 
>>> Quick question:
>>> why fopen() cannot open a qt-resource file?
>>> FILE *fp = fopen(“:/images/open.png”, “rb”); // NULL !!!!
>>>   
>>
>> I believe that to be pretty normal. Since fopen is below the Qt 
>> architecture it doesn't know anything about Qt's resource system.
>>
>>  
>>
> Yes, my real problem comes from zlib, where I am trying to unzip a zipFile.
> This zipFile has to go with my release, that is why I treat it as a 
> qt-resource file.
> Then, problem turns into zlib cannot open a qt-resource file, because 
> the implimentation of zlib uses fopen().
> 

If there is an API to uncompress from data in memory, then you can use 
QResource::data (http://doc.trolltech.com/4.3/qresource.html#data).

Girish

--
 [ signature omitted ]