Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
/* Determines the drop effect based on the
location of the source and destination
directories.
Note that the first dropped file is taken
as representative of the rest (meaning that
if the files come from different drives,
whether this operation is classed as a copy
or move is only based on the location of the
first file). */
BOOL CMyTreeView::CheckItemLocations(IDataObject *pDataObject,HTREEITEM hItem,
int iDroppedItem)
{
	FORMATETC	ftc;
	STGMEDIUM	stg;
	DROPFILES	*pdf = NULL;
	LPITEMIDLIST	pidlDest = NULL;
	TCHAR		szDestDirectory[MAX_PATH];
	TCHAR		szFullFileName[MAX_PATH];
	HRESULT		hr;
	BOOL		bOnSameDrive = FALSE;
	int			nDroppedFiles;

	ftc.cfFormat	= CF_HDROP;
	ftc.ptd			= NULL;
	ftc.dwAspect	= DVASPECT_CONTENT;
	ftc.lindex		= -1;
	ftc.tymed		= TYMED_HGLOBAL;

	hr = pDataObject->GetData(&ftc,&stg);

	if(hr == S_OK)
	{
		pdf = (DROPFILES *)GlobalLock(stg.hGlobal);

		if(pdf != NULL)
		{
			/* Request a count of the number of files that have been dropped. */
			nDroppedFiles = DragQueryFile((HDROP)pdf,0xFFFFFFFF,NULL,NULL);

			if(iDroppedItem < nDroppedFiles)
			{
				pidlDest = BuildPath(hItem);

				if(pidlDest != NULL)
				{
					/* Determine the name of the first dropped file. */
					DragQueryFile((HDROP)pdf,iDroppedItem,szFullFileName,
						SIZEOF_ARRAY(szFullFileName));

					GetDisplayName(pidlDest,szDestDirectory,SIZEOF_ARRAY(szDestDirectory),SHGDN_FORPARSING);

					bOnSameDrive = PathIsSameRoot(szDestDirectory,szFullFileName);

					CoTaskMemFree(pidlDest);
				}
			}

			GlobalUnlock(stg.hGlobal);
		}
	}

	return bOnSameDrive;
}
/* Determines the drop effect based on the
location of the source and destination
directories.
Note that the first dropped file is taken
as representative of the rest (meaning that
if the files come from different drives,
whether this operation is classed as a copy
or move is only based on the location of the
first file). */
BOOL CContainer::CheckItemLocations(int iTabId)
{
	TCHAR			szDestDirectory[MAX_PATH];
	BOOL			bOnSameDrive = FALSE;

	m_pShellBrowser[iTabId]->QueryCurrentDirectory(SIZEOF_ARRAY(szDestDirectory),
		szDestDirectory);

	bOnSameDrive = PathIsSameRoot(szDestDirectory,m_pszSource);

	return bOnSameDrive;
}
Exemplo n.º 4
0
BOOL CDropHandler::CheckItemLocations(int iDroppedItem)
{
	FORMATETC	ftc;
	STGMEDIUM	stg;
	DROPFILES	*pdf = NULL;
	TCHAR		szFullFileName[MAX_PATH];
	HRESULT		hr;
	BOOL		bOnSameDrive = FALSE;
	int			nDroppedFiles;

	ftc.cfFormat	= CF_HDROP;
	ftc.ptd			= NULL;
	ftc.dwAspect	= DVASPECT_CONTENT;
	ftc.lindex		= -1;
	ftc.tymed		= TYMED_HGLOBAL;

	hr = m_pDataObject->GetData(&ftc,&stg);

	if(hr == S_OK)
	{
		pdf = (DROPFILES *)GlobalLock(stg.hGlobal);

		if(pdf != NULL)
		{
			/* Request a count of the number of files that have been dropped. */
			nDroppedFiles = DragQueryFile((HDROP)pdf,0xFFFFFFFF,NULL,NULL);

			if(iDroppedItem < nDroppedFiles)
			{
				/* Determine the name of the first dropped file. */
				DragQueryFile((HDROP)pdf,iDroppedItem,szFullFileName,
					SIZEOF_ARRAY(szFullFileName));

				if(PathIsSameRoot(m_szDestDirectory,szFullFileName))
					bOnSameDrive = TRUE;
				else
					bOnSameDrive = FALSE;
			}

			GlobalUnlock(stg.hGlobal);
		}

		ReleaseStgMedium(&stg);
	}

	return bOnSameDrive;
}
Exemplo n.º 5
0
	static path relative_to(const path &from, const path &to, bool fromdir=true) {
		if(PathIsSameRoot(from.buf, to.buf)) {
			path p;

			if(!PathRelativePathTo(p.buf, from.buf, fromdir?FILE_ATTRIBUTE_DIRECTORY:0, to.buf, 0))
			{
				TCHAR chBuf[1024];
				swprintf_s(chBuf, _countof(chBuf), L"PathRelativePathTo() from:[%s] to:[%s] failed!!", from.buf, to.buf);
				TRACEERR("[path] [relative_to]", chBuf, GetLastError());
				throw path_error("PathRelativePathTo");
			}

			return p;
		}
		else if(to.has_root()) return to;
		else
		{
			TRACEE("[path] [relative_to]  * ERROR:  unable to create relative path: paths have different roots!!");
			throw std::runtime_error("unable to create relative path: paths have different roots");
		}
	}
Exemplo n.º 6
0
//=============================================================================
//
//  DriveBox_SelectDrive
//
BOOL DriveBox_SelectDrive(HWND hwnd,LPCWSTR lpszPath)
{

  COMBOBOXEXITEM cbei;
  LPDC_ITEMDATA lpdcid;
  WCHAR szRoot[64];

  int i;
  int cbItems = (int)SendMessage(hwnd,CB_GETCOUNT,0,0);

  // No Drives in Combo Box
  if (!cbItems)
    return FALSE;

  cbei.mask = CBEIF_LPARAM;

  for (i = 0; i < cbItems; i++)
  {
    // Get DC_ITEMDATA* of Item i
    cbei.iItem = i;
    SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei);
    lpdcid = (LPDC_ITEMDATA)cbei.lParam;

    // Get File System Path for Drive
    IL_GetDisplayName(lpdcid->lpsf,lpdcid->pidl,SHGDN_FORPARSING,szRoot,64);

    // Compare Root Directory with Path
    if (PathIsSameRoot(lpszPath,szRoot))
    {
      // Select matching Drive
      SendMessage(hwnd,CB_SETCURSEL,i,0);
      return TRUE;
    }
  }

  // Don't select anything
  SendMessage(hwnd,CB_SETCURSEL,(WPARAM)-1,0);
  return FALSE;

}