|
|
// *********************************************************
// ファイルの更新日付と時刻を文字列で取得( 9999/99/99 99:99:99 )
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxFileSystem::DateUpdate(
LboxString *LstrFileName, LboxString *LString )
{
if ( LString->nLboxString < 32 ) {
LString->Resize( 32 );
}
return LboxFileSystem::DateUpdate(
LstrFileName->szLboxString,
LString->szLboxString
);
}
BOOL LboxFileSystem::DateUpdate( LPCTSTR lpFileName, LPTSTR lpDateTime )
{
HANDLE ret;
WIN32_FIND_DATA wfd;
ret = FindFirstFile(
lpFileName,
&wfd
);
if ( ret == INVALID_HANDLE_VALUE ) {
return false;
}
FindClose( ret );
FILETIME ft;
SYSTEMTIME st;
FileTimeToLocalFileTime( &(wfd.ftLastWriteTime), &ft );
FileTimeToSystemTime( &ft, &st );
wsprintf(
lpDateTime,
"%04d/%02d/%02d %02d:%02d:%02d",
st.wYear,
st.wMonth,
st.wDay,
st.wHour,
st.wMinute,
st.wSecond
);
return true;
}
| |
|
|
|
|
// *********************************************************
// エクスプローラのファイルコピー
// lpFiles に指定できるのは一つのファイルまたはディレクトリ
// lpNewFile に指定できるのは一つのファイルまたはディレクトリ
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxFileSystem::ShellCopy(
HWND hWnd, LboxString *LstrFiles, LboxString *LstrNew )
{
return LboxFileSystem::ShellCopy(
hWnd,
LstrFiles->szLboxString,
LstrNew->szLboxString
);
}
BOOL LboxFileSystem::ShellCopy( HWND hWnd, LPTSTR lpFiles, LPTSTR lpNew )
{
SHFILEOPSTRUCT sf;
lpFiles[lstrlen( lpFiles )+1] = 0x00;
ZeroMemory( &sf, sizeof( sf ) );
sf.hwnd = hWnd;
sf.wFunc = FO_COPY;
sf.pFrom = lpFiles;
sf.pTo = lpNew;
return (BOOL)!SHFileOperation( &sf );
}
// *********************************************************
// エクスプローラのファイルコピー
// lpNewFile に指定できるのは一つのディレクトリ
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxFileSystem::ShellCopy( HWND hWnd, HWND hList, LboxString *LstrDir )
{
return LboxFileSystem::ShellCopy(
hWnd,
hList,
LstrDir->szLboxString
);
}
BOOL LboxFileSystem::ShellCopy( HWND hWnd, HWND hList, LPTSTR lpDir )
{
LboxToken *Ltoken = new LboxToken( );
LboxListCreateToken( hList, Ltoken );
BOOL bRet;
SHFILEOPSTRUCT sf;
ZeroMemory( &sf, sizeof( sf ) );
sf.hwnd = hWnd;
sf.wFunc = FO_COPY;
sf.pFrom = Ltoken->pszLboxToken;
sf.pTo = lpDir;
bRet = (BOOL)!SHFileOperation( &sf );
delete Ltoken;
return bRet;
}
| |
|
|
|
|
// *********************************************************
// 長い名前から短い名前を取得する
// " で囲まれていたら事前に取り去る
// 引数のデータはコピーして使用するので影響を受けない
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxFileSystem::GetShortPathName(
LboxString *LstrLongPath, LboxString *LstrShortPath, int nSize )
{
LstrShortPath->Resize( MAX_PATH );
return LboxFileSystem::GetShortPathName(
LstrLongPath->szLboxString,
LstrShortPath->szLboxString,
LstrShortPath->nLboxString
);
}
BOOL LboxFileSystem::GetShortPathName(
LPTSTR lpLongPath, LPTSTR lpShortPath, int nSize )
{
BOOL bRet;
DWORD nRequiredBufferSize;
char *szPath = new char[lstrlen( lpLongPath ) + 10];
lstrcpy( szPath, lpLongPath );
LboxStringRemoveEnclose( szPath, '"' );
lpShortPath[0] = 0x00;
nRequiredBufferSize = ::GetShortPathName(
szPath,
lpShortPath,
(DWORD)nSize
);
if ( lpShortPath[0] == 0x00 ) {
bRet = false;
}
if ( nRequiredBufferSize > (DWORD)nSize ) {
bRet = false;
}
bRet = true;
delete [] szPath;
return bRet;
}
| |
|
|
|
|
// *********************************************************
// テンポラリファイル作成 ( .tmp )
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxFileSystem::CreateTempFile(
LboxString *LPath, LPTSTR lpPrefix, LboxString *LString
)
{
return LboxFileSystem::CreateTempFile(
LPath->szLboxString,
lpPrefix,
LString
);
}
BOOL LboxFileSystem::CreateTempFile(
LPTSTR lpCreatePath, LPTSTR lpPrefix, LboxString *LString
)
{
UINT nRet;
if ( LString->nLboxString < MAX_PATH ) {
LString->Resize( MAX_PATH );
}
nRet = GetTempFileName(
lpCreatePath,
lpPrefix,
0,
LString->szLboxString
);
if ( nRet == 0 ) {
return false;
}
return true;
}
| |
|
|
|