[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1972 - gnunet-gtk/src/plugins/fs
From: |
durner |
Subject: |
[GNUnet-SVN] r1972 - gnunet-gtk/src/plugins/fs |
Date: |
Sat, 27 Aug 2005 14:41:55 -0700 (PDT) |
Author: durner
Date: 2005-08-27 14:41:51 -0700 (Sat, 27 Aug 2005)
New Revision: 1972
Modified:
gnunet-gtk/src/plugins/fs/download.c
gnunet-gtk/src/plugins/fs/fs.h
Log:
rename directory files
Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c 2005-08-27 20:24:40 UTC (rev
1971)
+++ gnunet-gtk/src/plugins/fs/download.c 2005-08-27 21:41:51 UTC (rev
1972)
@@ -118,6 +118,9 @@
const char * name;
struct stat sbuf;
unsigned int anon;
+ GtkTreePath *dirTreePath;
+ char *dirPath;
+ unsigned int dirPathLen;
uri = NULL;
meta = NULL;
@@ -226,6 +229,31 @@
FREE(pfx);
pfx = STRDUP(lnk);
}
+
+ /* If file is inside a directory, get the full path */
+ dirTreePath = gtk_tree_path_copy(path);
+ dirPath = MALLOC(1);
+ dirPathLen = 0;
+ while (gtk_tree_path_up(dirTreePath)) {
+ const char *dirname;
+ char *new;
+
+ if (!gtk_tree_model_get_iter(model, &iiter, dirTreePath))
+ break;
+ gtk_tree_model_get(model,
+ &iiter,
+ SEARCH_NAME, &dirname,
+ -1);
+ dirPathLen += strlen(dirname) + 1;
+ new = MALLOC(dirPathLen + 1);
+ strcpy(new, dirname);
+ strcat(new, DIR_SEPARATOR_STR);
+ strcat(new, dirPath);
+ FREE(dirPath);
+ dirPath = new;
+ }
+ g_object_unref(dirTreePath);
+
list->filename = pfx;
head = list;
gtk_tree_store_insert(summary,
@@ -241,6 +269,7 @@
DOWNLOAD_URISTRING, filename,
DOWNLOAD_URI, ECRS_dupUri(uri),
DOWNLOAD_TREEPATH, list->rr,
+ DOWNLOAD_DIRPATH, dirPath,
/* internal: row reference! */
-1);
FREE(filename);
@@ -326,6 +355,7 @@
GtkTreeIter iter;
GtkTreePath * path;
struct ECRS_URI * u;
+ char *dirPath;
pos = head;
while (pos != NULL) {
@@ -381,6 +411,7 @@
DOWNLOAD_URI, &u,
DOWNLOAD_FILENAME, &fn,
DOWNLOAD_LINKNAME, &ln,
+ DOWNLOAD_DIRPATH, &dirPath,
-1);
if (ECRS_equalsUri(u, uri)) {
char *dstPath, *newFn, *dstFile;
@@ -394,6 +425,20 @@
" in section `%s' under `%s'."));
if (!dstPath)
return;
+
+ /* If file is contained in a directory, create directory structure in
+ the file system. */
+ if (dirPath) {
+ unsigned int pathLen = strlen(dirPath);
+ if (pathLen) {
+ pathLen += strlen(dstPath) + 2;
+ dstPath = REALLOC(dstPath, pathLen);
+ strcat(dstPath, DIR_SEPARATOR_STR);
+ strcat(dstPath, dirPath);
+ FREE(dirPath);
+ }
+ }
+
mkdirp(dstPath);
dstFile = MALLOC(strlen(dstPath) + strlen(newFn) + 2);
@@ -575,7 +620,8 @@
G_TYPE_INT, /* progress */
G_TYPE_STRING, /* uri */
G_TYPE_POINTER, /* url */
- G_TYPE_POINTER); /* internal: gtk tree path / NULL */
+ G_TYPE_POINTER, /* internal: gtk tree path / NULL */
+ G_TYPE_POINTER); /* directory path if file is inside a
dir */
gtk_tree_view_set_model(GTK_TREE_VIEW(downloadList),
GTK_TREE_MODEL(summary));
renderer = gtk_cell_renderer_progress_new();
@@ -611,6 +657,7 @@
GtkTreeIter iter;
struct ECRS_URI * u;
DownloadList * pos;
+ char *dirPath;
/* free URIs in summary model */
if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(summary),
@@ -620,6 +667,7 @@
gtk_tree_model_get(GTK_TREE_MODEL(summary),
&iter,
DOWNLOAD_URI, &u,
+ DOWNLOAD_DIRPATH, &dirPath,
-1);
gtk_tree_store_set(summary,
&iter,
@@ -627,6 +675,7 @@
-1);
if (u != NULL)
ECRS_freeUri(u);
+ FREENONNULL(dirPath);
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
&iter));
while (head != NULL) {
Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h 2005-08-27 20:24:40 UTC (rev 1971)
+++ gnunet-gtk/src/plugins/fs/fs.h 2005-08-27 21:41:51 UTC (rev 1972)
@@ -65,6 +65,7 @@
DOWNLOAD_URISTRING,
DOWNLOAD_URI,
DOWNLOAD_TREEPATH,
+ DOWNLOAD_DIRPATH,
DOWNLOAD_NUM
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1972 - gnunet-gtk/src/plugins/fs,
durner <=