130 lines
2.7 KiB
C++
130 lines
2.7 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, SH Software Co. Ltd.
|
|
// = FileName : XCompressLib 类
|
|
// = Version : ver2.0
|
|
// = Author : zjq
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: XCompressLib 定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "XCompressLib.h"
|
|
#include "AString.h"
|
|
#include "XGlobalDef.h"
|
|
#include "XGlobalFunc.h"
|
|
|
|
XCompressLib::XCompressLib(const TCHAR *fname, const TCHAR *ext, const TCHAR *title,int opMode)
|
|
: XASLibMan(fname, LZW_EXT, title, opMode), extNormal(ext)
|
|
{
|
|
|
|
}
|
|
|
|
XCompressLib::~XCompressLib()
|
|
{
|
|
|
|
}
|
|
|
|
int XCompressLib::Copy(int n, const TCHAR *destFile)
|
|
{
|
|
XString sDest = destFile;
|
|
TCHAR *p = tstrchr_new((TCHAR *)sDest, '.');
|
|
if (p)
|
|
{
|
|
*p = 0;
|
|
}
|
|
|
|
XString sFile1, sFile2;
|
|
sFile1 << sDest << LZW_EXT;
|
|
sFile2 << sDest << extNormal;
|
|
|
|
if (XASLibMan::Copy(n, sFile1))
|
|
{
|
|
m_pStreamFile->UnPack(sFile1, sFile2);
|
|
_tremove(sFile1);
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int XCompressLib::QuickCopy(const TCHAR *destFile)
|
|
{
|
|
int nRet;
|
|
nRet = XASLibMan::QuickCopy(destFile);
|
|
if (nRet == 1)
|
|
{
|
|
TCHAR drive[_MAX_DRIVE] = _T(""), dir[_MAX_DIR] = _T(""), fname[_MAX_FNAME] = _T(""), ext[_MAX_EXT] = _T("");
|
|
_tsplitpath(destFile, drive, dir, fname, ext);
|
|
|
|
XString sDwgPrefix(256);
|
|
if (drive[0] && dir[0])
|
|
{
|
|
sDwgPrefix << drive << dir;
|
|
}
|
|
else
|
|
{
|
|
xg_getvar(_T("DWGPREFIX"), sDwgPrefix);
|
|
}
|
|
|
|
XString sFile1, sFile2;
|
|
sFile1 << sDwgPrefix << fname << LZW_EXT;
|
|
sFile2 << sDwgPrefix << fname << extNormal;
|
|
|
|
m_pStreamFile->UnPack(sFile1, sFile2);
|
|
_tremove(sFile1);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return nRet;
|
|
}
|
|
|
|
//移第 n 个记录到磁盘文件
|
|
int XCompressLib::Move(int n, const TCHAR *destFile)
|
|
{
|
|
XString sDest = destFile;
|
|
TCHAR *p = tstrchr_new((TCHAR *)sDest, '.');
|
|
if (p)
|
|
{
|
|
*p = 0;
|
|
}
|
|
|
|
XString sFile1, sFile2;
|
|
sFile1 << sDest << LZW_EXT;
|
|
sFile2 << sDest << extNormal;
|
|
|
|
if (XASLibMan::Move(n, sFile1))
|
|
{
|
|
m_pStreamFile->UnPack(sFile1, sFile2);
|
|
_tremove(sFile1);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int XCompressLib::Append(const TCHAR *srcFile, const TCHAR *szItem)
|
|
{
|
|
TCHAR drive[_MAX_DRIVE] = _T(""), dir[_MAX_DIR] = _T(""), file[_MAX_FNAME] = _T(""), ext[_MAX_EXT];
|
|
_tsplitpath(srcFile, drive, dir, file, ext);
|
|
|
|
TCHAR sDwgPrefix[80] = _T("");
|
|
xg_getvar(_T("DWGPREFIX"), sDwgPrefix);
|
|
|
|
XString sFile1, sFile2;
|
|
sFile1 << drive << dir << file << extNormal;
|
|
sFile2 << sDwgPrefix << file << LZW_EXT;
|
|
|
|
if (m_pStreamFile->Pack(sFile1, sFile2) == RTNORM)
|
|
{
|
|
int nRet=XASLibMan::Append(sFile2, szItem);
|
|
remove(_AS(sFile2));
|
|
|
|
return nRet;
|
|
}
|
|
|
|
return 0;
|
|
}
|