forked from old/legacy-imlib2
Introduce imlib_load_image_fde()
Same as imlib_load_image_fd() but with error return.
This commit is contained in:
parent
8dc921286c
commit
cea1207efe
|
@ -816,6 +816,26 @@ EAPI Imlib_Image imlib_load_image_with_errno_return(const char *file,
|
|||
*/
|
||||
EAPI Imlib_Image imlib_load_image_fd(int fd, const char *file);
|
||||
|
||||
/**
|
||||
* Read an image from file descriptor with error return
|
||||
*
|
||||
* Same as imlib_load_image_fd() but with error return.
|
||||
*
|
||||
* On error @p error_return is set to the detail of the error.
|
||||
* error values:
|
||||
* 0: Success,
|
||||
* positive: Regular errnos,
|
||||
* negative: IMLIB_ERR_... values, see above
|
||||
*
|
||||
* @param file File name
|
||||
* @param error_return The returned error
|
||||
* @param fd Image file descriptor
|
||||
*
|
||||
* @return Image handle (NULL on failure)
|
||||
*/
|
||||
EAPI Imlib_Image imlib_load_image_fde(const char *file, int *error_return,
|
||||
int fd);
|
||||
|
||||
/**
|
||||
* Free the current image
|
||||
*/
|
||||
|
|
|
@ -857,7 +857,7 @@ imlib_load_image_with_errno_return(const char *file, int *error_return)
|
|||
}
|
||||
|
||||
EAPI Imlib_Image
|
||||
imlib_load_image_fd(int fd, const char *file)
|
||||
imlib_load_image_fde(const char *file, int *err, int fd)
|
||||
{
|
||||
Imlib_Image im;
|
||||
ImlibLoadArgs ila = { ILA0(ctx, 1, 1) };
|
||||
|
@ -869,16 +869,26 @@ imlib_load_image_fd(int fd, const char *file)
|
|||
{
|
||||
im = __imlib_LoadImage(file, &ila);
|
||||
fclose(ila.fp);
|
||||
if (err)
|
||||
*err = ila.err;
|
||||
}
|
||||
else
|
||||
{
|
||||
im = NULL;
|
||||
close(fd);
|
||||
if (err)
|
||||
*err = errno;
|
||||
}
|
||||
|
||||
return im;
|
||||
}
|
||||
|
||||
EAPI Imlib_Image
|
||||
imlib_load_image_fd(int fd, const char *file)
|
||||
{
|
||||
return imlib_load_image_fde(file, NULL, fd);
|
||||
}
|
||||
|
||||
EAPI Imlib_Image
|
||||
imlib_load_image_frame(const char *file, int frame)
|
||||
{
|
||||
|
|
|
@ -178,12 +178,13 @@ test_load(void)
|
|||
fd = open(fileo, O_RDONLY);
|
||||
D("Load fd %d '%s'\n", fd, fileo);
|
||||
snprintf(fileo, sizeof(fileo), ".%s", pfxs[i]);
|
||||
im = imlib_load_image_fd(fd, pfxs[i]);
|
||||
im = imlib_load_image_fde(pfxs[i], &err, fd);
|
||||
EXPECT_TRUE(im);
|
||||
if (im)
|
||||
image_free(im);
|
||||
EXPECT_EQ(err, 0);
|
||||
err = close(fd);
|
||||
EXPECT_TRUE(err != 0);
|
||||
EXPECT_NE(err, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue