|
事前定義
|
#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);
| |
|
|
|
|
// *********************************************************
// リストボックスに列挙
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnlha::EnumListbox( HWND hList, int nIndex, LPTSTR szWildName )
{
if ( LboxUnlha::lib == NULL ) {
return false;
}
if ( LboxUnlha::hArc == NULL ) {
return false;
}
INDIVIDUALINFO ivinfo;
int ret;
ret = UnlhaFindFirst(
LboxUnlha::hArc,
szWildName,
&ivinfo
);
char *szBuffer = new char[1024];
ZeroMemory( szBuffer, 1024 );
FILETIME ft;
SYSTEMTIME st;
while( ret == 0 ) {
lstrcpy( szBuffer, ivinfo.szFileName );
wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
ivinfo.dwOriginalSize );
wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
ivinfo.dwCompressedSize );
wsprintf( szBuffer+lstrlen(szBuffer), "\t%d",
ivinfo.wRatio );
DosDateTimeToFileTime( ivinfo.wDate, ivinfo.wTime, &ft );
FileTimeToSystemTime( &ft, &st );
wsprintf(
szBuffer+lstrlen(szBuffer),
"\t%04d/%02d/%02d %02d:%02d:%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond
);
wsprintf( szBuffer+lstrlen(szBuffer), "\t%s",
ivinfo.szAttribute );
wsprintf( szBuffer+lstrlen(szBuffer), "\t%s",
ivinfo.szMode );
LboxListInsert( hList, nIndex, szBuffer );
ret = UnlhaFindNext(
LboxUnlha::hArc,
&ivinfo
);
nIndex++;
}
delete [] szBuffer;
return true;
}
| |
|
|
|
|
// *********************************************************
// リストビューに列挙
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxUnlha::Enum( LboxListview *Lview, LPTSTR szWildName )
{
if ( LboxUnlha::lib == NULL ) {
return false;
}
if ( LboxUnlha::hArc == NULL ) {
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 = UnlhaFindFirst(
LboxUnlha::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 = UnlhaFindNext(
LboxUnlha::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 LboxUnlha::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 = ( "U -r2x " );
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 LboxUnlha::Unlha(
&(this->Command)
);
}
// *********************************************************
// 複数のファイルを書庫登録または更新
// 戻り値 : 0 正常終了, それ以外はエラー
// LPath は、フルパスファイルリスト ( タブ区切り )
// *********************************************************
int LboxUnlha::Freeze( LboxString *LPath )
{
return LboxUnlha::Freeze(
LPath->szLboxString
);
}
int LboxUnlha::Freeze( LPTSTR lpPath )
{
LboxToken LToken;
LboxString LString;
LToken.CreateToken( lpPath, "\t" );
int i;
this->Command.operator = ( "U -r2x " );
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 LboxUnlha::Unlha(
&(this->Command)
);
}
| |
|
|
|