[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4662 - in Extractor/src: include main plugins
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4662 - in Extractor/src: include main plugins |
Date: |
Sat, 10 Mar 2007 16:38:47 -0700 (MST) |
Author: durner
Date: 2007-03-10 16:38:46 -0700 (Sat, 10 Mar 2007)
New Revision: 4662
Modified:
Extractor/src/include/extractor.h
Extractor/src/main/extractor.c
Extractor/src/plugins/filenameextractor.c
Extractor/src/plugins/lowerextractor.c
Extractor/src/plugins/splitextractor.c
Log:
also return filesize
Modified: Extractor/src/include/extractor.h
===================================================================
--- Extractor/src/include/extractor.h 2007-03-10 21:46:09 UTC (rev 4661)
+++ Extractor/src/include/extractor.h 2007-03-10 23:38:46 UTC (rev 4662)
@@ -184,7 +184,7 @@
EXTRACTOR_STARTING_SONG = 128,
EXTRACTOR_HARDWARE_DEPENDENCY = 129,
EXTRACTOR_RIPPER = 130,
-
+ EXTRACTOR_FILE_SIZE = 131
} EXTRACTOR_KeywordType;
/**
Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c 2007-03-10 21:46:09 UTC (rev 4661)
+++ Extractor/src/main/extractor.c 2007-03-10 23:38:46 UTC (rev 4662)
@@ -172,11 +172,12 @@
gettext_noop("starting song"),
gettext_noop("hardware dependency"),
gettext_noop("ripper"), /* 130 */
+ gettext_noop("filesize") /* 131 */,
NULL,
};
/* the number of keyword types (for bounds-checking) */
-#define HIGHEST_TYPE_NUMBER 131
+#define HIGHEST_TYPE_NUMBER 132
#ifdef HAVE_LIBOGG
#if HAVE_VORBIS
Modified: Extractor/src/plugins/filenameextractor.c
===================================================================
--- Extractor/src/plugins/filenameextractor.c 2007-03-10 21:46:09 UTC (rev
4661)
+++ Extractor/src/plugins/filenameextractor.c 2007-03-10 23:38:46 UTC (rev
4662)
@@ -33,18 +33,40 @@
const char * filenameRoot = filename;
int res;
- if (filename == NULL)
- return prev;
- for (res=strlen(filename)-1;res>=0;res--)
- if (filename[res] == DIR_SEPARATOR) {
- filenameRoot = &filename[res+1];
- break;
- }
- keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = convertToUtf8(filenameRoot,
- strlen(filenameRoot),
- nl_langinfo(CODESET));
- keyword->keywordType = EXTRACTOR_FILENAME;
- return keyword;
+ /* get filename */
+ if (filename != NULL) {
+ for (res=strlen(filename)-1;res>=0;res--)
+ if (filename[res] == DIR_SEPARATOR) {
+ filenameRoot = &filename[res+1];
+ break;
+ }
+ keyword = malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword->next = prev;
+ keyword->keyword = convertToUtf8(filenameRoot,
+ strlen(filenameRoot),
+ nl_langinfo(CODESET));
+ keyword->keywordType = EXTRACTOR_FILENAME;
+ prev = keyword;
+ }
+
+ /* get file size */
+ if (size > 0) {
+ keyword = malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword->next = prev;
+ keyword->keyword = malloc(14);
+ keyword->keywordType = EXTRACTOR_FILE_SIZE;
+
+ if (size >= 1000000000)
+ snprintf(keyword->keyword, 13, "%.2f %s", size / 1000000000.0, _("GB"));
+ else if (size >= 1000000)
+ snprintf(keyword->keyword, 13, "%.2f %s", size / 1000000.0, _("MB"));
+ else if (size >= 1000)
+ snprintf(keyword->keyword, 13, "%.2f %s", size / 1000.0, _("KB"));
+ else
+ snprintf(keyword->keyword, 13, "%.2f %s", size, _("Bytes"));
+
+ prev = keyword;
+ }
+
+ return prev;
}
Modified: Extractor/src/plugins/lowerextractor.c
===================================================================
--- Extractor/src/plugins/lowerextractor.c 2007-03-10 21:46:09 UTC (rev
4661)
+++ Extractor/src/plugins/lowerextractor.c 2007-03-10 23:38:46 UTC (rev
4662)
@@ -48,6 +48,11 @@
while (pos != NULL)
{
+ if (pos->keywordType == EXTRACTOR_FILE_SIZE) {
+ pos = pos->next;
+ continue;
+ }
+
needed = strlen(pos->keyword) + 1;
if (needed > mem)
{
Modified: Extractor/src/plugins/splitextractor.c
===================================================================
--- Extractor/src/plugins/splitextractor.c 2007-03-10 21:46:09 UTC (rev
4661)
+++ Extractor/src/plugins/splitextractor.c 2007-03-10 23:38:46 UTC (rev
4662)
@@ -98,9 +98,11 @@
options = TOKENIZERS;
pos = prev;
while (pos != NULL) {
- splitKeywords(pos->keyword,
- &prev,
- options);
+ if (pos->keywordType != EXTRACTOR_FILE_SIZE)
+ splitKeywords(pos->keyword,
+ &prev,
+ options);
+
pos = pos->next;
}
return prev;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4662 - in Extractor/src: include main plugins,
gnunet <=