Files
envi-code/SourceCode/Code2026/tg_shs/shs_geLib/TGGiCompressStorage.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

128 lines
2.8 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TGGiCompressStorage 类
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TGGiCompressStorage 定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TGGiCompressStorage.h"
#include "TAString.h"
#include "TchGlobalDef.h"
#include "TchGlobalFunc.h"
TGGiCompressStorage::TGGiCompressStorage(const TCHAR *fname, const TCHAR *ext, const TCHAR *title,int opMode)
: TGGiSlibStorage(fname, 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 << 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
{
TGGetVar(_T("DWGPREFIX"), sDwgPrefix);
}
TCString sFile1, sFile2;
sFile1 << sDwgPrefix << fname << 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 << 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("");
TGGetVar(_T("DWGPREFIX"), sDwgPrefix);
TCString sFile1, sFile2;
sFile1 << drive << dir << file << extNormal;
sFile2 << sDwgPrefix << file << LZW_EXT;
if (m_pStreamFile->Pack(sFile1, sFile2) == RTNORM)
{
int nRet=TGGiSlibStorage::Append(sFile2, szItem);
remove(_AS(sFile2));
return nRet;
}
return 0;
}