summaryrefslogtreecommitdiff
path: root/diskio-windows.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-02-11 22:22:22 -0500
committersrs5694 <srs5694@users.sourceforge.net>2010-02-11 22:22:22 -0500
commitcb76c673eeb84344887715d36d44b799042be5a5 (patch)
treec727bc4a638968b1be3812b567c34bd4c4f76132 /diskio-windows.cc
parent6699b01eda84d24bfaf80ad725304fef2b0e1b2a (diff)
downloadsgdisk-cb76c673eeb84344887715d36d44b799042be5a5.tar.gz
A few minor bug fixes; backup function now accepts dd output of MBR,
main header, and main partition table, as well as gdisk-generated backups.
Diffstat (limited to 'diskio-windows.cc')
-rw-r--r--diskio-windows.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/diskio-windows.cc b/diskio-windows.cc
index e3547c6..d5cd84b 100644
--- a/diskio-windows.cc
+++ b/diskio-windows.cc
@@ -19,7 +19,7 @@
#include <winioctl.h>
#define fstat64 fstat
#define stat64 stat
-#define S_IRGRP 0
+//#define S_IRGRP 0
#define S_IROTH 0
#include <stdio.h>
#include <string>
@@ -64,7 +64,9 @@ int DiskIO::OpenForRead(void) {
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (fd == INVALID_HANDLE_VALUE) {
CloseHandle(fd);
- cerr << "Problem opening " << realFilename << " for reading!\n";
+ cerr << "Problem opening ";
+ cerr << realFilename;
+ cerr << " for reading!\n";
realFilename = "";
userFilename = "";
isOpen = 0;
@@ -220,11 +222,12 @@ int DiskIO::Read(void* buffer, int numBytes) {
blockSize = GetBlockSize();
if (numBytes <= blockSize) {
numBlocks = 1;
- tempSpace = (char*) malloc(blockSize);
+ tempSpace = new char [blockSize];
} else {
numBlocks = numBytes / blockSize;
- if ((numBytes % blockSize) != 0) numBlocks++;
- tempSpace = (char*) malloc(numBlocks * blockSize);
+ if ((numBytes % blockSize) != 0)
+ numBlocks++;
+ tempSpace = new char [numBlocks * blockSize];
} // if/else
// Read the data into temporary space, then copy it to buffer
@@ -237,7 +240,7 @@ int DiskIO::Read(void* buffer, int numBytes) {
if (((numBlocks * blockSize) != numBytes) && (retval > 0))
retval = numBytes;
- free(tempSpace);
+ delete[] tempSpace;
} // if (isOpen)
return retval;
} // DiskIO::Read()
@@ -261,11 +264,11 @@ int DiskIO::Write(void* buffer, int numBytes) {
blockSize = GetBlockSize();
if (numBytes <= blockSize) {
numBlocks = 1;
- tempSpace = (char*) malloc(blockSize);
+ tempSpace = new char [blockSize];
} else {
numBlocks = numBytes / blockSize;
if ((numBytes % blockSize) != 0) numBlocks++;
- tempSpace = (char*) malloc(numBlocks * blockSize);
+ tempSpace = new char [numBlocks * blockSize];
} // if/else
// Copy the data to my own buffer, then write it
@@ -282,7 +285,7 @@ int DiskIO::Write(void* buffer, int numBytes) {
if (((numBlocks * blockSize) != numBytes) && (retval > 0))
retval = numBytes;
- free(tempSpace);
+ delete[] tempSpace;
} // if (isOpen)
return retval;
} // DiskIO:Write()