forked from old/legacy-imlib2
zlib/bz2 loaders, round 2: look for the real loader using a fake filename (original filename with the bz2/gz suffix cut)
SVN revision: 13917
This commit is contained in:
parent
80d218bca7
commit
29b2ab1df7
|
@ -51,16 +51,27 @@ char load (ImlibImage *im, ImlibProgressFunction progress,
|
|||
FILE *fp;
|
||||
int dest, res;
|
||||
char *file, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX", *p;
|
||||
char real_ext[16];
|
||||
|
||||
assert (im);
|
||||
|
||||
/* make sure this file ends in ".bz2" and that there's another ext
|
||||
* (e.g. "foo.png.bz2"
|
||||
*/
|
||||
p = strrchr(im->real_file, '.');
|
||||
if (p) {
|
||||
if (p && p != im->real_file) {
|
||||
if (strcasecmp(p + 1, "bz2"))
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
strncpy (real_ext, p - sizeof (real_ext) + 1, sizeof (real_ext));
|
||||
real_ext[sizeof (real_ext) - 1] = '\0';
|
||||
|
||||
/* abort if there's no dot in the "real" filename */
|
||||
if (!strrchr (real_ext, '.'))
|
||||
return 0;
|
||||
|
||||
if (!(fp = fopen (im->real_file, "rb"))) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,7 +90,7 @@ char load (ImlibImage *im, ImlibProgressFunction progress,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!(loader = __imlib_FindBestLoaderForFile (tmp, 0))) {
|
||||
if (!(loader = __imlib_FindBestLoaderForFile (real_ext, 0))) {
|
||||
unlink (tmp);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -68,18 +68,28 @@ char load (ImlibImage *im, ImlibProgressFunction progress,
|
|||
ImlibLoader *loader;
|
||||
int src, dest;
|
||||
char *file, *p, tmp[] = "/tmp/imlib2_loader_zlib-XXXXXX";
|
||||
char real_ext[16];
|
||||
struct stat st;
|
||||
|
||||
assert (im);
|
||||
|
||||
/* check that this file ends in *.gz */
|
||||
/* check that this file ends in *.gz and that there's another ext
|
||||
* (e.g. "foo.png.gz"
|
||||
*/
|
||||
p = strrchr(im->real_file, '.');
|
||||
if (p) {
|
||||
if (p && p != im->real_file) {
|
||||
if (strcasecmp(p + 1, "gz"))
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
strncpy (real_ext, p - sizeof (real_ext) + 1, sizeof (real_ext));
|
||||
real_ext[sizeof (real_ext) - 1] = '\0';
|
||||
|
||||
/* abort if there's no dot in the "real" filename */
|
||||
if (!strrchr (real_ext, '.'))
|
||||
return 0;
|
||||
|
||||
if (stat (im->real_file, &st) < 0)
|
||||
return 0;
|
||||
|
||||
|
@ -97,7 +107,7 @@ char load (ImlibImage *im, ImlibProgressFunction progress,
|
|||
close (src);
|
||||
close (dest);
|
||||
|
||||
if (!(loader = __imlib_FindBestLoaderForFile (tmp, 0))) {
|
||||
if (!(loader = __imlib_FindBestLoaderForFile (real_ext, 0))) {
|
||||
unlink (tmp);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue