summaryrefslogtreecommitdiff
path: root/libavutil/file.h
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-12-22 14:13:04 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-12-22 14:13:04 +0000
commit0328b9ea39e86cb462a189eb1dfcc4065c1f332b (patch)
tree7a9849a6e29dad0ca6a72ccf040137179951bf05 /libavutil/file.h
parent1ce9d6b85fea7c4d209d9e54009177ccf4b91222 (diff)
downloadffmpeg-0328b9ea39e86cb462a189eb1dfcc4065c1f332b.tar.gz
Add av_file_map() and av_file_unmap() functions.
Originally committed as revision 26073 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/file.h')
-rw-r--r--libavutil/file.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/libavutil/file.h b/libavutil/file.h
new file mode 100644
index 0000000000..f94d7803f1
--- /dev/null
+++ b/libavutil/file.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_FILE_H
+#define AVUTIL_FILE_H
+
+#include "avutil.h"
+
+/**
+ * @file misc file utilities
+ */
+
+/**
+ * Read the file with name filename, and put its content in a newly
+ * allocated buffer or map it with mmap() when available.
+ * In case of success set *bufptr to the read or mmapped buffer, and
+ * *size to the size in bytes of the buffer in *bufptr.
+ * The returned buffer must be released with av_file_unmap().
+ *
+ * @param log_offset loglevel offset used for logging
+ * @param log_ctx context used for logging
+ * @return a non negative number in case of success, a negative value
+ * corresponding to an AVERROR error code in case of failure
+ */
+int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
+ int log_offset, void *log_ctx);
+
+/**
+ * Unmap or free the buffer bufptr created by av_file_map().
+ *
+ * @param size size in bytes of bufptr, must be the same as returned
+ * by av_file_map()
+ */
+void av_file_unmap(uint8_t *bufptr, size_t size);
+
+#endif /* AVUTIL_FILE_H */