コード例 #1
0
ファイル: DriveViewer.cpp プロジェクト: avrionov/explorerxp
CString & CDriveViewer::GetDriveInfoStr(const TCHAR *path)
{
	CDriveArray drArray;
	::GetDrives(drArray);
			
	static CString info;
	info.Empty ();

	if (drArray.size() == 0)
		MarkForUpdate();

	for (int i = 0; i < static_cast<int>(drArray.size()); i++ )
	{
	  if (drArray[i].m_nType == DRIVE_FIXED)
		  if (PathIsSameRoot (path, drArray[i].m_Path))
		  {
			  //info += m_Array[i].as_text(0);
			  //info += m_Array[i].m_Path;
			  //info += "  ";
			  TCHAR buf[128];
			  StrFormatByteSize64 (drArray[i].m_FreeSpace, buf, 127);
			  //info += m_Array[i].as_text(0);
			  if (*path && path[0] > 0) {
			     info += path[0];
				 info += TEXT(": ");
			  }
			 
			  info += buf;
			  info += " free ";
		  }
	}
	return info;
}
コード例 #2
0
/** Converts a Disk Free Space into a string that represents the number 
expressed as a size value in bytes, kilobytes, megabytes, or gigabytes, depending on the size.
\return LPCTSTR - pointer to static buffer

*/
LPCTSTR GetFormatedFreeDiskSpace(LPCTSTR root_path) {

	ULARGE_INTEGER FreeBytesAvailable;    // bytes available to caller
	ULARGE_INTEGER TotalNumberOfBytes;    // bytes on disk
	ULARGE_INTEGER TotalNumberOfFreeBytes; // free bytes on disk
	static TCHAR str[60];

	if ( GetDiskFreeSpaceEx( root_path, &FreeBytesAvailable, 
				&TotalNumberOfBytes, &TotalNumberOfFreeBytes) ) 
		StrFormatByteSize64( TotalNumberOfFreeBytes.QuadPart, str, 50);
	else
		_tcscpy(str, TEXT("0 Kb") );


	return str;


}
コード例 #3
0
void CRepositoryBrowser::FillListCtrlForShadowTree(CShadowFilesTree* pTree)
{
	for (TShadowFilesTreeMap::iterator itShadowTree = pTree->m_ShadowTree.begin(); itShadowTree != pTree->m_ShadowTree.end(); ++itShadowTree)
	{
		int icon = m_nIconFolder;
		if (!(*itShadowTree).second.m_bFolder && !(*itShadowTree).second.m_bSubmodule)
		{
			icon = SYS_IMAGE_LIST().GetFileIconIndex((*itShadowTree).second.m_sName);
		}

		int indexItem = m_RepoList.InsertItem(m_RepoList.GetItemCount(), (*itShadowTree).second.m_sName, icon);

		if ((*itShadowTree).second.m_bSubmodule)
		{
			m_RepoList.SetItemState(indexItem, INDEXTOOVERLAYMASK(OVERLAY_EXTERNAL), LVIS_OVERLAYMASK);
		}
		if ((*itShadowTree).second.m_bExecutable)
			m_RepoList.SetItemState(indexItem, INDEXTOOVERLAYMASK(OVERLAY_EXECUTABLE), LVIS_OVERLAYMASK);
		if ((*itShadowTree).second.m_bSymlink)
			m_RepoList.SetItemState(indexItem, INDEXTOOVERLAYMASK(OVERLAY_SYMLINK), LVIS_OVERLAYMASK);
		m_RepoList.SetItemData(indexItem, (DWORD_PTR)&(*itShadowTree).second);
		if (!(*itShadowTree).second.m_bFolder && !(*itShadowTree).second.m_bSubmodule)
		{
			CString temp;

			temp = CPathUtils::GetFileExtFromPath((*itShadowTree).second.m_sName);
			m_RepoList.SetItemText(indexItem, eCol_Extension, temp);

			StrFormatByteSize64((*itShadowTree).second.m_iSize, temp.GetBuffer(20), 20);
			temp.ReleaseBuffer();
			m_RepoList.SetItemText(indexItem, eCol_FileSize, temp);
		}
	}

	CRepoListCompareFunc compareFunc(&m_RepoList, m_currSortCol, m_currSortDesc);
	m_RepoList.SortItemsEx(&CRepoListCompareFunc::StaticCompare, (DWORD_PTR)&compareFunc);

	SetSortArrowA(&m_RepoList, m_currSortCol, !m_currSortDesc);

	UpdateInfoLabel();
}
コード例 #4
0
ファイル: PropVolume.cpp プロジェクト: bagdxk/openafs
BOOL CPropVolume::PropPageProc( HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam )
{
    switch(uMessage)
    {
    case WM_INITDIALOG:
        {
            CPropVolume * sheetpage = (CPropVolume*) ((LPPROPSHEETPAGE) lParam)->lParam;
            SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) sheetpage);
            sheetpage->SetHwnd(hwnd);
            AfxSetResourceHandle(m_hInst);

            BOOL bFollow = (filenames.GetCount() == 1 && m_bIsMountpoint);

            if(filenames.GetCount() >= 1) {
                CString sText;

                SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, filenames.GetAt(0));
                sText = GetCellName(filenames.GetAt(0), bFollow);
                SetDlgItemText(hwnd, IDC_PROP_CELL, sText);
                sText = GetServer(filenames.GetAt(0), bFollow);
                SetDlgItemText(hwnd, IDC_PROP_FILESERVER, sText);

                TCHAR buf[100];
                CVolInfo volInfo;

                if (GetVolumeInfo(filenames.GetAt(0), volInfo, bFollow)) {
                    SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, volInfo.m_strName);

                    SetDlgItemText(hwnd, IDC_PROP_VOLUME_STATUS, volInfo.m_strAvail);

                    sText.Format(_T("%u"), volInfo.m_nID);
                    SetDlgItemText(hwnd, IDC_PROP_VID, sText);

                    if (volInfo.m_nQuota == 0) {
                        SetDlgItemText(hwnd, IDC_QUOTA_MAX, _T("unlimited"));
                        SetDlgItemText(hwnd, IDC_QUOTA_PERCENT, _T("0.00%"));
                    } else {
                        StrFormatByteSize64(volInfo.m_nQuota*1024, buf, 100);
                        SetDlgItemText(hwnd, IDC_QUOTA_MAX, buf);

                        sText.Format(_T("%.2f%%"), ((double)volInfo.m_nUsed / (double)volInfo.m_nQuota) * 100);
                        SetDlgItemText(hwnd, IDC_QUOTA_PERCENT, sText);
                    }

                    StrFormatByteSize64(volInfo.m_nUsed*1024, buf, 100);
                    SetDlgItemText(hwnd, IDC_QUOTA_USED, buf);

                    StrFormatByteSize64(volInfo.m_nPartSize*1024, buf, 100);
                    SetDlgItemText(hwnd, IDC_PARTITION_SIZE, buf);
                    StrFormatByteSize64(volInfo.m_nPartFree*1024, buf, 100);
                    SetDlgItemText(hwnd, IDC_PARTITION_FREE, buf);

                    sText.Format(_T("%.2f%%"), ((double)volInfo.m_nPartFree / (double)volInfo.m_nPartSize) * 100);
                    SetDlgItemText(hwnd, IDC_PARTITION_PERCENT, sText);
                }
                else
                {
                    SetDlgItemText(hwnd, IDC_PROP_VOLUMENAME, volInfo.m_strErrorMsg);
                }

                // "where is" info
                CStringArray servers;
                GetServers(filenames.GetAt(0), servers, bFollow);
                int tabstops[1] = {118};
                SendDlgItemMessage(hwnd, IDC_SERVERS, LB_SETTABSTOPS, 1, (LPARAM)&tabstops);
                for (int i=0;i<servers.GetCount();++i){
                    SendDlgItemMessage(m_hwnd, IDC_SERVERS, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)servers.GetAt(i));
                }
            }
            return TRUE;
        }
        break;
    case WM_NOTIFY:
        {
            LPNMHDR point = (LPNMHDR)lParam;
            int code = point->code;
            BOOL bRet = FALSE;
            switch (code)
            {
            case PSN_APPLY:
                {
                    // Return PSNRET_NOERROR to allow the sheet to close if the user clicked OK.
                    SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_NOERROR);
                }
                break;
            }
            SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
            return bRet;
        }
        break;
    case WM_COMMAND:
        switch (HIWORD(wParam))
        {
        case BN_CLICKED:
            switch (LOWORD(wParam))
            {
            case IDC_FLUSH:
                FlushVolume(filenames);
                return TRUE;
            }
            break;
        }
        break;
    }

    return FALSE;
}