Revision 4a1d5e1f block/raw-win32.c
b/block/raw-win32.c | ||
---|---|---|
213 | 213 |
return l.QuadPart; |
214 | 214 |
} |
215 | 215 |
|
216 |
static int64_t raw_get_allocated_file_size(BlockDriverState *bs) |
|
217 |
{ |
|
218 |
typedef DWORD (WINAPI * get_compressed_t)(const char *filename, |
|
219 |
DWORD * high); |
|
220 |
get_compressed_t get_compressed; |
|
221 |
struct _stati64 st; |
|
222 |
const char *filename = bs->filename; |
|
223 |
/* WinNT support GetCompressedFileSize to determine allocate size */ |
|
224 |
get_compressed = |
|
225 |
(get_compressed_t) GetProcAddress(GetModuleHandle("kernel32"), |
|
226 |
"GetCompressedFileSizeA"); |
|
227 |
if (get_compressed) { |
|
228 |
DWORD high, low; |
|
229 |
low = get_compressed(filename, &high); |
|
230 |
if (low != 0xFFFFFFFFlu || GetLastError() == NO_ERROR) { |
|
231 |
return (((int64_t) high) << 32) + low; |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
if (_stati64(filename, &st) < 0) { |
|
236 |
return -1; |
|
237 |
} |
|
238 |
return st.st_size; |
|
239 |
} |
|
240 |
|
|
216 | 241 |
static int raw_create(const char *filename, QEMUOptionParameter *options) |
217 | 242 |
{ |
218 | 243 |
int fd; |
... | ... | |
257 | 282 |
.bdrv_write = raw_write, |
258 | 283 |
.bdrv_truncate = raw_truncate, |
259 | 284 |
.bdrv_getlength = raw_getlength, |
285 |
.bdrv_get_allocated_file_size |
|
286 |
= raw_get_allocated_file_size, |
|
260 | 287 |
|
261 | 288 |
.create_options = raw_create_options, |
262 | 289 |
}; |
... | ... | |
419 | 446 |
.bdrv_read = raw_read, |
420 | 447 |
.bdrv_write = raw_write, |
421 | 448 |
.bdrv_getlength = raw_getlength, |
449 |
.bdrv_get_allocated_file_size |
|
450 |
= raw_get_allocated_file_size, |
|
422 | 451 |
}; |
423 | 452 |
|
424 | 453 |
static void bdrv_file_init(void) |
Also available in: Unified diff