qemu qemu-img.c
CVSROOT: /sources/qemu
Module name: qemu
Changes by: Fabrice Bellard <bellard> 06/06/14 15:32:10
Modified files:
. : qemu-img.c
Log message:
show real allocated disk image size on Windows (Frediano Ziglio)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/qemu-img.c?cvsroot=qemu&r1=1.8&r2=1.9
Patches:
Index: qemu-img.c
===================================================================
RCS file: /sources/qemu/qemu/qemu-img.c,v
retrieving revision 1.8
retrieving revision 1.9
qemu-img.c +16 -0
@@ -23,6 +23,10 @@*/ #include "vl.h" +#ifdef _WIN32 +#include <windows.h> +#endif +void *get_mmap_addr (unsigned long size) {return NULL ;
@@ -598,7 +602,19 @@#ifdef _WIN32static 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;