本文整理汇总了C++中CLibraryFile::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CLibraryFile::GetSize方法的具体用法?C++ CLibraryFile::GetSize怎么用?C++ CLibraryFile::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLibraryFile
的用法示例。
在下文中一共展示了CLibraryFile::GetSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnInitDialog
BOOL CFileGeneralPage::OnInitDialog()
{
CFilePropertiesPage::OnInitDialog();
{
CQuickLock oLock( Library.m_pSection );
CLibraryFile* pFile = GetFile();
if ( ! pFile ) return TRUE;
m_sPath = pFile->GetFolder();
m_sType = ShellIcons.GetTypeString( pFile->m_sName );
m_sSize.Format( _T("%s (%I64i)"), Settings.SmartVolume( pFile->GetSize() ), pFile->GetSize() );
m_sIndex.Format( _T("# %lu"), pFile->m_nIndex );
m_sSHA1 = pFile->m_oSHA1.toShortUrn();
m_sTiger = pFile->m_oTiger.toShortUrn();
m_sED2K = pFile->m_oED2K.toShortUrn();
m_sMD5 = pFile->m_oMD5.toShortUrn();
if ( m_sSHA1.IsEmpty() && m_sED2K.IsEmpty() && m_sTiger.IsEmpty() && m_sMD5.IsEmpty() )
LoadString( m_sSHA1, IDS_NO_URN_AVAILABLE );
SYSTEMTIME pTime;
FileTimeToSystemTime( &pFile->m_pTime, &pTime );
SystemTimeToTzSpecificLocalTime( NULL, &pTime, &pTime );
CString strDate, strTime;
GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE, &pTime, NULL, strDate.GetBuffer( 64 ), 64 );
GetTimeFormat( LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT, &pTime, NULL, strTime.GetBuffer( 64 ), 64 );
strDate.ReleaseBuffer();
strTime.ReleaseBuffer();
m_sModified = strDate + _T(", ") + strTime;
}
UpdateData( FALSE );
return TRUE;
}
示例2: Update
void CLibraryMetaPanel::Update()
{
CSingleLock pLock1( &Library.m_pSection, TRUE );
CSingleLock pLock2( &m_pSection, TRUE );
CLibraryListPtr pSel( GetViewSelection() );
m_nSelected = pSel ? static_cast< int >( pSel->GetCount() ) : 0;
// Show info for library files only
CLibraryFile* pFirst = NULL;
if ( m_nSelected )
{
const CLibraryListItem& pItem = pSel->GetHead();
if ( pItem.Type == CLibraryListItem::LibraryFile )
pFirst = Library.LookupFile( pItem );
if ( pFirst == NULL ) m_nSelected = 0;
}
m_nIcon32 = m_nIcon48 = -1;
if ( m_nSelected == 1 )
{
m_nIndex = pFirst->m_nIndex;
m_sName = pFirst->m_sName;
m_sPath = pFirst->GetPath();
m_sFolder = pFirst->GetFolder();
m_sSize = Settings.SmartVolume( pFirst->GetSize() );
m_sType = ShellIcons.GetTypeString( m_sName );
m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 );
m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 );
m_nRating = pFirst->m_nRating;
}
else if ( m_nSelected > 1 )
{
CString strFormat;
LoadString( strFormat, IDS_LIBPANEL_MULTIPLE_FILES );
m_sName.Format( strFormat, m_nSelected );
QWORD nSize = 0;
m_sFolder = pFirst->GetFolder();
m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 );
m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 );
m_nRating = 0;
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
CLibraryFile* pFile = Library.LookupFile( pSel->GetNext( pos ) );
if ( pFile == NULL ) continue;
nSize += pFile->GetSize() / 1024;
if ( pFile->IsAvailable() && pFile->GetFolder().CompareNoCase( m_sFolder ) )
{
LoadString( m_sFolder, IDS_LIBPANEL_MULTIPLE_FOLDERS );
}
int nIcon = ShellIcons.Get( pFile->GetPath(), 48 );
if ( nIcon != m_nIcon48 ) m_nIcon48 = -1;
nIcon = ShellIcons.Get( pFile->GetPath(), 32 );
if ( nIcon != m_nIcon32 ) m_nIcon32 = -1;
}
m_sSize = Settings.SmartVolume( nSize );
m_sPath.Empty();
m_sType.Empty();
}
m_pSchema = NULL;
if ( pSel )
{
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
const CLibraryListItem& pItem = pSel->GetNext( pos );
if ( pItem.Type != CLibraryListItem::LibraryFile ) continue;
CLibraryFile* pFile = Library.LookupFile( pItem );
if ( pFile == NULL ) continue;
m_pSchema = pFile->m_pSchema;
if ( m_pSchema ) break;
}
}
if ( m_pServiceData )
{
m_pMetadata->Setup( m_pServiceData );
}
else
{
m_pMetadata->Setup( m_pSchema );
if ( m_pSchema && pSel )
{
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
const CLibraryListItem& pItem = pSel->GetNext( pos );
if ( pItem.Type != CLibraryListItem::LibraryFile ) continue;
if ( CLibraryFile* pFile = Library.LookupFile( pItem ) )
{
if ( pFile->m_pMetadata != NULL &&
m_pSchema->Equals( pFile->m_pSchema ) )
//.........这里部分代码省略.........
示例3: ListCompare
int CLibraryDetailView::ListCompare(LPCVOID pA, LPCVOID pB)
{
LDVITEM* ppA = (LDVITEM*)pA;
LDVITEM* ppB = (LDVITEM*)pB;
int nTest = 0;
CLibraryFile* pfA = Library.LookupFile( ppA->nIndex );
CLibraryFile* pfB = Library.LookupFile( ppB->nIndex );
if ( ! pfA || ! pfB ) return 0;
switch ( m_pThis->m_nSortColumn )
{
case 0:
nTest = _tcsicoll( pfA->m_sName, pfB->m_sName );
break;
case 1:
{
LPCTSTR pszA = _tcsrchr( pfA->m_sName, '.' );
LPCTSTR pszB = _tcsrchr( pfB->m_sName, '.' );
if ( ! pszA || ! pszB ) return 0;
nTest = _tcsicoll( pszA, pszB );
break;
}
case 2:
if ( pfA->GetSize() == pfB->GetSize() )
nTest = 0;
else if ( pfA->GetSize() < pfB->GetSize() )
nTest = -1;
else
nTest = 1;
break;
case 3:
if ( pfA->m_pFolder == NULL || pfB->m_pFolder == NULL ) return 0;
nTest = _tcsicoll( pfA->m_pFolder->m_sPath, pfB->m_pFolder->m_sPath );
break;
case 4:
if ( pfA->m_nHitsTotal == pfB->m_nHitsTotal )
nTest = 0;
else if ( pfA->m_nHitsTotal < pfB->m_nHitsTotal )
nTest = -1;
else
nTest = 1;
break;
case 5:
if ( pfA->m_nUploadsTotal == pfB->m_nUploadsTotal )
nTest = 0;
else if ( pfA->m_nUploadsTotal < pfB->m_nUploadsTotal )
nTest = -1;
else
nTest = 1;
break;
case 6:
nTest = CompareFileTime( &pfA->m_pTime, &pfB->m_pTime );
break;
default:
{
int nColumn = m_pThis->m_nSortColumn - DETAIL_COLUMNS;
if ( nColumn >= m_pThis->m_pColumns.GetCount() ) return 0;
POSITION pos = m_pThis->m_pColumns.FindIndex( nColumn );
if ( pos == NULL ) return 0;
CSchemaMember* pMember = (CSchemaMember*)m_pThis->m_pColumns.GetAt( pos );
CString strA, strB;
if ( pfA->m_pMetadata ) strA = pMember->GetValueFrom( pfA->m_pMetadata, NULL, TRUE );
if ( pfB->m_pMetadata ) strB = pMember->GetValueFrom( pfB->m_pMetadata, NULL, TRUE );
if ( *(LPCTSTR)strA && *(LPCTSTR)strB &&
( ((LPCTSTR)strA)[ _tcslen( strA ) - 1 ] == 'k' || ((LPCTSTR)strA)[ _tcslen( strA ) - 1 ] == '~' )
&&
( ((LPCTSTR)strB)[ _tcslen( strB ) - 1 ] == 'k' || ((LPCTSTR)strB)[ _tcslen( strB ) - 1 ] == '~' ) )
{
nTest = CLiveList::SortProc( strA, strB, TRUE );
}
else
{
nTest = _tcsicoll( strA, strB );
}
}
}
if ( ! m_pThis->m_bSortFlip ) nTest = -nTest;
return nTest;
}
示例4: CacheItem
void CLibraryDetailView::CacheItem(int nItem)
{
CLibraryFile* pFile = Library.LookupFile( m_pList[ nItem ].nIndex );
if ( ! pFile ) return;
LDVITEM* pItem = &m_pList[ nItem ];
pItem->nCookie = m_nListCookie;
if ( pItem->pText == NULL ) pItem->pText = new CStringArray();
CStringArray* pText = pItem->pText;
pText->SetSize( m_nStyle == LVS_REPORT ? DETAIL_COLUMNS + m_pColumns.GetCount() : 1 );
CString strName( pFile->m_sName );
int nDot = strName.ReverseFind( '.' );
if ( nDot >= 0 ) strName.SetAt( nDot, 0 );
pText->SetAt( 0, strName );
if ( m_nStyle == LVS_ICON )
{
pItem->nIcon = ShellIcons.Get( pFile->m_sName, 32 );
}
else
{
if ( pFile->m_nIcon16 >= 0 )
pItem->nIcon = pFile->m_nIcon16;
else
pItem->nIcon = pFile->m_nIcon16 = ShellIcons.Get( pFile->m_sName, 16 );
}
pItem->nState &= LDVI_SELECTED;
if ( ! pFile->IsShared() ) pItem->nState |= LDVI_PRIVATE;
if ( ! pFile->m_bSHA1 ) pItem->nState |= LDVI_UNSCANNED;
if ( pFile->m_bVerify == TS_FALSE ) pItem->nState |= LDVI_UNSAFE;
if ( m_nStyle != LVS_REPORT ) return;
if ( LPCTSTR pszType = _tcsrchr( pFile->m_sName, '.' ) )
pText->SetAt( 1, pszType + 1 );
else
pText->SetAt( 1, _T("") );
pText->SetAt( 2, Settings.SmartVolume( pFile->GetSize(), FALSE ) );
if ( pFile->m_pFolder != NULL ) pText->SetAt( 3, pFile->m_pFolder->m_sPath );
CString str;
str.Format( _T("%lu (%lu)"), pFile->m_nHitsToday, pFile->m_nHitsTotal );
pText->SetAt( 4, str );
str.Format( _T("%lu (%lu)"), pFile->m_nUploadsToday, pFile->m_nUploadsTotal );
pText->SetAt( 5, str );
TCHAR szModified[ 64 ];
SYSTEMTIME pTime;
FileTimeToSystemTime( &pFile->m_pTime, &pTime );
SystemTimeToTzSpecificLocalTime( NULL, &pTime, &pTime );
GetDateFormat( LOCALE_USER_DEFAULT, 0, &pTime, _T("yyyy-MM-dd"), szModified, 64 );
_tcscat( szModified, _T(" ") );
GetTimeFormat( LOCALE_USER_DEFAULT, 0, &pTime, _T("hh:mm tt"), szModified + _tcslen( szModified ), 64 - _tcslen( szModified ) );
pText->SetAt( 6, szModified );
if ( m_pSchema == NULL ) return;
int nColumn = DETAIL_COLUMNS;
BOOL bSource = pFile->m_pMetadata && m_pSchema->Equals( pFile->m_pSchema ) &&
m_pSchema->m_sSingular.CompareNoCase( pFile->m_pMetadata->GetName() ) == 0;
for ( POSITION pos = m_pColumns.GetHeadPosition() ; pos ; nColumn++ )
{
CSchemaMember* pMember = (CSchemaMember*)m_pColumns.GetNext( pos );
if ( pMember->m_sName.CompareNoCase( _T("SHA1") ) == 0 )
{
if ( pFile->m_bSHA1 )
{
pText->SetAt( nColumn, CSHA::HashToString( &pFile->m_pSHA1 ) );
}
else pText->SetAt( nColumn, _T("") );
}
else if ( bSource )
{
pText->SetAt( nColumn, pMember->GetValueFrom( pFile->m_pMetadata, NULL, TRUE ) );
}
else
{
pText->SetAt( nColumn, _T("") );
}
}
}
示例5: ShowBitziTicket
BOOL CFileExecutor::ShowBitziTicket(DWORD nIndex)
{
CString str;
if ( ! Settings.Library.BitziOkay )
{
Skin.LoadString( str, IDS_LIBRARY_BITZI_MESSAGE );
if ( AfxMessageBox( str, MB_ICONQUESTION|MB_YESNO ) != IDYES ) return FALSE;
Settings.Library.BitziOkay = TRUE;
Settings.Save();
}
CSingleLock pLock( &Library.m_pSection, TRUE );
CLibraryFile* pFile = Library.LookupFile( nIndex );
if ( pFile == NULL ) return FALSE;
if ( pFile->m_bSHA1 == FALSE || pFile->m_bTiger == FALSE )
{
CString strFormat;
Skin.LoadString( strFormat, IDS_LIBRARY_BITZI_HASHED );
str.Format( strFormat, (LPCTSTR)pFile->m_sName );
pLock.Unlock();
AfxMessageBox( str, MB_ICONINFORMATION );
return FALSE;
}
CString strURL = Settings.Library.BitziWebView;
CFile hFile;
if ( hFile.Open( pFile->GetPath(), CFile::modeRead|CFile::shareDenyNone ) && hFile.GetLength() > 0 )
{
static LPCTSTR pszHex = _T("0123456789ABCDEF");
BYTE nBuffer[20];
int nPeek = hFile.Read( nBuffer, 20 );
hFile.Close();
str.Empty();
for ( int nByte = 0 ; nByte < nPeek ; nByte++ )
{
str += pszHex[ (BYTE)nBuffer[ nByte ] >> 4 ];
str += pszHex[ (BYTE)nBuffer[ nByte ] & 15 ];
}
strURL = Settings.Library.BitziWebSubmit;
Replace( strURL, _T("(FIRST20)"), str );
}
Replace( strURL, _T("(NAME)"), CConnection::URLEncode( pFile->m_sName ) );
Replace( strURL, _T("(SHA1)"), CSHA::HashToString( &pFile->m_pSHA1 ) );
Replace( strURL, _T("(TTH)"), CTigerNode::HashToString( &pFile->m_pTiger ) );
Replace( strURL, _T("(AGENT)"), CConnection::URLEncode( Settings.SmartAgent() ) );
str.Format( _T("%I64i"), pFile->GetSize() );
Replace( strURL, _T("(SIZE)"), str );
pLock.Unlock();
DisplayURL( strURL );
return TRUE;
}
示例6: OnPrepare
BOOL CLibraryTipCtrl::OnPrepare()
{
{
CQuickLock oLock( Library.m_pSection );
CLibraryFile* pFile = Library.LookupFile( (DWORD)m_pContext );
if ( pFile == NULL ) return FALSE;
CSingleLock pLock( &m_pSection, TRUE );
// Basic data
m_sName = pFile->m_sName;
m_sPath = pFile->GetPath();
m_nIndex = pFile->m_nIndex;
m_sSize = Settings.SmartVolume( pFile->GetSize(), FALSE );
m_nIcon = 0;
if ( pFile->m_pFolder != NULL ) m_sFolder = pFile->m_pFolder->m_sPath;
m_sType.Empty();
m_sSHA1.Empty();
m_sTTH.Empty();
m_sED2K.Empty();
// Type information and icons
m_sType = ShellIcons.GetTypeString( m_sName );
m_nIcon = ShellIcons.Get( m_sName, 48 );
// URN
if ( pFile->m_bSHA1 && Settings.General.GUIMode != GUI_BASIC)
{
m_sSHA1 = _T("sha1:") + CSHA::HashToString( &pFile->m_pSHA1 );
}
if ( pFile->m_bTiger && Settings.General.GUIMode != GUI_BASIC)
{
m_sTTH = _T("tree:tiger/:") + CTigerNode::HashToString( &pFile->m_pTiger );
}
if ( pFile->m_bED2K && Settings.General.GUIMode != GUI_BASIC)
{
m_sED2K = _T("ed2k:") + CED2K::HashToString( &pFile->m_pED2K );
}
// Metadata
CSchema* pSchema = pFile->m_pSchema;
CString str, sData, sFormat;
m_pMetadata.Clear();
LoadString( str, IDS_TIP_LOCATION );
m_pMetadata.Add( str, m_sFolder );
LoadString( str, IDS_TIP_TYPE );
m_pMetadata.Add( str, m_sType );
LoadString( str, IDS_TIP_SIZE );
m_pMetadata.Add( str, m_sSize );
LoadString( sFormat, IDS_TIP_TODAYTOTAL );
sData.Format( sFormat, pFile->m_nHitsToday, pFile->m_nHitsTotal );
LoadString( str, IDS_TIP_HITS );
m_pMetadata.Add( str, sData );
sData.Format( sFormat, pFile->m_nUploadsToday, pFile->m_nUploadsTotal );
LoadString( str, IDS_TIP_UPLOADS );
m_pMetadata.Add( str, sData );
if ( pFile->m_pMetadata && pSchema )
{
m_pMetadata.Setup( pSchema, FALSE );
m_pMetadata.Combine( pFile->m_pMetadata );
m_pMetadata.Clean();
}
}
CalcSizeHelper();
return m_sz.cx > 0;
}