33 #elif HAVE_MAPVIEWOFFILE
49 int log_offset,
void *log_ctx)
52 int err, fd = open(filename, O_RDONLY);
66 if (fstat(fd, &st) < 0) {
74 off_size = st.st_size;
75 if (off_size > SIZE_MAX) {
77 "File size for file '%s' is too big\n", filename);
84 ptr = mmap(
NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
85 if (ptr == MAP_FAILED) {
93 #elif HAVE_MAPVIEWOFFILE
95 HANDLE
mh, fh = (HANDLE)_get_osfhandle(fd);
97 mh = CreateFileMapping(fh,
NULL, PAGE_READONLY, 0, 0,
NULL);
104 ptr = MapViewOfFile(mh, FILE_MAP_READ, 0, 0, *size);
121 read(fd, *bufptr, *size);
131 munmap(bufptr, size);
132 #elif HAVE_MAPVIEWOFFILE
133 UnmapViewOfFile(bufptr);
139 int av_tempfile(
const char *prefix,
char **filename,
int log_offset,
void *log_ctx) {
143 void *ptr= tempnam(
NULL, prefix);
145 ptr= tempnam(
".", prefix);
150 size_t len = strlen(prefix) + 12;
154 if (*filename ==
NULL) {
167 snprintf(*filename, len,
"/tmp/%sXXXXXX", prefix);
168 fd = mkstemp(*filename);
171 snprintf(*filename, len,
"./%sXXXXXX", prefix);
172 fd = mkstemp(*filename);
179 av_log(&file_log_ctx,
AV_LOG_ERROR,
"ff_tempfile: Cannot open temporary file %s\n", *filename);