[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r2486 - in GNUnet/src/applications/fs: ecrs fsui
From: |
grothoff |
Subject: |
[GNUnet-SVN] r2486 - in GNUnet/src/applications/fs: ecrs fsui |
Date: |
Sat, 11 Mar 2006 15:10:21 -0800 (PST) |
Author: grothoff
Date: 2006-03-11 15:10:18 -0800 (Sat, 11 Mar 2006)
New Revision: 2486
Modified:
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/fsui/download.c
GNUnet/src/applications/fs/fsui/upload.c
Log:
directory naming fixes
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2006-03-11 22:47:05 UTC (rev
2485)
+++ GNUnet/src/applications/fs/ecrs/download.c 2006-03-11 23:10:18 UTC (rev
2486)
@@ -112,8 +112,12 @@
MUTEX_DESTROY(&this->lock);
if (YES == unlinkTreeFiles) {
for (i=1;i<= this->treedepth;i++) {
- fn = MALLOC(strlen(this->filename) + 3);
+ fn = MALLOC(strlen(this->filename) + 3 + strlen(GNUNET_DIRECTORY_EXT));
strcpy(fn, this->filename);
+ if (fn[strlen(fn)-1] == '/') {
+ fn[strlen(fn)-1] = '\0';
+ strcat(fn, GNUNET_DIRECTORY_EXT);
+ }
strcat(fn, ".A");
fn[strlen(fn)-1]+=i;
if (0 != UNLINK(fn))
@@ -162,10 +166,12 @@
this->handles[i] = -1;
for (i=0;i<=this->treedepth;i++) {
- fn = MALLOC(strlen(filename) + 3);
+ fn = MALLOC(strlen(filename) + 3 + strlen(GNUNET_DIRECTORY_EXT));
strcpy(fn, filename);
- if (fn[strlen(fn)-1] == DIR_SEPARATOR)
+ if (fn[strlen(fn)-1] == '/') {
fn[strlen(fn)-1] = '\0';
+ strcat(fn, GNUNET_DIRECTORY_EXT);
+ }
if (i > 0) {
strcat(fn, ".A");
fn[strlen(fn)-1] += i;
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2006-03-11 22:47:05 UTC (rev
2485)
+++ GNUnet/src/applications/fs/fsui/download.c 2006-03-11 23:10:18 UTC (rev
2486)
@@ -84,7 +84,10 @@
+ strlen(GNUNET_DIRECTORY_EXT) + 2
+ strlen(filename));
strcpy(fullName, parent->filename);
- strcat(fullName, GNUNET_DIRECTORY_EXT);
+ if (fullName[strlen(fullName)-1] == '/')
+ fullName[strlen(fullName)-1] = '\0';
+ else
+ strcat(fullName, GNUNET_DIRECTORY_EXT);
while (NULL != (dotdot = strstr(fullName, "..")))
dotdot[0] = dotdot[1] = '_';
mkdirp(fullName);
@@ -228,18 +231,25 @@
(dl->is_directory) ) {
char * dirBlock;
int fd;
+ char * fn;
+ fn = MALLOC(strlen(dl->filename) + 3 + strlen(GNUNET_DIRECTORY_EXT));
+ strcpy(fn, dl->filename);
+ if (fn[strlen(fn)-1] == '/') {
+ fn[strlen(fn)-1] = '\0';
+ strcat(fn, GNUNET_DIRECTORY_EXT);
+ }
#ifdef O_LARGEFILE
- fd = fileopen(dl->filename,
+ fd = fileopen(fn,
O_LARGEFILE | O_RDONLY);
#else
- fd = fileopen(dl->filename,
+ fd = fileopen(fn,
O_RDONLY);
#endif
if (fd == -1) {
LOG_FILE_STRERROR(LOG_ERROR,
"OPEN",
- dl->filename);
+ fn);
} else {
dirBlock = MMAP(NULL,
totalBytes,
@@ -247,19 +257,24 @@
MAP_SHARED,
fd,
0);
- /* load directory, start downloads */
- md = NULL;
- MUTEX_LOCK(&dl->ctx->lock);
- ECRS_listDirectory(dirBlock,
- totalBytes,
- &md,
- &triggerRecursiveDownload,
- dl);
- MUTEX_UNLOCK(&dl->ctx->lock);
- ECRS_freeMetaData(md);
- MUNMAP(dirBlock, totalBytes);
+ if (MAP_FAILED == dirBlock) {
+ LOG_FILE_STRERROR(LOG_ERROR, "MMAP", fn);
+ } else {
+ /* load directory, start downloads */
+ md = NULL;
+ MUTEX_LOCK(&dl->ctx->lock);
+ ECRS_listDirectory(dirBlock,
+ totalBytes,
+ &md,
+ &triggerRecursiveDownload,
+ dl);
+ MUTEX_UNLOCK(&dl->ctx->lock);
+ ECRS_freeMetaData(md);
+ MUNMAP(dirBlock, totalBytes);
+ }
closefile(fd);
}
+ FREE(fn);
}
if (ret != OK) {
if (dl->signalTerminate == YES) {
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2006-03-11 22:47:05 UTC (rev
2485)
+++ GNUnet/src/applications/fs/fsui/upload.c 2006-03-11 23:10:18 UTC (rev
2486)
@@ -287,9 +287,14 @@
0);
}
if (ret == OK) {
+ char * mfilename = MALLOC(strlen(filename) + 2);
+ strcpy(mfilename, filename);
+ if (YES == isDirectory(fn))
+ strcat(mfilename, '/');
ECRS_addToMetaData(meta,
EXTRACTOR_FILENAME,
- filename);
+ mfilename);
+ FREE(mfilename);
if (utc->individualKeywords) {
keywordUri = ECRS_metaDataToUri(meta);
if (keywordUri != NULL) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r2486 - in GNUnet/src/applications/fs: ecrs fsui,
grothoff <=