Changeset 4742 in vbox for trunk/src/VBox
- Timestamp:
- Sep 12, 2007 4:56:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/testcase/vditool.cpp
r4372 r4742 62 62 63 63 /** 64 * Our internal functions use UTF8 65 */ 66 static int FilenameToUtf8(char **pszUtf8Filename, const char *pszFilename) 67 { 68 int rc = RTStrCurrentCPToUtf8(pszUtf8Filename, pszFilename); 69 if (VBOX_FAILURE(rc)) 70 RTPrintf("Error converting filename '%s' to UTF8! (rc=%Rrc)\n", 71 pszFilename, rc); 72 return rc; 73 } 74 75 /** 64 76 * Prints a done message indicating success or failure. 65 77 * @returns rc … … 80 92 { 81 93 RTPrintf("Creating VDI: file=\"%s\" size=%u MB...\n", 82 pszFilename, cMBs); 83 int rc = VDICreateBaseImage(pszFilename, 84 VDI_IMAGE_TYPE_NORMAL, 85 (uint64_t)cMBs * (uint64_t)(1024 * 1024), 86 "Newly created test image", NULL, NULL); 94 pszFilename, cMBs); 95 96 /* translate argv[] to UTF8 */ 97 char *pszUtf8Filename; 98 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 99 if (VBOX_FAILURE(rc)) 100 return rc; 101 102 rc = VDICreateBaseImage(pszUtf8Filename, 103 VDI_IMAGE_TYPE_NORMAL, 104 (uint64_t)cMBs * (uint64_t)(1024 * 1024), 105 "Newly created test image", NULL, NULL); 87 106 return PrintDone(rc); 88 107 } … … 93 112 pszDDFilename, pszFilename); 94 113 114 /* translate argv[] to UTF8 */ 115 char *pszUtf8Filename, *pszUtf8DDFilename; 116 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 117 if (VBOX_FAILURE(rc)) 118 return rc; 119 rc = FilenameToUtf8(&pszUtf8DDFilename, pszDDFilename); 120 if (VBOX_FAILURE(rc)) 121 return rc; 122 95 123 /* open raw image file. */ 96 124 RTFILE File; 97 int rc = RTFileOpen(&File, pszDDFilename, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);125 rc = RTFileOpen(&File, pszUtf8DDFilename, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 98 126 if (VBOX_FAILURE(rc)) 99 127 { … … 108 136 { 109 137 RTPrintf("Creating fixed image with size %u Bytes...\n", (unsigned)cbFile); 110 rc = VDICreateBaseImage(psz Filename,138 rc = VDICreateBaseImage(pszUtf8Filename, 111 139 VDI_IMAGE_TYPE_FIXED, 112 140 cbFile, … … 117 145 RTPrintf("Writing data...\n"); 118 146 PVDIDISK pVdi = VDIDiskCreate(); 119 rc = VDIDiskOpenImage(pVdi, psz Filename, VDI_OPEN_FLAGS_NORMAL);147 rc = VDIDiskOpenImage(pVdi, pszUtf8Filename, VDI_OPEN_FLAGS_NORMAL); 120 148 if (VBOX_SUCCESS(rc)) 121 149 { … … 148 176 { 149 177 /* delete image on error */ 150 VDIDeleteImage(psz Filename);178 VDIDeleteImage(pszUtf8Filename); 151 179 } 152 180 PrintDone(rc); … … 179 207 "progress: 0%%", 180 208 pszFilename); 209 210 /* translate argv[] to UTF8 */ 211 char *pszUtf8Filename; 212 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 213 if (VBOX_FAILURE(rc)) 214 return rc; 215 181 216 unsigned uPercent = 0; 182 int rc = VDIConvertImage(pszFilename, ProcessCallback, &uPercent);217 rc = VDIConvertImage(pszUtf8Filename, ProcessCallback, &uPercent); 183 218 RTPrintf("\n"); 184 219 return PrintDone(rc); … … 189 224 RTPrintf("Dumping VDI image file=\"%s\" into the log file...\n", pszFilename); 190 225 PVDIDISK pVdi = VDIDiskCreate(); 191 int rc = VDIDiskOpenImage(pVdi, pszFilename, VDI_OPEN_FLAGS_READONLY); 226 227 /* translate argv[] to UTF8 */ 228 char *pszUtf8Filename; 229 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 230 if (VBOX_FAILURE(rc)) 231 return rc; 232 rc = VDIDiskOpenImage(pVdi, pszUtf8Filename, VDI_OPEN_FLAGS_READONLY); 192 233 if (VBOX_SUCCESS(rc)) 193 234 { … … 202 243 RTPrintf("Resetting geometry info of VDI image file=\"%s\"\n", pszFilename); 203 244 PVDIDISK pVdi = VDIDiskCreate(); 204 int rc = VDIDiskOpenImage(pVdi, pszFilename, VDI_OPEN_FLAGS_NORMAL); 245 246 /* translate argv[] to UTF8 */ 247 char *pszUtf8Filename; 248 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 249 if (VBOX_FAILURE(rc)) 250 return rc; 251 252 rc = VDIDiskOpenImage(pVdi, pszUtf8Filename, VDI_OPEN_FLAGS_NORMAL); 205 253 if (VBOX_SUCCESS(rc)) 206 254 { … … 218 266 "progress: 0%%", 219 267 pszSrcFile, pszDstFile); 268 269 /* translate argv[] to UTF8 */ 270 char *pszUtf8SrcFile, *pszUtf8DstFile; 271 int rc = FilenameToUtf8(&pszUtf8SrcFile, pszSrcFile); 272 if (VBOX_FAILURE(rc)) 273 return rc; 274 rc = FilenameToUtf8(&pszUtf8DstFile, pszDstFile); 275 if (VBOX_FAILURE(rc)) 276 return rc; 277 220 278 unsigned uPrecent = 0; 221 int rc = VDICopyImage(pszDstFile, pszSrcFile, NULL, ProcessCallback, &uPrecent);279 rc = VDICopyImage(pszUtf8DstFile, pszUtf8SrcFile, NULL, ProcessCallback, &uPrecent); 222 280 RTPrintf("\n"); 223 281 return PrintDone(rc); … … 229 287 pszSrcFile, pszDstFile); 230 288 PVDIDISK pVdi = VDIDiskCreate(); 231 int rc = VDIDiskOpenImage(pVdi, pszSrcFile, VDI_OPEN_FLAGS_NORMAL); 289 290 /* translate argv[] to UTF8 */ 291 char *pszUtf8SrcFile, *pszUtf8DstFile; 292 int rc = FilenameToUtf8(&pszUtf8SrcFile, pszSrcFile); 293 if (VBOX_FAILURE(rc)) 294 return rc; 295 rc = FilenameToUtf8(&pszUtf8DstFile, pszDstFile); 296 if (VBOX_FAILURE(rc)) 297 return rc; 298 299 rc = VDIDiskOpenImage(pVdi, pszUtf8SrcFile, VDI_OPEN_FLAGS_NORMAL); 232 300 if (VBOX_SUCCESS(rc)) 233 301 { 234 302 RTFILE FileDst; 235 rc = RTFileOpen(&FileDst, psz DstFile, RTFILE_O_CREATE | RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE);303 rc = RTFileOpen(&FileDst, pszUtf8DstFile, RTFILE_O_CREATE | RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE); 236 304 if (VBOX_SUCCESS(rc)) 237 305 { … … 266 334 "progress: 0%%", 267 335 pszFilename); 336 337 /* translate argv[] to UTF8 */ 338 char *pszUtf8Filename; 339 int rc = FilenameToUtf8(&pszUtf8Filename, pszFilename); 340 if (VBOX_FAILURE(rc)) 341 return rc; 342 268 343 unsigned uPrecent; 269 int rc = VDIShrinkImage(pszFilename, ProcessCallback, &uPrecent);344 rc = VDIShrinkImage(pszUtf8Filename, ProcessCallback, &uPrecent); 270 345 RTPrintf("\n"); 271 346 return PrintDone(rc); … … 278 353 279 354 RTR3Init(); 280 RTPrintf("vditool Copyright (c) 2004-200 5innotek GmbH.\n\n");355 RTPrintf("vditool Copyright (c) 2004-2007 innotek GmbH.\n\n"); 281 356 282 357 /*
Note:
See TracChangeset
for help on using the changeset viewer.