--nextPart33890686.S46Tb4dYT7 Content-Type: multipart/alternative; boundary="Boundary-00=_BbypIk0hbglvphH" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-00=_BbypIk0hbglvphH Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable On Thursday 14 August 2008, Andre Gem=FCnd wrote: > Carsten Pfeiffer schrieb: > > > + FILE *fd_in; > > > + if ((fd_in =3D fopen(path.toLatin1().data(), "rb")) =3D=3D > > > > Can you use the QFile API instead of fopen()? If not, then please use > > QFile::encodeName() instead of latin1() to preserve the filename > > encoding. > > In theory you can. I'd have to write a custom source manager for that > then, because we can't use the stdio one of jpeglib in that case. I > think it would add a lot of code though, is it really needed? Actually it's easier than that: On an opened QFile you can use QFile::handle() to return the file descripto= r=20 (i.e. what is passed to write(2)). Using the file descriptior you can use = the=20 C stdio fdopen() function to return a FILE* tied to that file descriptor. This way you can still use stdio functions on a file managed by QFile. All that this would really buy you is guaranteeing that the file gets close= d,=20 which may not be worth the overhead however if you're simply going to be=20 passing the FILE* to libjpeg. Regards, - Michael Pyne --Boundary-00=_BbypIk0hbglvphH Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

On Thursday= 14 August 2008, Andre Gem=FCnd wrote:

> Carste= n Pfeiffer schrieb:

> > &= gt; + FILE *fd_in;

> > &= gt; + if ((fd_in =3D fopen(path.toLatin1().data(), "rb")) =3D=3D

> >

> > C= an you use the QFile API instead of fopen()? If not, then please use

> > Q= =46ile::encodeName() instead of latin1() to preserve the filename

> > e= ncoding.

>

> In the= ory you can. I'd have to write a custom source manager for that

> then, = because we can't use the stdio one of jpeglib in that case. I

> think = it would add a lot of code though, is it really needed?

Actually it= 's easier than that:

On an opene= d QFile you can use QFile::handle() to return the file descriptor (i.e. wha= t is passed to write(2)). Using the file descriptior you can use the C std= io fdopen() function to return a FILE* tied to that file descriptor.

This way yo= u can still use stdio functions on a file managed by QFile.

All that th= is would really buy you is guaranteeing that the file gets closed, which ma= y not be worth the overhead however if you're simply going to be passing th= e FILE* to libjpeg.

Regards,

- Michael = Pyne

--Boundary-00=_BbypIk0hbglvphH-- --nextPart33890686.S46Tb4dYT7 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEABECAAYFAkinJsQACgkQqjQYp5Omm0pOKACgxVi/cwmOuZKh+PFO9xh20dU7 XjMAoIS8ejF2dauG7dceiHkEgPUgH1aJ =t0bT -----END PGP SIGNATURE----- --nextPart33890686.S46Tb4dYT7--