gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3990 - GNUnet/src/applications/fs/tools


From: grothoff
Subject: [GNUnet-SVN] r3990 - GNUnet/src/applications/fs/tools
Date: Wed, 20 Dec 2006 21:25:22 -0800 (PST)

Author: grothoff
Date: 2006-12-20 21:25:19 -0800 (Wed, 20 Dec 2006)
New Revision: 3990

Modified:
   GNUnet/src/applications/fs/tools/gnunet-insert.c
Log:
fixing mantis 1158

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-12-21 04:45:09 UTC 
(rev 3989)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2006-12-21 05:25:19 UTC 
(rev 3990)
@@ -145,6 +145,48 @@
   pseudonym = NULL;
 }
 
+static int listKeywords(const char * fn,
+                       const char * dir,
+                       void * cls) {
+  EXTRACTOR_ExtractorList * l = cls;
+  char * fullName;
+  struct stat buf;
+  EXTRACTOR_KeywordList * list;
+  
+  fullName = MALLOC(strlen(dir) + strlen(fn) + 2);
+  strcpy(fullName, dir);
+  if (dir[strlen(dir)-1] != '/')
+    strcat(fullName, "/");
+  strcat(fullName, fn);
+  printf(_("Keywords for file `%s':\n"),
+        fullName);
+  if (0 != STAT(fullName,
+               &buf)) {
+    FREE(fullName);
+    return OK;
+  }
+  if (S_ISDIR(buf.st_mode)) {
+    printf("%s - %s\n",
+          dgettext("libextractor", "filename"),
+          fn);
+    printf("%s - %s\n",
+          dgettext("libextractor", "mimetype"),
+          "application/gnunet-directory");
+    disk_directory_scan(NULL,
+                       fullName,
+                       &listKeywords,
+                       cls);
+  } else {
+    list = EXTRACTOR_getKeywords(l, fullName);
+    EXTRACTOR_printKeywords(stdout,
+                           list);
+    EXTRACTOR_freeKeywords(list);
+  }
+  FREE(fullName);
+  return OK;
+}
+                     
+
 /**
  * Print progess message.
  */
@@ -330,27 +372,35 @@
   if (extract_only) {
     EXTRACTOR_ExtractorList * l;
     char * ex;
-    EXTRACTOR_KeywordList * list;
+    char * dirname;
+    char * fname;
        
     l = EXTRACTOR_loadDefaultLibraries();
     ex = NULL;
     GC_get_configuration_value_string(cfg,
                                      "FS",
                                      "EXTRACTORS",
-                                     NULL,
+                                     "",
                                      &ex);
-    if (ex != NULL) {
+    if (strlen(ex) > 0) 
       l = EXTRACTOR_loadConfigLibraries(l,
-                                       ex);
-      FREE(ex);
-    }
-    list
-      = EXTRACTOR_getKeywords(l, filename);
-    printf(_("Keywords for file `%s':\n"),
-          filename);
-    EXTRACTOR_printKeywords(stdout,
-                           list);
-    EXTRACTOR_freeKeywords(list);
+                                       ex);    
+    FREE(ex);
+    dirname = string_expandFileName(ectx, filename);
+    GE_ASSERT(ectx, dirname != NULL);
+    while ( (strlen(dirname) > 0) &&
+           (dirname[strlen(dirname)-1] == '/') )
+      dirname[strlen(dirname)-1] = '\0';      
+    fname = dirname;
+    while (strstr(fname, "/") != NULL)
+      fname = strstr(fname, "/") + 1;
+    GE_ASSERT(ectx, 
+             fname != dirname);
+    fname[-1] = '\0';
+    listKeywords(fname,
+                dirname,                
+                l);
+    FREE(dirname);
     EXTRACTOR_removeAll(l);
     ECRS_freeMetaData(meta);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]