All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabrice Bellard <fabrice@bellard.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] qemu qemu-img.c
Date: Wed, 14 Jun 2006 15:32:10 +0000	[thread overview]
Message-ID: <E1FqXLm-000168-GM@savannah.gnu.org> (raw)

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
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 <windows.h>
+#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;

             reply	other threads:[~2006-06-14 15:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14 15:32 Fabrice Bellard [this message]
2006-08-01 15:51 [Qemu-devel] qemu qemu-img.c Fabrice Bellard
2006-08-07 21:33 Fabrice Bellard
2007-02-10 22:59 Thiemo Seufer
2007-10-24 16:11 Thiemo Seufer
2007-10-31  1:11 Andrzej Zaborowski
2007-11-11  3:33 Paul Brook
2008-02-10 14:10 Andrzej Zaborowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1FqXLm-000168-GM@savannah.gnu.org \
    --to=fabrice@bellard.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.