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)
145 void *ptr= tempnam(
NULL, prefix);
147 ptr= tempnam(
".", prefix);
152 size_t len = strlen(prefix) + 12;
169 snprintf(*filename, len,
"/tmp/%sXXXXXX", prefix);
170 fd = mkstemp(*filename);
173 snprintf(*filename, len,
"./%sXXXXXX", prefix);
174 fd = mkstemp(*filename);
181 av_log(&file_log_ctx,
AV_LOG_ERROR,
"ff_tempfile: Cannot open temporary file %s\n", *filename);