From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FqXLo-0005JC-UO for qemu-devel@nongnu.org; Wed, 14 Jun 2006 11:32:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FqXLo-0005H1-5F for qemu-devel@nongnu.org; Wed, 14 Jun 2006 11:32:12 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FqXLn-0005Gu-Th for qemu-devel@nongnu.org; Wed, 14 Jun 2006 11:32:12 -0400 Received: from [199.232.41.3] (helo=savannah.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FqXV0-0001hf-5s for qemu-devel@nongnu.org; Wed, 14 Jun 2006 11:41:42 -0400 Received: from savannah.gnu.org ([127.0.0.1]) by savannah.gnu.org with esmtp (Exim 3.36 #1 (Debian)) id 1FqXLm-00016B-00 for ; Wed, 14 Jun 2006 11:32:10 -0400 Received: from bellard by savannah.gnu.org with local (Exim 4.50) id 1FqXLm-000168-GM for qemu-devel@nongnu.org; Wed, 14 Jun 2006 15:32:10 +0000 Message-Id: From: Fabrice Bellard Date: Wed, 14 Jun 2006 15:32:10 +0000 Subject: [Qemu-devel] qemu qemu-img.c Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org CVSROOT: /sources/qemu Module name: qemu Changes by: Fabrice 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 diff -u -b -r1.8 -r1.9 --- qemu-img.c 24 Jul 2005 18:44:55 -0000 1.8 +++ qemu-img.c 14 Jun 2006 15:32:10 -0000 1.9 @@ -23,6 +23,10 @@ */ #include "vl.h" +#ifdef _WIN32 +#include +#endif + void *get_mmap_addr(unsigned long size) { return NULL; @@ -598,7 +602,19 @@ #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;