|
事前定義
|
#define FNAME_MAX32 512
typedef HGLOBAL HARC;
typedef struct {
DWORD dwOriginalSize;
DWORD dwCompressedSize;
DWORD dwCRC;
UINT uFlag;
UINT uOSType;
WORD wRatio;
WORD wDate;
WORD wTime;
char szFileName[FNAME_MAX32 + 1];
char dummy1[3];
char szAttribute[8];
char szMode[8];
} INDIVIDUALINFO, *LPINDIVIDUALINFO;
typedef HARC (WINAPI *LPFUNC_OPEN_ARC)
(const HWND _hwnd, LPCSTR _szFileName,const DWORD _dwMode);
typedef int (WINAPI *LPFUNC_CLOSE_ARC)
(HARC _harc);
typedef int (WINAPI *LPFUNC_FIND_FIRST)
(HARC _harc, LPCSTR _szWildName,INDIVIDUALINFO FAR *lpSubInfo);
typedef int (WINAPI *LPFUNC_FIND_NEXT)
(HARC _harc,INDIVIDUALINFO FAR *_lpSubInfo);
typedef int (WINAPI *LPFUNC_UNLHA)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
typedef int (WINAPI *LPFUNC_UNZIP)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
typedef int (WINAPI *LPFUNC_ZIP)
(const HWND _hwnd,LPCSTR _szCmdLine,LPSTR _szOutput,const DWORD _dwSize);
| |
|
クラス定義
|
class LboxUnzip
{
public:
int MeltAll( int nType );
BOOL CheckDll( void );
int MeltPathRow( LboxListview *Lview, int nTargetRow, LboxString *LDir );
int MeltPathRow( LboxListview *Lview, int nTargetRow, LPTSTR lpDir );
int MeltDirectRow( LboxListview *Lview, int nTargetRow, LboxString *LDir );
int MeltDirectRow( LboxListview *Lview, int nTargetRow, LPTSTR lpDir );
int MeltDirect( LboxListview *Lview, LboxString *LDir );
int MeltDirect( LboxListview *Lview, LPTSTR lpDir );
int MeltPath( LboxListview *Lview, LboxString *LDir );
int MeltPath( LboxListview *Lview, LPTSTR lpDir );
int Zip( LboxString *LCmdLine );
int Zip(LPTSTR szCmdLine,LPTSTR szOutput,const DWORD dwSize);
int Melt( LboxListview *Lview, LboxString *LDir );
int Melt( LboxListview *Lview, LPTSTR lpDir );
int Delete( LboxListview *Lview );
int Freeze( HDROP hDrop );
int Freeze( LboxString *LPath );
int Freeze( LPTSTR lpPath );
int Unzip( LboxString *LCmdLine );
int Unzip(LPTSTR szCmdLine,LPTSTR szOutput,const DWORD dwSize);
BOOL Enum( LboxListview *Lview, LPTSTR szWildName );
BOOL Enum( LboxListview *Lview, LboxString *LWildName );
void CloseArchive( void );
BOOL OpenArchive( void );
BOOL OpenArchive( LboxString *LFileName );
BOOL OpenArchive( LPTSTR szFileName );
void Initialize2( void );
void Initialize( void );
LboxUnzip( HWND hOwner );
LboxUnzip();
virtual ~LboxUnzip();
LPFUNC_UNZIP UnzipAction;
LPFUNC_ZIP ZipAction;
LPFUNC_FIND_NEXT UnzipFindNext;
LPFUNC_FIND_FIRST UnzipFindFirst;
LPFUNC_CLOSE_ARC UnzipCloseArchive;
LPFUNC_OPEN_ARC UnzipOpenArchive;
HINSTANCE lib;
HINSTANCE lib2;
HARC hArc;
HWND hOwner;
DWORD Mode;
LboxString TargetPath;
LboxString Output;
LboxString Command;
LboxString ErrMessage;
};
| |
|
|
|
|
// *********************************************************
// リストビューに列挙
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnzip::Enum( LboxListview *Lview, LboxString *LWildName )
{
return LboxUnzip::Enum(
Lview,
LWildName->szLboxString
);
}
BOOL LboxUnzip::Enum( LboxListview *Lview, LPTSTR szWildName )
{
if ( LboxUnzip::lib == NULL ) {
this->ErrMessage.operator = (
"Unzip32.dll がインストールされていません"
);
return false;
}
if ( LboxUnzip::hArc == NULL ) {
this->ErrMessage.operator = (
"書庫が開かれていません"
);
return false;
}
Lview->Initialize();
Lview->AddColumn( LVCFMT_LEFT, 100, "" );
Lview->AddColumn( LVCFMT_LEFT, 100, "ファイル名" );
Lview->AddColumn( LVCFMT_LEFT, 100, "サイズ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "圧縮サイズ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "圧縮率" );
Lview->AddColumn( LVCFMT_LEFT, 100, "タイムスタンプ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "属性" );
Lview->AddColumn( LVCFMT_LEFT, 100, "モード" );
Lview->AddColumn( LVCFMT_LEFT, 100, "ディレクトリ" );
Lview->AddColumn( LVCFMT_LEFT, 100, "フルパス" );
Lview->AddColumn( LVCFMT_LEFT, 100, "ソート" );
INDIVIDUALINFO ivinfo;
int ret;
ret = UnzipFindFirst(
LboxUnzip::hArc,
szWildName,
&ivinfo
);
FILETIME ft;
SYSTEMTIME st;
int nCount;
LboxString LString;
while( ret == 0 ) {
Lview->AddRow();
LString.operator = (ivinfo.szFileName );
LString.Replace( "/", "\\" );
LString.StripPath( );
LString.Replace( "\\", "/" );
Lview->SetColumnText( 1, &LString );
Lview->SetColumnPrintf( 2, "%d", ivinfo.dwOriginalSize );
Lview->SetColumnPrintf( 3, "%d", ivinfo.dwCompressedSize );
LString.Printf( "%d", ivinfo.wRatio );
if ( LString.Length() > 0 ) {
LString.Insert( ".", LString.Length()-1 );
Lview->SetColumnText( 4, &LString );
}
DosDateTimeToFileTime( ivinfo.wDate, ivinfo.wTime, &ft );
FileTimeToSystemTime( &ft, &st );
Lview->SetColumnPrintf( 5,
"%04d/%02d/%02d %02d:%02d:%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond
);
Lview->SetColumnText( 6, ivinfo.szAttribute );
Lview->SetColumnText( 7, ivinfo.szMode );
LString.operator = (ivinfo.szFileName );
LString.Replace( "/", "\\" );
LString.RemoveFileSpec( );
LString.Replace( "\\", "/" );
Lview->SetColumnText( 8, &LString );
if ( LString.operator == ( "" ) ) {
LString.operator = (" ");
LString.operator += (ivinfo.szFileName);
Lview->SetColumnText( 10, &(LString) );
}
else {
Lview->SetColumnText( 10, ivinfo.szFileName );
}
Lview->SetColumnText( 9, ivinfo.szFileName );
ret = UnzipFindNext(
LboxUnzip::hArc,
&ivinfo
);
}
Lview->Sort( 10, 0 );
nCount = -1;
while( Lview->FindNextRow( &nCount ) ) {
Lview->SetColumnPrintf( 0, "%d", nCount+1 );
}
Lview->Fit();
Lview->SetColumnWidth( 10, 0 );
return true;
}
| |
|
|
|
|
// *********************************************************
// ドラッグドロップされたファイルを書庫へ登録または更新
// 戻り値 : 0 正常終了, それ以外はエラー
// *********************************************************
int LboxUnzip::Freeze( HDROP hDrop )
{
int i,nFiles;
LboxString LFile;
LFile.Resize( MAX_PATH );
nFiles = DragQueryFile(
hDrop,
0xFFFFFFFF,
LFile.szLboxString,
LFile.nLboxString
);
this->Command.SetChar( 0, 0 );
this->Command.operator = ( "-rD " );
LFile.operator = (&(this->TargetPath));
LFile.Enclose('"');
this->Command.operator += ( &(LFile) );
this->Command.operator += ( " " );
for( i = 0; i < nFiles; i++ ) {
if ( i != 0 ) {
this->Command.operator += ( " " );
}
DragQueryFile(
hDrop,
i,
LFile.szLboxString,
LFile.nLboxString
);
LFile.RemoveFileSpec();
LFile.AddBackslash();
LFile.Enclose( '"' );
this->Command.operator += ( &LFile );
this->Command.operator += ( " " );
DragQueryFile(
hDrop,
i,
LFile.szLboxString,
LFile.nLboxString
);
LFile.StripPath();
LFile.Enclose( '"' );
this->Command.operator += ( &LFile );
}
return LboxUnzip::Zip(
&(this->Command)
);
}
// *********************************************************
// 複数のファイルを書庫登録または更新
// 戻り値 : 0 正常終了, それ以外はエラー
// LPath は、フルパスファイルリスト ( タブ区切り )
// *********************************************************
int LboxUnzip::Freeze( LboxString *LPath )
{
return LboxUnzip::Freeze(
LPath->szLboxString
);
}
int LboxUnzip::Freeze( LPTSTR lpPath )
{
LboxToken LToken;
LboxString LString;
LToken.CreateToken( lpPath, "\t" );
int i;
this->Command.operator = ( "-rD " );
LString.operator = (&(this->TargetPath));
LString.Enclose('"');
this->Command.operator += ( &(LString) );
this->Command.operator += ( " " );
for( i = 0; i < LToken.nCount; i++ ) {
if ( i != 0 ) {
this->Command.operator += ( " " );
}
LString.operator = (LToken.Token[i]);
LString.RemoveFileSpec();
LString.AddBackslash();
LString.Enclose('"');
this->Command.operator += (&LString);
this->Command.operator += ( " " );
LString.operator = (LToken.Token[i]);
LString.StripPath();
LString.Enclose('"');
this->Command.operator += (&LString);
}
return LboxUnzip::Zip(
&(this->Command)
);
}
| |
|
|
|