summaryrefslogtreecommitdiff
path: root/libavformat/avio.h
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki2@gmail.com>2014-07-05 18:11:59 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-03-27 18:29:46 +0100
commit184084c6998cd04c0afdda076d7c95be0d6b2d22 (patch)
treeeabe49bf64eac0d759da7230e0d10541fbe34779 /libavformat/avio.h
parentdbce8cdacf0c610a69cbf0d2959d793957dd4dfa (diff)
lavf: add directory listing API
API allows protocol implementations to provide API that allows to list directory content. API is similar to POSIX opendir/readdir/closedir. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avio.h')
-rw-r--r--libavformat/avio.h84
1 files changed, 83 insertions, 1 deletions
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 8fc7e27d4e..bbd482a52e 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -34,7 +34,6 @@
#include "libavformat/version.h"
-
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
/**
@@ -54,6 +53,47 @@ typedef struct AVIOInterruptCB {
} AVIOInterruptCB;
/**
+ * Directory entry types.
+ */
+enum AVIODirEntryType {
+ AVIO_ENTRY_UNKNOWN,
+ AVIO_ENTRY_BLOCK_DEVICE,
+ AVIO_ENTRY_CHARACTER_DEVICE,
+ AVIO_ENTRY_DIRECTORY,
+ AVIO_ENTRY_NAMED_PIPE,
+ AVIO_ENTRY_SYMBOLIC_LINK,
+ AVIO_ENTRY_SOCKET,
+ AVIO_ENTRY_FILE
+};
+
+/**
+ * Describes single entry of the directory.
+ *
+ * Only name and type fields are guaranteed be set.
+ * Rest of fields are protocol or/and platform dependent and might be unknown.
+ */
+typedef struct AVIODirEntry {
+ char *name; /**< Filename */
+ int type; /**< Type of the entry */
+ int utf8; /**< Set to 1 when name is encoded with UTF-8, 0 otherwise.
+ Name can be encoded with UTF-8 eventhough 0 is set. */
+ int64_t size; /**< File size in bytes, -1 if unknown. */
+ int64_t modification_timestamp; /**< Time of last modification in microseconds since unix
+ epoch, -1 if unknown. */
+ int64_t access_timestamp; /**< Time of last access in microseconds since unix epoch,
+ -1 if unknown. */
+ int64_t status_change_timestamp; /**< Time of last status change in microseconds since unix
+ epoch, -1 if unknown. */
+ int64_t user_id; /**< User ID of owner, -1 if unknown. */
+ int64_t group_id; /**< Group ID of owner, -1 if unknown. */
+ int64_t filemode; /**< Unix file mode, -1 if unknown. */
+} AVIODirEntry;
+
+typedef struct AVIODirContext {
+ struct URLContext *url_context;
+} AVIODirContext;
+
+/**
* Bytestream IO Context.
* New fields can be added to the end with minor version bumps.
* Removal, reordering and changes to existing fields require a major
@@ -181,6 +221,48 @@ const char *avio_find_protocol_name(const char *url);
int avio_check(const char *url, int flags);
/**
+ * Open directory for reading.
+ *
+ * @param s directory read context. Pointer to a NULL pointer must be passed.
+ * @param url directory to be listed.
+ * @param options A dictionary filled with protocol-private options. On return
+ * this parameter will be destroyed and replaced with a dictionary
+ * containing options that were not found. May be NULL.
+ * @return >=0 on success or negative on error.
+ */
+int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options);
+
+/**
+ * Get next directory entry.
+ *
+ * Returned entry must be freed with avio_free_directory_entry(). In particular
+ * it may outlive AVIODirContext.
+ *
+ * @param s directory read context.
+ * @param[out] next next entry or NULL when no more entries.
+ * @return >=0 on success or negative on error.
+ */
+int avio_read_dir(AVIODirContext *s, AVIODirEntry **next);
+
+/**
+ * Close directory.
+ *
+ * @note Entries created using avio_read_dir() are not deleted and must be
+ * freeded with avio_free_directory_entry().
+ *
+ * @param s directory read context.
+ * @return >=0 on success or negative on error.
+ */
+int avio_close_dir(AVIODirContext **s);
+
+/**
+ * Free entry allocated by avio_read_dir().
+ *
+ * @param entry entry to be freed.
+ */
+void avio_free_directory_entry(AVIODirEntry **entry);
+
+/**
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
* freed with av_free().
*