aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_file_information.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-05-31 08:24:42 +0000
committerChristian Grothoff <christian@grothoff.org>2010-05-31 08:24:42 +0000
commit5554d773fef027d978d8b94f2cfe10b3206c5916 (patch)
tree22c4d3cf3b820248a15fa86552dfa3d505dbc09d /src/fs/fs_file_information.c
parent46e277f53de5d77ba4414c178b511278c21b1789 (diff)
downloadgnunet-5554d773fef027d978d8b94f2cfe10b3206c5916.tar.gz
gnunet-5554d773fef027d978d8b94f2cfe10b3206c5916.zip
done
Diffstat (limited to 'src/fs/fs_file_information.c')
-rw-r--r--src/fs/fs_file_information.c74
1 files changed, 71 insertions, 3 deletions
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index d9acc9595..c04c5a56e 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -36,6 +36,74 @@
36 36
37 37
38/** 38/**
39 * Add meta data that libextractor finds to our meta data
40 * container.
41 *
42 * @param cls closure, our meta data container
43 * @param plugin_name name of the plugin that produced this value;
44 * special values can be used (i.e. '&lt;zlib&gt;' for zlib being
45 * used in the main libextractor library and yielding
46 * meta data).
47 * @param type libextractor-type describing the meta data
48 * @param format basic format information about data
49 * @param data_mime_type mime-type of data (not of the original file);
50 * can be NULL (if mime-type is not known)
51 * @param data actual meta-data found
52 * @param data_len number of bytes in data
53 * @return always 0 to continue extracting
54 */
55static int
56add_to_md(void *cls,
57 const char *plugin_name,
58 enum EXTRACTOR_MetaType type,
59 enum EXTRACTOR_MetaFormat format,
60 const char *data_mime_type,
61 const char *data,
62 size_t data_len)
63{
64 struct GNUNET_CONTAINER_MetaData *md = cls;
65 (void) GNUNET_CONTAINER_meta_data_insert (md,
66 plugin_name,
67 type,
68 format,
69 data_mime_type,
70 data,
71 data_len);
72 return 0;
73}
74
75
76/**
77 * Extract meta-data from a file.
78 *
79 * @return GNUNET_SYSERR on error, otherwise the number
80 * of meta-data items obtained
81 */
82int
83GNUNET_FS_meta_data_extract_from_file (struct GNUNET_CONTAINER_MetaData
84 *md, const char *filename,
85 struct EXTRACTOR_PluginList *
86 extractors)
87{
88 int old;
89
90 if (filename == NULL)
91 return GNUNET_SYSERR;
92 if (extractors == NULL)
93 return 0;
94 old = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL);
95 GNUNET_assert (old >= 0);
96 EXTRACTOR_extract (extractors,
97 filename,
98 NULL, 0,
99 &add_to_md,
100 md);
101 return (GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL) - old);
102}
103
104
105
106/**
39 * Obtain the name under which this file information 107 * Obtain the name under which this file information
40 * structure is stored on disk. Only works for top-level 108 * structure is stored on disk. Only works for top-level
41 * file information structures. 109 * file information structures.
@@ -350,9 +418,9 @@ dir_scan_cb (void *cls,
350 else 418 else
351 { 419 {
352 meta = GNUNET_CONTAINER_meta_data_create (); 420 meta = GNUNET_CONTAINER_meta_data_create ();
353 GNUNET_CONTAINER_meta_data_extract_from_file (meta, 421 GNUNET_FS_meta_data_extract_from_file (meta,
354 filename, 422 filename,
355 dsc->extractors); 423 dsc->extractors);
356 // FIXME: remove path from filename in metadata! 424 // FIXME: remove path from filename in metadata!
357 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); 425 keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta);
358 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); 426 ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords);