Makefile e.a. flink opgeschoond _CRT_SECURE_DEPRECATE verwijderd en aantal functies de _s variant gebruikt WTL van 9.0 naar 9.1 DWF Toolkit makefiles voor VS12.0 en vooral 14.0 ook committen svn path=/Slnkdwf/trunk/; revision=28366
191 lines
5.4 KiB
C++
191 lines
5.4 KiB
C++
// filesys.cpp : Defines the entry point for the DLL application.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "packerplug.h"
|
|
#define _detectstring "EXT=\"DWF\"|EXT=\"W2D\"|([0]=\"(\"&[1]=\"W\"&[2]=\"2\"&[3]=\"D\")"
|
|
|
|
const char *strX = "/\\|:?*<>\"";
|
|
|
|
tProcessDataProc ProcessDataProc = NULL;
|
|
typedef BOOL (* EPlot_Progress_Action) (void *param, double progress);
|
|
|
|
BOOL APIENTRY DllMain( HANDLE hModule,
|
|
DWORD ul_reason_for_call,
|
|
LPVOID lpReserved
|
|
)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
HANDLE __stdcall OpenArchive (tOpenArchiveData *ArchiveData)
|
|
{
|
|
try
|
|
{
|
|
COpenArchive *arch = new COpenArchive();
|
|
arch->m_FullName = ArchiveData->ArcName;
|
|
arch->m_iDWFFile.Open(arch->m_FullName);
|
|
arch->m_AtPage = -1;
|
|
arch->AtAscii = TRUE; // Eerstvolgende is binary
|
|
|
|
return (HANDLE)arch; // We hebben maar een globale en dus geen HANDLE nodig
|
|
}
|
|
catch (CString &ee)
|
|
{
|
|
::MessageBox(NULL, ee, "SLNKDWF", MB_ICONEXCLAMATION | MB_OK);
|
|
ArchiveData->OpenResult = E_UNKNOWN_FORMAT;
|
|
return (HANDLE)0;
|
|
}
|
|
}
|
|
int __stdcall ReadHeader (HANDLE hArcData, tHeaderData *HeaderData)
|
|
{
|
|
COpenArchive *arch = (COpenArchive*)hArcData;
|
|
ATLASSERT(arch);
|
|
try
|
|
{
|
|
CEPlotSectionsImpl *piEPlotSections;
|
|
piEPlotSections = arch->m_iDWFFile.get_EPlotSections();
|
|
|
|
HeaderData->PackSize = 0;
|
|
HeaderData->UnpSize = 0;
|
|
|
|
if (piEPlotSections->get_Count() == 0 && arch->m_AtPage==-1)
|
|
{
|
|
char drive[_MAX_DRIVE], dir[_MAX_DIR];
|
|
char fname[_MAX_FNAME], ext[_MAX_EXT];
|
|
_splitpath_s( arch->m_FullName, drive, dir, fname, ext );
|
|
|
|
CString s = CString(fname) + ".ascii" + ext;
|
|
// Wel een geldige filenaam van maken
|
|
for (size_t i = 0; i < strlen(strX); i++)
|
|
s.Replace(strX[i], '_');
|
|
|
|
CString sVer;
|
|
sVer.Format("DWF v%02d_%02d", arch->m_iDWFFile.m_tInfo.nVersion / 100,
|
|
arch->m_iDWFFile.m_tInfo.nVersion % 100);
|
|
|
|
strcpy_s(HeaderData->FileName, sVer + "\\" + s);
|
|
arch->m_AtPage ++; // We blijven AtAscii
|
|
return 0;
|
|
}
|
|
if (arch->AtAscii)
|
|
{
|
|
arch->m_AtPage ++;
|
|
arch->AtAscii = FALSE;
|
|
}
|
|
else
|
|
arch->AtAscii = TRUE;
|
|
|
|
if (arch->m_AtPage >= piEPlotSections->get_Count())
|
|
return E_END_ARCHIVE;
|
|
|
|
HeaderData->FileAttr = 0;//x10;
|
|
|
|
CEPlotSectionImpl *piEPlotSection;
|
|
|
|
piEPlotSection = piEPlotSections->get_Item(arch->m_AtPage);
|
|
CString s = piEPlotSection->get_Title();
|
|
// Wel een geldige filenaam van maken
|
|
for (size_t i = 0; i < strlen(strX); i++)
|
|
s.Replace(strX[i], '_');
|
|
s = s + "\\" + s + (arch->AtAscii?".ascii":"") + ".W2D";
|
|
strcpy_s(HeaderData->FileName, s);
|
|
|
|
piEPlotSection->Open(false);
|
|
const DWFProperty *dp; // = piEPlotSection->findProperty(DWFXML::kzAttribute_ModificationTime);
|
|
dp = piEPlotSection->findProperty(L"Creation Time", L""); // ac_b7_0.dwf
|
|
if (dp==NULL)
|
|
dp = piEPlotSection->findProperty(L"creationTime", L""); // "1 - IRD Addition.dwf"
|
|
if (dp)
|
|
{
|
|
CString modTime = (const wchar_t*)dp->value();// "2006-05-04T19:31:38.000+01:00"
|
|
int year,month,day;
|
|
int hour,minute,second;
|
|
sscanf_s(modTime,"%4d-%2d-%2dT%2d:%2d:%2d.", &year,&month,&day,&hour,&minute,&second);
|
|
HeaderData->FileTime = (year - 1980) << 25 | month << 21 | day << 16 | hour << 11 | minute << 5 | second/2;
|
|
// Merk op dat de ASCII afmeting niet van tevoren bekend is
|
|
HeaderData->UnpSize = HeaderData->PackSize = (int)piEPlotSection->size();
|
|
}
|
|
piEPlotSection->Close();
|
|
}
|
|
catch (CString &ee)
|
|
{
|
|
::MessageBox(NULL, ee, "SLNKDWF", MB_ICONEXCLAMATION | MB_OK);
|
|
return E_BAD_DATA;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
BOOL my_progress_action(void *param, double progress)
|
|
{
|
|
return ProcessDataProc("test", - (int)(progress * 100));
|
|
}
|
|
int __stdcall ProcessFile (HANDLE hArcData, int Operation, char *DestPath, char *DestName)
|
|
{
|
|
COpenArchive *arch = (COpenArchive*)hArcData;
|
|
switch (Operation)
|
|
{
|
|
case PK_SKIP:
|
|
break; /* Skip this file */
|
|
case PK_TEST:
|
|
break; /* Test file integrity */
|
|
case PK_EXTRACT: /* Extract to disk */
|
|
{
|
|
if (ProcessDataProc)
|
|
ProcessDataProc(NULL, 0);
|
|
try
|
|
{
|
|
CEPlotSectionsImpl *piEPlotSections;
|
|
piEPlotSections = arch->m_iDWFFile.get_EPlotSections();
|
|
if (piEPlotSections->get_Count()==0) // Moet wel oldstyle zijn?
|
|
{
|
|
CEPlotSectionImpl::SaveAsAscii(arch->m_FullName, DestName);
|
|
}
|
|
else
|
|
{
|
|
CEPlotSectionImpl *piEPlotSection;
|
|
piEPlotSection = piEPlotSections->get_Item(arch->m_AtPage);
|
|
|
|
ATLASSERT(arch->m_AtPage < piEPlotSections->get_Count());
|
|
|
|
if (arch->AtAscii)
|
|
piEPlotSection->SaveAsAscii(DestName, my_progress_action);
|
|
else
|
|
{
|
|
piEPlotSection->SaveAs(DestName);
|
|
}
|
|
}
|
|
}
|
|
catch (CString &ee)
|
|
{
|
|
::MessageBox(NULL, ee, "SLNKDWF", MB_ICONEXCLAMATION | MB_OK);
|
|
return E_BAD_DATA;
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
int __stdcall CloseArchive (HANDLE hArcData)
|
|
{
|
|
COpenArchive *arch = (COpenArchive*)hArcData;
|
|
ATLASSERT(arch);
|
|
delete arch;
|
|
return 0;
|
|
}
|
|
|
|
void __stdcall SetChangeVolProc (HANDLE hArcData, tChangeVolProc pChangeVolProc1)
|
|
{
|
|
}
|
|
|
|
void __stdcall SetProcessDataProc (HANDLE hArcData, tProcessDataProc pProcessDataProc)
|
|
{
|
|
ProcessDataProc = pProcessDataProc;
|
|
};
|
|
|
|
int __stdcall GetPackerCaps()
|
|
{
|
|
return PK_CAPS_MULTIPLE | /* Archive can contain multiple files */
|
|
// PK_CAPS_SEARCHTEXT | /* Allow searching for text in archives */
|
|
PK_CAPS_HIDE; /* open with Ctrl+PgDn, not Enter */
|
|
}; |