Example #1
0
void CDirstatDoc::PerformUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, CItem *item) throw(CException *)
{
	CWaitCursor wc;

	CString path= item->GetPath();

	bool isDirectory= item->GetType() == IT_DRIVE || item->GetType() == IT_DIRECTORY || item->GetType() == IT_FILESFOLDER;

	// Verify that path still exists
	if (isDirectory)
	{
		if (!FolderExists(path) && !DriveExists(path))
			MdThrowStringExceptionF(IDS_THEDIRECTORYsDOESNOTEXIST, path);
	}
	else
	{
		ASSERT(item->GetType() == IT_FILE);

		if (!FileExists(path))
			MdThrowStringExceptionF(IDS_THEFILEsDOESNOTEXIST, path);
	}

	if (udc->recurseIntoSubdirectories && item->GetType() != IT_FILESFOLDER)
	{
		ASSERT(item->GetType() == IT_DRIVE || item->GetType() == IT_DIRECTORY);

		RecursiveUserDefinedCleanup(udc, path, path);
	}
	else
	{
		CallUserDefinedCleanup(isDirectory, udc->commandLine, path, path, udc->showConsoleWindow, udc->waitForCompletion);
	}
}
Example #2
0
int main(void)
{
  int maxdrives,curdrive, x;
  unsigned long disksize,diskfree,clustersize,sizesum=0,freesum=0;
  unsigned long capacity;
  char label[41],file_system[256];

  #ifdef __OS2__
   DosError(FERR_DISABLEHARDERR|FERR_ENABLEEXCEPTION);
  #endif

  printf("\nDF/" VERSION_BITS "bit v" VERSION_NO
	 "     Copyright (c) Timo Kokkonen, OH6LXV  "
	 "             " RELEASE_DATE "\n\n");

  curdrive=getdisk();
  maxdrives=setdisk(curdrive);
  if (maxdrives-2<=0) return 1;

  printf("disk               free       used      total capacity  cluster   file system\n");
  for(x=3;x<=maxdrives;x++) {
    label[0]=0;
    file_system[0]=0;
    #ifdef __MSDOS__
    if (!DriveExists(x)) continue;
    #endif
    if (getDiskSize(x,&disksize,&diskfree,&clustersize)) {
      getDiskLabel(x,label);
      strcpy(file_system,getIFSname(x));
    }
    sizesum+=disksize; freesum+=diskfree;
    if (disksize==0) capacity=0;
      else capacity=((disksize-diskfree)/(disksize/100));

    printf("%c:%-12s %8luk  %8luk  %8luk  %3lu%%  %5lu bytes   %-8s \n",
       x+64,label,diskfree/1024,(disksize-diskfree)/1024,disksize/1024,
       capacity,clustersize,file_system);
  }

  printf("\nTotal:        %9luk %9luk %9luk  %3lu%% \n",
     freesum/1024,(sizesum-freesum)/1024,sizesum/1024,
     (sizesum-freesum)/(sizesum/100));

  return 0;
}
Example #3
0
// Return: false if deleted
bool CItem::StartRefresh() 
{
	ASSERT(GetType() != IT_FREESPACE);
	ASSERT(GetType() != IT_UNKNOWN);

	m_ticksWorked = 0;

	// Special case IT_MYCOMPUTER
	if (GetType() == IT_MYCOMPUTER)
	{
		ZeroMemory(&m_lastChange, sizeof(m_lastChange));

		for (int i=0; i < GetChildrenCount(); i++)
			GetChild(i)->StartRefresh();

		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY || GetType() == IT_FILESFOLDER);

	bool wasExpanded = IsVisible() && IsExpanded();
	int oldScrollPosition = 0;
	if (IsVisible())
		oldScrollPosition = GetScrollPosition();

	UncacheImage();

	// Upward clear data
	UpdateLastChange();

	UpwardSetUndone();

	UpwardAddReadJobs(-GetReadJobs());
	ASSERT(GetReadJobs() == 0);

	if (GetType() == IT_FILE)
		GetParent()->UpwardAddFiles(-1);
	else
		UpwardAddFiles(-GetFilesCount());
	ASSERT(GetFilesCount() == 0);

	if (GetType() == IT_DIRECTORY || GetType() == IT_DRIVE)
		UpwardAddSubdirs(-GetSubdirsCount());
	ASSERT(GetSubdirsCount() == 0);

	UpwardAddSize(-GetSize());
	ASSERT(GetSize() == 0);

	RemoveAllChildren();
	UpwardRecalcLastChange();

	// Special case IT_FILESFOLDER
	if (GetType() == IT_FILESFOLDER)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetFindPattern());
		while (b)
		{
			b = finder.FindNextFile();
			if (finder.IsDirectory())
				continue;

			FILEINFO fi;
			fi.name = finder.GetFileName();
			fi.attributes = finder.GetAttributes();
			// Retrieve file size
			fi.length = finder.GetCompressedLength();
			finder.GetLastWriteTime(&fi.lastWriteTime);

			AddFile(fi);
			UpwardAddFiles(1);
		}
		SetDone();

		if (wasExpanded)
			GetTreeListControl()->ExpandItem(this);
		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	// The item may have been deleted.
	bool deleted = false;
	if (GetType() == IT_DRIVE)
		deleted = !DriveExists(GetPath());
	else if (GetType() == IT_FILE)
		deleted = !FileExists(GetPath());
	else if (GetType() == IT_DIRECTORY)
		deleted = !FolderExists(GetPath());

	if (deleted)
	{
		if (GetParent() == NULL)
		{
			GetDocument()->UnlinkRoot();
		}
		else
		{
			GetParent()->UpwardRecalcLastChange();
			GetParent()->RemoveChild(GetParent()->FindChildIndex(this)); // --> delete this
		}
		return false;
	}

	// Case IT_FILE
	if (GetType() == IT_FILE)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetPath());
		if (b)
		{
			finder.FindNextFile();
			if (!finder.IsDirectory())
			{
				FILEINFO fi;
				fi.name = finder.GetFileName();
				fi.attributes = finder.GetAttributes();
				// Retrieve file size
				fi.length = finder.GetCompressedLength();
				finder.GetLastWriteTime(&fi.lastWriteTime);

				SetLastChange(fi.lastWriteTime);

				UpwardAddSize(fi.length);
				UpwardUpdateLastChange(GetLastChange());
				GetParent()->UpwardAddFiles(1);
			}
		}
		SetDone();
		return true;
	}

	ASSERT(GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsMountPoint(GetPath()) && !GetOptions()->IsFollowMountPoints())
		return true;

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsJunctionPoint(GetPath()) && !GetOptions()->IsFollowJunctionPoints())
		return true;

	// Initiate re-read
	SetReadJobDone(false);

	// Re-create <free space> and <unknown>
	if (GetType() == IT_DRIVE)
	{
		if (GetDocument()->OptionShowFreeSpace())
			CreateFreeSpaceItem();
		if (GetDocument()->OptionShowUnknown())
			CreateUnknownItem();
	}

	DoSomeWork(0);

	if (wasExpanded)
		GetTreeListControl()->ExpandItem(this);

	if (IsVisible())
		SetScrollPosition(oldScrollPosition);

	return true;
}
BOOL CSelectDrivesDlg::OnInitDialog()
{
	CWaitCursor wc;

	CDialog::OnInitDialog();

	if (WMU_THREADFINISHED == 0)
	{
		TRACE("RegisterMessage() failed. Using WM_USER + 123\r\n");
		WMU_THREADFINISHED = WM_USER + 123;
	}

	ModifyStyle(0, WS_CLIPCHILDREN);

	m_layout.AddControl(IDOK,				1, 0, 0, 0);
	m_layout.AddControl(IDCANCEL,			1, 0, 0, 0);
	m_layout.AddControl(IDC_DRIVES,			0, 0, 1, 1);
	m_layout.AddControl(IDC_AFOLDER,		0, 1, 0, 0);
	m_layout.AddControl(IDC_FOLDERNAME,		0, 1, 1, 0);
	m_layout.AddControl(IDC_BROWSEFOLDER,	1, 1, 0, 0);

	m_layout.OnInitDialog(true);

	m_list.ShowGrid(GetOptions()->IsListGrid());
	m_list.ShowStripes(GetOptions()->IsListStripes());
	m_list.ShowFullRowSelection(GetOptions()->IsListFullRowSelection());

	m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_HEADERDRAGDROP);
	// If we set an ImageList here, OnMeasureItem will have no effect ?!

	m_list.InsertColumn(COL_NAME,		LoadString(IDS_DRIVECOL_NAME),		LVCFMT_LEFT, 120, COL_NAME);
	m_list.InsertColumn(COL_TOTAL,		LoadString(IDS_DRIVECOL_TOTAL),		LVCFMT_RIGHT, 55, COL_TOTAL);
	m_list.InsertColumn(COL_FREE,		LoadString(IDS_DRIVECOL_FREE),		LVCFMT_RIGHT, 55, COL_FREE);
	m_list.InsertColumn(COL_GRAPH,		LoadString(IDS_DRIVECOL_GRAPH),		LVCFMT_LEFT, 100, COL_GRAPH);
	m_list.InsertColumn(COL_PERCENTUSED,LoadString(IDS_DRIVECOL_PERCENTUSED),LVCFMT_RIGHT, 55, COL_PERCENTUSED);

	m_list.OnColumnsInserted();

	m_folderName= CPersistence::GetSelectDrivesFolder();
	CPersistence::GetSelectDrivesDrives(m_selectedDrives);

	ShowWindow(SW_SHOWNORMAL);
	UpdateWindow();
	BringWindowToTop();
	SetForegroundWindow();

	DWORD drives= GetLogicalDrives();
	int i;
	DWORD mask= 0x00000001;
	for (i=0; i < 32; i++, mask <<= 1)
	{
		if ((drives & mask) == 0)
			continue;

		CString s;
		s.Format(_T("%c:\\"), i + _T('A'));

		UINT type= GetDriveType(s);
		if (type == DRIVE_UNKNOWN || type == DRIVE_NO_ROOT_DIR)
			continue;

		// The check of remote drives will be done in the backgound by the CDriveInformationThread.
		if (type != DRIVE_REMOTE && !DriveExists(s))
			continue;

		CDriveItem *item= new CDriveItem(&m_list, s);
		m_list.InsertListItem(m_list.GetItemCount(), item);
		item->StartQuery(m_hWnd, _serial);

		for (int k=0; k < m_selectedDrives.GetSize(); k++)
		{
			if (item->GetDrive() == m_selectedDrives[k])
			{
				m_list.SelectItem(item);
				break;
			}
		}
	}

	m_list.SortItems();

	m_radio= CPersistence::GetSelectDrivesRadio();
	UpdateData(false);

	switch (m_radio)
	{
	case RADIO_ALLLOCALDRIVES:
	case RADIO_AFOLDER:
		m_okButton.SetFocus();
		break;
	case RADIO_SOMEDRIVES:
		m_list.SetFocus();
		break;
	}

	UpdateButtons();
	return false; // we have set the focus.
}