fix segv with type DT_UNKOWN
authorHannes Janetzek <hannes.janetzek@gmail.com>
Fri, 4 Jun 2010 21:22:04 +0000 (21:22 +0000)
committerHannes Janetzek <hannes.janetzek@gmail.com>
Fri, 4 Jun 2010 21:22:04 +0000 (21:22 +0000)
SVN revision: 49458

src/modules/everything-files/e_mod_main.c

index a369fdd..ddd446d 100644 (file)
@@ -211,11 +211,19 @@ _scan_func(void *data)
 
        is_dir = EINA_FALSE;
 
+       if (d->directory[1])
+         snprintf(buf, sizeof(buf), "%s/%s",
+                  d->directory,
+                  dp->d_name);
+       else
+         snprintf(buf, sizeof(buf), "/%s",
+                  dp->d_name);
+
 #ifdef _DIRENT_HAVE_D_TYPE
        if (dp->d_type & DT_UNKNOWN)
          {
 #endif
-            if (ecore_file_is_dir(file->path))
+            if (ecore_file_is_dir(buf))
               is_dir = EINA_TRUE;
 
 #ifdef _DIRENT_HAVE_D_TYPE
@@ -225,22 +233,17 @@ _scan_func(void *data)
             is_dir = EINA_TRUE;
          }
 #endif
-
        if (p->dirs_only && !is_dir)
          continue;
 
-       file = EVRY_ITEM_NEW(Evry_Item_File, p, NULL, NULL, _item_free);
+       file = EVRY_ITEM_NEW(Evry_Item_File, p,
+                            NULL, NULL, _item_free);
 
        filename = strdup(dp->d_name);
        EVRY_ITEM(file)->label = filename;
        EVRY_ITEM(file)->browseable = is_dir;
        d->files = eina_list_append(d->files, file);
 
-       if (d->directory[1])
-         snprintf(buf, sizeof(buf), "%s/%s", d->directory, filename);
-       else
-         snprintf(buf, sizeof(buf), "/%s", filename);
-
        file->path = strdup(buf);
      }
    closedir(d->dirp);