diff options
author | Chris Robinson <[email protected]> | 2018-11-09 23:51:29 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-09 23:51:29 -0800 |
commit | 68bcf81756d160f9bf1c6c68b9d83611754ff54a (patch) | |
tree | b6b8362894418a539c333125aa16d470eafe86cd /Alc/helpers.c | |
parent | d8163a416a00780bced89fd0efca9e641637395f (diff) |
Remove the unused file mapping calls
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r-- | Alc/helpers.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 0d5087e6..41e4fdc9 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -614,68 +614,6 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir) return results; } - -struct FileMapping MapFileToMem(const char *fname) -{ - struct FileMapping ret = { NULL, NULL, NULL, 0 }; - MEMORY_BASIC_INFORMATION meminfo; - HANDLE file, fmap; - WCHAR *wname; - void *ptr; - - wname = FromUTF8(fname); - - file = CreateFileW(wname, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if(file == INVALID_HANDLE_VALUE) - { - ERR("Failed to open %s: %lu\n", fname, GetLastError()); - free(wname); - return ret; - } - free(wname); - wname = NULL; - - fmap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL); - if(!fmap) - { - ERR("Failed to create map for %s: %lu\n", fname, GetLastError()); - CloseHandle(file); - return ret; - } - - ptr = MapViewOfFile(fmap, FILE_MAP_READ, 0, 0, 0); - if(!ptr) - { - ERR("Failed to map %s: %lu\n", fname, GetLastError()); - CloseHandle(fmap); - CloseHandle(file); - return ret; - } - - if(VirtualQuery(ptr, &meminfo, sizeof(meminfo)) != sizeof(meminfo)) - { - ERR("Failed to get map size for %s: %lu\n", fname, GetLastError()); - UnmapViewOfFile(ptr); - CloseHandle(fmap); - CloseHandle(file); - return ret; - } - - ret.file = file; - ret.fmap = fmap; - ret.ptr = ptr; - ret.len = meminfo.RegionSize; - return ret; -} - -void UnmapFileMem(const struct FileMapping *mapping) -{ - UnmapViewOfFile(mapping->ptr); - CloseHandle(mapping->fmap); - CloseHandle(mapping->file); -} - #else void GetProcBinary(al_string *path, al_string *fname) @@ -959,47 +897,6 @@ vector_al_string SearchDataFiles(const char *ext, const char *subdir) return results; } - -struct FileMapping MapFileToMem(const char *fname) -{ - struct FileMapping ret = { -1, NULL, 0 }; - struct stat sbuf; - void *ptr; - int fd; - - fd = open(fname, O_RDONLY, 0); - if(fd == -1) - { - ERR("Failed to open %s: (%d) %s\n", fname, errno, strerror(errno)); - return ret; - } - if(fstat(fd, &sbuf) == -1) - { - ERR("Failed to stat %s: (%d) %s\n", fname, errno, strerror(errno)); - close(fd); - return ret; - } - - ptr = mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if(ptr == MAP_FAILED) - { - ERR("Failed to map %s: (%d) %s\n", fname, errno, strerror(errno)); - close(fd); - return ret; - } - - ret.fd = fd; - ret.ptr = ptr; - ret.len = sbuf.st_size; - return ret; -} - -void UnmapFileMem(const struct FileMapping *mapping) -{ - munmap(mapping->ptr, mapping->len); - close(mapping->fd); -} - #endif |