evas: don't try all loader on directory.
authorCedric BAIL <cedric.bail@free.fr>
Fri, 6 May 2011 09:36:24 +0000 (09:36 +0000)
committerCedric BAIL <cedric.bail@free.fr>
Fri, 6 May 2011 09:36:24 +0000 (09:36 +0000)
SVN revision: 59235

legacy/evas/ChangeLog
legacy/evas/src/lib/engines/common/evas_image_load.c

index 138b93f..ff978b7 100644 (file)
@@ -1,4 +1,4 @@
-2011-01-29  Carsten Haitzler (The Rasterman)
+6~2011-01-29  Carsten Haitzler (The Rasterman)
 
        1.0.0 release
 
          are possibly faster. I haven't noticed any difference between the
          two speed-wise, but there probably are in some rare cases.
 
+2011-05-06 Cedric Bail
+
+       * Don't try all image loader when user is pointing them on a directory.
+
index 31b3d01..23b9930 100644 (file)
@@ -1,3 +1,7 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
 #include "evas_common.h"
 #include "evas_private.h"
 #include "evas_cs.h"
@@ -82,6 +86,7 @@ evas_common_load_rgba_image_module_from_file(Image_Entry *ie)
    Evas_Image_Load_Func *evas_image_load_func = NULL;
    const char           *loader = NULL, *end;
    Evas_Module          *em;
+   struct stat          st;
    unsigned int          i;
    int                   len, ret = EVAS_LOAD_ERROR_NONE;
    struct evas_image_foreach_loader_data fdata;
@@ -100,6 +105,12 @@ evas_common_load_rgba_image_module_from_file(Image_Entry *ie)
           }
      }
 #endif
+   if (stat(ie->file, &st) != 0 || S_ISDIR(st.st_mode))
+     {
+        DBG("trying to open directory '%s' !", ie->file);
+        return EVAS_LOAD_ERROR_DOES_NOT_EXIST;
+     }
+
    len = strlen(ie->file);
    end = ie->file + len;
    for (i = 0; i < (sizeof (loaders) / sizeof(struct ext_loader_s)); i++)