Added check to avoid closing dir twice (and improved macro usage consistency).

In example the cc65-Apple2 dirent library caused heap corruption.
diff --git a/contiki/apps/directory.c b/contiki/apps/directory.c
index f7f6578..62b4f25 100644
--- a/contiki/apps/directory.c
+++ b/contiki/apps/directory.c
@@ -29,7 +29,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: directory.c,v 1.2 2005/05/06 22:33:05 oliverschmidt Exp $
+ * $Id: directory.c,v 1.3 2006/05/24 19:34:39 oliverschmidt Exp $
  *
  */
 
@@ -102,7 +102,7 @@
     show_statustext("Cannot open directory");
     loading = 0;
   } else {
-    loading = 1;
+    loading = LOADING_DIR;
     ek_post(id, EK_EVENT_CONTINUE, NULL);
     numfiles = 0;
   }
@@ -172,7 +172,9 @@
 {
   unsigned char i;
 
-  cfs_closedir(&dir);
+  if(loading == LOADING_DIR) {
+    cfs_closedir(&dir);
+  }
   ctk_window_close(&window);
   for(i = 0; dscs[i] != NULL; ++i) {
     LOADER_UNLOAD_DSC(dscs[i]);