yading@11: /* yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVUTIL_FILE_H yading@11: #define AVUTIL_FILE_H yading@11: yading@11: #include yading@11: yading@11: #include "avutil.h" yading@11: yading@11: /** yading@11: * @file yading@11: * Misc file utilities. yading@11: */ yading@11: yading@11: /** yading@11: * Read the file with name filename, and put its content in a newly yading@11: * allocated buffer or map it with mmap() when available. yading@11: * In case of success set *bufptr to the read or mmapped buffer, and yading@11: * *size to the size in bytes of the buffer in *bufptr. yading@11: * The returned buffer must be released with av_file_unmap(). yading@11: * yading@11: * @param log_offset loglevel offset used for logging yading@11: * @param log_ctx context used for logging yading@11: * @return a non negative number in case of success, a negative value yading@11: * corresponding to an AVERROR error code in case of failure yading@11: */ yading@11: int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, yading@11: int log_offset, void *log_ctx); yading@11: yading@11: /** yading@11: * Unmap or free the buffer bufptr created by av_file_map(). yading@11: * yading@11: * @param size size in bytes of bufptr, must be the same as returned yading@11: * by av_file_map() yading@11: */ yading@11: void av_file_unmap(uint8_t *bufptr, size_t size); yading@11: yading@11: /** yading@11: * Wrapper to work around the lack of mkstemp() on mingw. yading@11: * Also, tries to create file in /tmp first, if possible. yading@11: * *prefix can be a character constant; *filename will be allocated internally. yading@11: * @return file descriptor of opened file (or -1 on error) yading@11: * and opened file name in **filename. yading@11: * @note On very old libcs it is necessary to set a secure umask before yading@11: * calling this, av_tempfile() cant call umask itself as it is used in yading@11: * libraries and could interfere with the calling application. yading@11: */ yading@11: int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); yading@11: yading@11: #endif /* AVUTIL_FILE_H */