34 #elif HAVE_MAPVIEWOFFILE
50 int log_offset,
void *log_ctx)
67 if (fstat(fd, &st) < 0) {
75 off_size = st.st_size;
76 if (off_size > SIZE_MAX) {
78 "File size for file '%s' is too big\n", filename);
85 ptr = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
86 if (ptr == MAP_FAILED) {
94 #elif HAVE_MAPVIEWOFFILE
98 mh = CreateFileMapping(fh, NULL, PAGE_READONLY, 0, 0, NULL);
105 ptr = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, *size);
122 read(fd, *bufptr, *size);
132 munmap(bufptr, size);
133 #elif HAVE_MAPVIEWOFFILE
134 UnmapViewOfFile(bufptr);
140 int av_tempfile(
const char *prefix,
char **filename,
int log_offset,
void *log_ctx) {
144 void *ptr= tempnam(NULL, prefix);
146 ptr= tempnam(
".", prefix);
151 size_t len = strlen(prefix) + 12;
155 if (*filename == NULL) {
168 snprintf(*filename, len,
"/tmp/%sXXXXXX", prefix);
169 fd = mkstemp(*filename);
172 snprintf(*filename, len,
"./%sXXXXXX", prefix);
173 fd = mkstemp(*filename);
180 av_log(&file_log_ctx,
AV_LOG_ERROR,
"ff_tempfile: Cannot open temporary file %s\n", *filename);
195 if (
av_file_map(
"file.c", &buf, &size, 0, NULL) < 0)
#define LIBAVUTIL_VERSION_INT
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx)
Wrapper to work around the lack of mkstemp() on mingw.
const char * av_default_item_name(void *ctx)
Return the context name.
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define av_unused
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
common internal API header
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
memory handling functions
static void close(AVCodecParserContext *s)
Describe the class of an AVClass context structure.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static const AVClass file_log_ctx_class
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
int main(int argc, char **argv)