| Hello, I am trying to use httrack with an shadowed volume, created by an
service like the shadow copy of windows on Win xp.
In C# I can use the following code to copy a file from the real volume to the
snapshot volume:
using System.Runtime.InteropServices;
using System;
using Microsoft.Win32.SafeHandles;
using System.IO;
namespace Shadow1{
public class Edit{
public const short FILE_ATTRIBUTE_NORMAL = 0x80;
public const short INVALID_HANDLE_VALUE = -1;
public const uint GENERIC_READ = 0x80000000;
public const uint GENERIC_WRITE = 0x40000000;
public const uint CREATE_NEW = 1;
public const uint CREATE_ALWAYS = 2;
public const uint OPEN_EXISTING = 3;
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess,
uint dwShareMode, IntPtr
lpSecurityAttributes, uint dwCreationDisposition,
uint dwFlagsAndAttributes, IntPtr
hTemplateFile);
[System.Runtime.InteropServices.DllImport("kernel32", SetLastError = true)]
static extern bool CloseHandle
(
IntPtr hObject // handle to object
);
public IntPtr SnapShotCreateFile(string RealVolumeFilePath){
RealVolumeFilePath = "\\\\?\\SnapShot0\\" +
RealVolumeFilePath.Substring(3);
return CreateFile(RealVolumeFilePath, GENERIC_WRITE, 0, IntPtr.Zero,
CREATE_NEW, 0, IntPtr.Zero);
}
public void copyToShadow(string filePath){
//string path = "meuTeste.txt";
IntPtr SnapShotPTR = SnapShotCreateFile(filePath);
//MessageBox.Show(ptr.ToString());
SafeFileHandle safeSnapShotPTR = new SafeFileHandle(SnapShotPTR,true);
Stream destStream = new FileStream(safeSnapShotPTR,FileAccess.Write);
Stream originStream = new
FileStream(filePath,FileMode.Open,FileAccess.Read);
byte[] buffer = new byte[4096];
//copying the original file to the snapshot
for (;;)
{
//reading original
int bytesRead = originStream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
{
break;
}
//writing in the snapshot
destStream.Write(buffer,0,buffer.Length);
}
//closing the streams
destStream.Close();
originStream.Close();
//destroying th file handle
safeSnapShotPTR.Close();
CloseHandle(SnapShotPTR);
}
}
}
//============================================
//===========================================
The question is, when I pass the path of my Snapshot volume to winhttrack an
error occurs: "Directory not exists" or "Wrong argument"
The arguments is:
httrack <http://www.site.com> -O "\\?\SnapShot0\MyWebSite"
I think I can use an httrack module using the function
"filesave2" and use "CreateFileA" to each site file to my snapshot volume. Is
this possible, and... I can use dev-c++ to compile the module? | |