Example #1
0
static BOOL FillDriveList()
{
    DRIVE_INFO di;

    TCHAR chDrive = TEXT('A');
    DWORD dwDrives = GetLogicalDrives();

    // This failing is not fatal to this function
    // Make sure the partition table is up to date
    afs_status_t nStatus;
    int nResult = ReadPartitionTable(&nStatus);
    ASSERT(nResult);

    while (dwDrives) {
	if (dwDrives & 1) {
	    memset(&di, 0, sizeof(di));

	    if (GetDriveInfo(chDrive, di)) {
		FASTLISTADDITEM ai = { 0, di.nImage, IMAGE_NOIMAGE, di.szRootDir, di.bDisabled, di.dwFlags };
		HLISTITEM hItem = FastList_AddItem(m_hDriveList, &ai);
		FastList_SetItemText(m_hDriveList, hItem, 1, di.szVolName);
		FastList_SetItemText(m_hDriveList, hItem, 2, di.szSize);
	    }
	}

	chDrive++;
	dwDrives >>= 1;
    }

    return TRUE;
}
static afs_status_t DoesAPartitionExist(BOOL& bExists)
{
    g_LogFile.Write("Does a partition exist on this machine: ");

    bExists = FALSE;

    afs_status_t nStatus;

    int nResult = ReadPartitionTable(&nStatus);
    if (!nResult)
	return nStatus;

    int nNumPartitions = 0;

    cfg_partitionEntry_t *pTable = GetPartitionTable(nNumPartitions);

    bExists = nNumPartitions > 0;
    if (bExists) {
	g_CfgData.chDeviceName = pTable->deviceName[0];
	lstrcpy(g_CfgData.szPartitionName, ((TCHAR *)A2S(pTable->partitionName)) + lstrlen(TEXT("/vicep")));
    }

    g_LogFile.WriteBoolResult(bExists);

    return 0;
}	
bool CIoSupport::ReadPartitionTable()
{
#ifdef _XBOX
  unsigned int retval;

  retval = ReadPartitionTable(&m_partitionTable);
  if (retval == STATUS_SUCCESS)
  {
    m_fPartitionTableIsValid = true;
    return true;
  }
  else
  {
    m_fPartitionTableIsValid = false;
    return false;
  }
#else
  return false;
#endif
}