/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
* @file include/gnunet_disk_lib.h
* @brief disk IO apis
*/
-
#ifndef GNUNET_DISK_LIB_H
#define GNUNET_DISK_LIB_H
-#include "gnunet_configuration_lib.h"
-#include "gnunet_scheduler_lib.h"
+/**
+ * Opaque handle used to access files.
+ */
+struct GNUNET_DISK_FileHandle;
+
+/**
+ * Opaque handle used to manage a pipe.
+ */
+struct GNUNET_DISK_PipeHandle;
+
/* we need size_t, and since it can be both unsigned int
or unsigned long long, this IS platform dependent;
but "stdlib.h" should be portable 'enough' to be
unconditionally available... */
#include <stdlib.h>
+#include "gnunet_configuration_lib.h"
+#include "gnunet_scheduler_lib.h"
#ifdef __cplusplus
extern "C"
#endif
#endif
+
/* Open the file for reading */
#define GNUNET_DISK_OPEN_READ 1
/* Open the file for writing */
#define GNUNET_DISK_PERM_OTHER_WRITE 128
#define GNUNET_DISK_PERM_OTHER_EXEC 256
-enum GNUNET_DISK_Seek {GNUNET_SEEK_SET, GNUNET_SEEK_CUR, GNUNET_SEEK_END};
-
-struct GNUNET_DISK_FileHandle;
+enum GNUNET_DISK_Seek
+ {
+ GNUNET_DISK_SEEK_SET,
+ GNUNET_DISK_SEEK_CUR,
+ GNUNET_DISK_SEEK_END
+ };
/**
* Get the number of blocks that are left on the partition that
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int GNUNET_DISK_file_size (const char *filename,
- unsigned long long *size, int includeSymLinks);
+ unsigned long long *size, int includeSymLinks);
+
+
+/**
+ * Create an (empty) temporary file on disk.
+ *
+ * @param template component to use for the name;
+ * does NOT contain "XXXXXX" or "/tmp/".
+ * @return NULL on error, otherwise name of fresh
+ * file on disk in directory for temporary files
+ */
+char *
+GNUNET_DISK_mktemp (const char *template);
/**
*/
struct GNUNET_DISK_FileHandle *GNUNET_DISK_file_open (const char *fn, int flags, ...);
+/**
+ * Creates an interprocess channel
+ * @param blocking creates an asynchronous pipe if set to GNUNET_NO
+ * @return handle to the new pipe, NULL on error
+ */
+struct GNUNET_DISK_PipeHandle *GNUNET_DISK_pipe (int blocking);
+
+/**
+ * Closes an interprocess channel
+ * @param p pipe
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ */
+int GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p);
/**
* Close an open file.
*/
int GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h);
+/**
+ * Get the handle to a particular pipe end
+ * @param p pipe
+ * @param n number of the end
+ */
+const struct GNUNET_DISK_FileHandle *GNUNET_DISK_pipe_handle (const struct
+ GNUNET_DISK_PipeHandle
+ *p, int n);
/**
* Read the contents of a binary file into a buffer.
* @return the number of files found, -1 on error
*/
int GNUNET_DISK_directory_scan (const char *dirName,
- GNUNET_FileNameCallback callback, void *data);
+ GNUNET_FileNameCallback callback,
+ void *data);
/**