#include "StdAfx.h" #include "globalFunc.h" #include "TGGiCompressStorage.h" #include "AString.h" TGGiCompressStorage::TGGiCompressStorage(const TCHAR *fname, const TCHAR *ext, const TCHAR *title,int opMode) : TGGiSlibStorage(fname, g_Option::instance().LZW_EXT, title, opMode), extNormal(ext) { } TGGiCompressStorage::~TGGiCompressStorage() { } int TGGiCompressStorage::Copy(int n, const TCHAR *destFile) { TCString sDest = destFile; TCHAR *p = tstrchr_new((TCHAR *)sDest, '.'); if (p) { *p = 0; } TCString sFile1, sFile2; sFile1 << sDest << g_Option::instance().LZW_EXT; sFile2 << sDest << extNormal; if (TGGiSlibStorage::Copy(n, sFile1)) { m_pStreamFile->UnPack(sFile1, sFile2); _tremove(sFile1); return 1; } return 0; } int TGGiCompressStorage::QuickCopy(const TCHAR *destFile) { int nRet; nRet = TGGiSlibStorage::QuickCopy(destFile); if (nRet == 1) { char drive[_MAX_DRIVE] = "", dir[_MAX_DIR] = "", fname[_MAX_FNAME] = "", ext[_MAX_EXT] = ""; _splitpath(_AS(destFile), drive, dir, fname, ext); TCString sDwgPrefix(256); if (drive[0] && dir[0]) { sDwgPrefix << drive << dir; } else { GlobalFunc::TGGetVar(_T("DWGPREFIX"), sDwgPrefix); } TCString sFile1, sFile2; sFile1 << sDwgPrefix << fname << g_Option::instance().LZW_EXT; sFile2 << sDwgPrefix << fname << extNormal; m_pStreamFile->UnPack(sFile1, sFile2); _tremove(sFile1); return 1; } return nRet; } //移第 n 个记录到磁盘文件 int TGGiCompressStorage::Move(int n, const TCHAR *destFile) { TCString sDest = destFile; TCHAR *p = tstrchr_new((TCHAR *)sDest, '.'); if (p) { *p = 0; } TCString sFile1, sFile2; sFile1 << sDest << g_Option::instance().LZW_EXT; sFile2 << sDest << extNormal; if (TGGiSlibStorage::Move(n, sFile1)) { m_pStreamFile->UnPack(sFile1, sFile2); _tremove(sFile1); return 1; } return 0; } int TGGiCompressStorage::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(""); GlobalFunc::TGGetVar(_T("DWGPREFIX"), sDwgPrefix); TCString sFile1, sFile2; sFile1 << drive << dir << file << extNormal; sFile2 << sDwgPrefix << file << g_Option::instance().LZW_EXT; if (m_pStreamFile->Pack(sFile1, sFile2) == RTNORM) { int nRet=TGGiSlibStorage::Append(sFile2, szItem); remove(_AS(sFile2)); return nRet; } return 0; }