Changeset 47357 in vbox for trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
- Timestamp:
- Jul 23, 2013 5:45:24 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
r47343 r47357 1 1 /* $Id$ */ 2 2 /** @file 3 *4 3 * IO helper for IAppliance COM class implementations. 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2010-201 2Oracle Corporation7 * Copyright (C) 2010-2013 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 32 #include <iprt/stream.h> 34 33 #include <iprt/circbuf.h> 34 #include <iprt/vfs.h> 35 35 #include <VBox/vd.h> 36 36 #include <zlib.h> 37 //#define VBOX_MAIN_USE_VFS /** @todo Replace as much as possible with IPRT VFS. */ 37 38 38 39 /****************************************************************************** … … 1406 1407 AssertPtrReturn(pIfIo, VERR_INVALID_POINTER); 1407 1408 1409 /* 1410 * Open the source file. 1411 */ 1408 1412 void *pvStorage; 1409 1413 int rc = pIfIo->pfnOpen(pvUser, pcszFullFilenameIn, … … 1412 1416 if (RT_FAILURE(rc)) 1413 1417 return rc; 1418 #ifdef VBOX_MAIN_USE_VFS 1419 1420 /* Turn the source file handle/whatever into a VFS stream. */ 1421 RTVFSIOSTREAM hVfsIosCompressedSrc; 1422 rc = VDIfCreateVfsStream(pIfIo, pvStorage, RTFILE_O_READ, &hVfsIosCompressedSrc); 1423 if (RT_SUCCESS(rc)) 1424 { 1425 /* Pass the source thru gunzip. */ 1426 RTVFSIOSTREAM hVfsIosSrc; 1427 rc = RTZipGzipDecompressIoStream(hVfsIosCompressedSrc, 0, &hVfsIosSrc); 1428 if (RT_SUCCESS(rc)) 1429 { 1430 /* 1431 * Create the output file, including necessary paths. 1432 * Any existing file will be overwritten. 1433 */ 1434 rc = VirtualBox::ensureFilePathExists(Utf8Str(pcszFullFilenameOut), true /*fCreate*/); 1435 if (RT_SUCCESS(rc)) 1436 { 1437 RTVFSIOSTREAM hVfsIosDst; 1438 rc = RTVfsIoStrmOpenNormal(pcszFullFilenameOut, 1439 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL, 1440 &hVfsIosDst); 1441 if (RT_SUCCESS(rc)) 1442 { 1443 /* 1444 * Pump the bytes thru. If we fail, delete the output file. 1445 */ 1446 rc = RTVfsUtilPumpIoStreams(hVfsIosSrc, hVfsIosDst, 0); 1447 1448 RTVfsIoStrmRelease(hVfsIosDst); 1449 RTFileDelete(pcszFullFilenameOut); 1450 } 1451 } 1452 1453 RTVfsIoStrmRelease(hVfsIosSrc); 1454 } 1455 RTVfsIoStrmRelease(hVfsIosCompressedSrc); 1456 } 1457 pIfIo->pfnClose(pvUser, pvStorage); 1458 1459 #else 1414 1460 1415 1461 Bytef *decompressedBuffer = 0; … … 1435 1481 if (FAILED(rc)) 1436 1482 { 1437 rc = VBOX_E_FILE_ERROR; 1483 rc = VBOX_E_FILE_ERROR; /** @todo r=bird: You're mixing COM and VBox status codes... */ 1438 1484 break; 1439 1485 } … … 1532 1578 if (compressedBuffer) 1533 1579 RTMemFree(compressedBuffer); 1580 #endif /* !VBOX_MAIN_USE_VFS */ 1534 1581 1535 1582 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.