|
// *********************************************************
// 長い名前から短い名前を取得する
// " で囲まれていたら事前に取り去る
// 引数のデータはコピーして使用するので影響を受けない
// 戻り値 : 成功 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;
}
| |