[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r462 - in GNUnet/src: applications/fs/ecrs applications/fs/
From: |
grothoff |
Subject: |
[GNUnet-SVN] r462 - in GNUnet/src: applications/fs/ecrs applications/fs/lib include |
Date: |
Sun, 20 Mar 2005 15:29:40 -0800 (PST) |
Author: grothoff
Date: 2005-03-20 15:29:39 -0800 (Sun, 20 Mar 2005)
New Revision: 462
Modified:
GNUnet/src/applications/fs/ecrs/indexinfo.c
GNUnet/src/applications/fs/lib/fslib.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_fs_lib.h
Log:
stuff
Modified: GNUnet/src/applications/fs/ecrs/indexinfo.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/indexinfo.c 2005-03-20 22:59:14 UTC (rev
461)
+++ GNUnet/src/applications/fs/ecrs/indexinfo.c 2005-03-20 23:29:39 UTC (rev
462)
@@ -26,16 +26,11 @@
#include "platform.h"
#include "gnunet_ecrs_lib.h"
+#include "gnunet_getoption_lib.h"
/**
* Test if a file is indexed.
*
- * This function will ONLY work if gnunetd runs on the
- * same machine as the current process and if the indexed
- * files could be symlinked. If indexed files had to be
- * uploaded to a remote machine or copied, the original
- * names will have been lost.
- *
* @return YES if the file is indexed, NO if not, SYSERR on errors
* (i.e. filename could not be accessed and thus we have problems
* checking; also possible that the file was modified after indexing;
@@ -43,9 +38,45 @@
* be notified that 'something is wrong')
*/
int ECRS_isFileIndexed(const char * filename) {
- return SYSERR;
+ HashCode512 hc;
+ GNUNET_TCP_SOCKET * sock;
+ int ret;
+
+ if (SYSERR == getFileHash(filename,
+ &hc))
+ return SYSERR;
+ sock = getClientSocket();
+ if (sock == NULL)
+ return SYSERR;
+ ret = FS_testIndexed(sock,
+ &hc);
+ releaseClientSocket(sock);
+ return ret;
}
+struct iiC {
+ ECRS_FileIterator iterator;
+ void * closure;
+ int cnt;
+};
+
+static void iiHelper(const char * fn,
+ const char * dir,
+ struct iiC * cls) {
+ char * fullName;
+ char * lnkName;
+
+ if (cls->cnt == SYSERR)
+ return;
+
+ // FIXME: implement!
+ cls->cnt++;
+ if (OK != cls->iterator(lnkName,
+ cls->closure))
+ cls->cnt = SYSERR;
+ FREE(lnkName);
+}
+
/**
* Iterate over all indexed files.
*
@@ -60,7 +91,25 @@
*/
int ECRS_iterateIndexedFiles(ECRS_FileIterator iterator,
void * closure) {
- return SYSERR;
+ char * indexDirectory;
+ GNUNET_TCP_SOCKET * sock;
+ struct iiC cls;
+
+ sock = getClientSocket();
+ if (sock == NULL)
+ return 0;
+ indexDirectory = getConfigurationOptionValue(sock,
+ "FIXME",
+ "FIXME");
+ releaseClientSocket(sock);
+ cls.iterator = iterator;
+ cls.closure = closure;
+ cls.cnt = 0;
+ scanDirectory((DirectoryEntryCallback) &indexDirectory,
+ &iiHelper,
+ &cls);
+ FREE(indexDirectory);
+ return cls.cnt;
}
/* end of indexinfo.c */
Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c 2005-03-20 22:59:14 UTC (rev
461)
+++ GNUnet/src/applications/fs/lib/fslib.c 2005-03-20 23:29:39 UTC (rev
462)
@@ -431,4 +431,17 @@
return ret;
}
+/**
+ * Test if a file of the given hash is indexed.
+ *
+ * @param hc the hash of the entire file
+ * @return YES if so, NO if not, SYSERR on error
+ */
+int FS_testIndexed(GNUNET_TCP_SOCKET * sock,
+ const HashCode512 * hc) {
+ // FIXME: implement!
+ return SYSERR;
+}
+
+
/* end of fslib.c */
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-20 22:59:14 UTC (rev
461)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2005-03-20 23:29:39 UTC (rev
462)
@@ -353,12 +353,6 @@
/**
* Test if a file is indexed.
*
- * This function will ONLY work if gnunetd runs on the
- * same machine as the current process and if the indexed
- * files could be symlinked. If indexed files had to be
- * uploaded to a remote machine or copied, the original
- * names will have been lost.
- *
* @return YES if the file is indexed, NO if not, SYSERR on errors
* (i.e. filename could not be accessed and thus we have problems
* checking; also possible that the file was modified after indexing;
Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h 2005-03-20 22:59:14 UTC (rev 461)
+++ GNUnet/src/include/gnunet_fs_lib.h 2005-03-20 23:29:39 UTC (rev 462)
@@ -129,4 +129,13 @@
unsigned int blocksize,
const HashCode512 * hc);
+/**
+ * Test if a file of the given hash is indexed.
+ *
+ * @param hc the hash of the entire file
+ * @return YES if so, NO if not, SYSERR on error
+ */
+int FS_testIndexed(GNUNET_TCP_SOCKET * sock,
+ const HashCode512 * hc);
+
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r462 - in GNUnet/src: applications/fs/ecrs applications/fs/lib include,
grothoff <=