Commit e8445331 authored by bellard's avatar bellard

show real allocated disk image size on Windows (Frediano Ziglio)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162
parent 8f447cc7
......@@ -23,6 +23,10 @@
#include "vl.h"
#ifdef _WIN32
#include <windows.h>
void *get_mmap_addr(unsigned long size)
return NULL;
......@@ -598,7 +602,19 @@ static int img_convert(int argc, char **argv)
#ifdef _WIN32
static int64_t get_allocated_file_size(const char *filename)
typedef DWORD (WINAPI * get_compressed_t)(const char *filename, DWORD *high);
get_compressed_t get_compressed;
struct _stati64 st;
/* WinNT support GetCompressedFileSize to determine allocate size */
get_compressed = (get_compressed_t) GetProcAddress(GetModuleHandle("kernel32"), "GetCompressedFileSizeA");
if (get_compressed) {
DWORD high, low;
low = get_compressed(filename, &high);
if (low != 0xFFFFFFFFlu || GetLastError() == NO_ERROR)
return (((int64_t) high) << 32) + low;
if (_stati64(filename, &st) < 0)
return -1;
return st.st_size;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment