Esempio n. 1
0
wxString wxFileData::GetHint() const
{
    wxString s = m_filePath;
    s += wxT("  ");

    if (IsDir())
        s += _("<DIR>");
    else if (IsLink())
        s += _("<LINK>");
    else if (IsDrive())
        s += _("<DRIVE>");
    else // plain file
        s += wxString::Format( _("%ld bytes"), m_size );

    s += wxT(' ');

    if ( !IsDrive() )
    {
        s << GetModificationTime()
          << wxT("  ")
          << m_permissions;
    }

    return s;
};
Esempio n. 2
0
wxString wxFileData::GetEntry( fileListFieldType num ) const
{
    wxString s;
    switch ( num )
    {
    case FileList_Name:
        s = m_fileName;
        break;

    case FileList_Size:
        if (!IsDir() && !IsLink() && !IsDrive())
            s.Printf(_T("%ld"), m_size);
        break;

    case FileList_Type:
        s = GetFileType();
        break;

    case FileList_Time:
        if (!IsDrive())
            s = GetModificationTime();
        break;

#if defined(__UNIX__) || defined(__WIN32__)
    case FileList_Perm:
        s = m_permissions;
        break;
#endif // defined(__UNIX__) || defined(__WIN32__)

    default:
        wxFAIL_MSG( _T("unexpected field in wxFileData::GetEntry()") );
    }

    return s;
}
Esempio n. 3
0
BOOL CTreeFileCtrl::Rename(HTREEITEM hItem)
{
  if (!IsDrive(hItem) && m_bAllowRename)
    return (EditLabel(hItem) != NULL);
  else
    return FALSE;
}
Esempio n. 4
0
/** 
Function to create a given directory. 

@internalComponent
@released

@param aSrcPath - path of the directory that needs to be created.
@param aDelimiter - delimiter.
*/
void ImageReader::CreateSpecifiedDir(char* aSrcPath,const char* aDelimiter)
{
	char* currWorkingDir = new char[_MAX_BUFFER_SIZE_];
	string origPath;

	origPath.assign(aSrcPath);


	// get the current working directory and store in buffer.
	if( GETCWD(currWorkingDir,_MAX_BUFFER_SIZE_) == NULL )
	{
		// throw an exception if unable to get current working directory information.
		throw ImageReaderException((char*)ImageReader::iImgFileName.c_str(), "Failed to get the current working directory");
	}
	else
	{
		char* cPtr = strtok(aSrcPath,aDelimiter);

		// check whether cPtr is a drive or a directory.
		if(IsDrive(cPtr))
		{
			// if yes, then change the directory to cPtr.
			string changeToDrive ;
			changeToDrive.assign(cPtr);
			changeToDrive.append(aDelimiter);
			
			// change the current working directory to the specified directory.
			if( CHDIR(changeToDrive.c_str()) )
			{
				// throw an exception if unable to change the directory specified.
				throw ImageReaderException((char*)ImageReader::iImgFileName.c_str(), "Failed to change to the directory specified");
			}
		}
		else
		{
			// if not,then create a cPtr directory. 
			MKDIR(cPtr);
			// change the current working directory to cPtr.
			int r = CHDIR(cPtr); (void)r;
		}
		// repeat till cPtr is NULL.
		while (cPtr!=NULL)
		{
			if ((cPtr = strtok(NULL,aDelimiter)) != NULL)
			{
				// create the directory.
				MKDIR(cPtr);
				// change current working directory.
				int r = CHDIR(cPtr); (void)r;
			}
		}
		// revert back the working directory.
		int r = CHDIR(currWorkingDir); (void)r;
		// replace the source path with the original path information.
		strcpy(aSrcPath,origPath.c_str());
		delete[] currWorkingDir;
	}
}
Esempio n. 5
0
LRESULT FolderTree::OnSelChanged(int /*idCtrl*/, LPNMHDR pnmh, BOOL &bHandled)
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pnmh;

	//Nothing selected
	if (pNMTreeView->itemNew.hItem == NULL)
	{
		bHandled = FALSE;
		return 0;
	}

	//Check to see if the current item is valid, if not then delete it (Exclude network items from this check)
	FolderTreeItemInfo* pItem = (FolderTreeItemInfo*) GetItemData(pNMTreeView->itemNew.hItem);
	//ASSERT(pItem);
	tstring sPath = pItem->m_sFQPath;
	if (!pItem->m_removed && (pNMTreeView->itemNew.hItem != m_hNetworkRoot) && (pItem->m_pNetResource == NULL) &&
		(pNMTreeView->itemNew.hItem != m_hMyComputerRoot) && !IsDrive(sPath) && (GetFileAttributes(sPath.c_str()) == 0xFFFFFFFF))
	{
		//Before we delete it see if we are the only child item
		HTREEITEM hParent = GetParentItem(pNMTreeView->itemNew.hItem);

		//Delete the item
		DeleteItem(pNMTreeView->itemNew.hItem);

		//Remove all the child items from the parent
		SetHasPlusButton(hParent, false);

		bHandled = FALSE; //Allow the message to be reflected again
		return 1;
	}

	//Remeber the serial number for this item (if it is a drive)
	if (IsDrive(sPath))
	{
		int nDrive = sPath[0] - _T('A');
		GetSerialNumber(sPath, m_dwMediaID[nDrive]);
	}
	
	bHandled = FALSE; //Allow the message to be reflected again
	
	return 0;	
}
Esempio n. 6
0
bool
IsAbsolutePath(const TCHAR *p)
{
#ifdef WIN32
    if (IsDrive(p) && IsDirSeparator(p[2]))
        return true;
#endif

    return IsDirSeparator(*p);

}
Esempio n. 7
0
void FolderTree::checkRemovedDirs(const tstring& aParentPath, HTREEITEM hParent) {
	string parentPath = Text::fromT(aParentPath);
	for(auto& sd: sp->getCurItems()) {
		if (sd->found || !sd->isCurItem())
			continue;

		auto dir = Util::getParentDir(sd->dir->path);
		if (dir == parentPath) {
			//this should have been inserted
			FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
			pItem->m_sFQPath = Text::toT(sd->dir->path);
			pItem->m_sRelativePath = Text::toT(Util::getLastDir(sd->dir->path));
			pItem->m_removed = true;

			tstring sLabel;

			//Correct the label if need be
			if(IsDrive(pItem->m_sFQPath) && m_bShowDriveLabels)
				sLabel = GetDriveLabel(pItem->m_sFQPath);
			else
				sLabel = GetCorrectedLabel(pItem);

			sLabel = _T("REMOVED: ") + sLabel;

			//Add the actual item
			TV_INSERTSTRUCT tvis;
			memzero(&tvis, sizeof(TV_INSERTSTRUCT));
			tvis.hParent = hParent;
			tvis.hInsertAfter = TVI_FIRST;
			tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
			//tvis.item.iImage = 7;
			//tvis.item.iSelectedImage = 7;
			tvis.item.iImage = 1;
			tvis.item.iSelectedImage = 1;

			tvis.item.lParam = (LPARAM) pItem;
			tvis.item.pszText = (LPWSTR)sLabel.c_str();
			tvis.item.cChildren = false;
	
			tvis.item.mask |= TVIF_STATE;
			tvis.item.stateMask |= TVIS_OVERLAYMASK;
			tvis.item.state = TVIS_BOLD | INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
			tvis.item.state |= TVIS_BOLD;

			//tvis.item.state = TVIS_BOLD;
			//tvis.item.stateMask = TVIS_BOLD;

			HTREEITEM hItem = InsertItem(&tvis);
			//SetItemImage(hItem, MAKEINTRESOURCE(IDI_ERROR), MAKEINTRESOURCE(IDI_ERROR));
			SetChecked(hItem, true);
			SetItemState(hItem, TVIS_BOLD, TVIS_BOLD);
		}
	}
}
Esempio n. 8
0
bool
Path::IsAbsolute() const
{
  assert(!IsNull());

#ifdef WIN32
  if (IsDrive(c_str()) && IsDirSeparator(c_str()[2]))
    return true;
#endif

  return IsDirSeparator(c_str()[0]);
}
Esempio n. 9
0
bool FolderTree::DriveHasRemovableMedia(const tstring &sPath)
{
	bool bRemovableMedia = false;
	if(IsDrive(sPath))
	{
		UINT nDriveType = GetDriveType(sPath.c_str());
		bRemovableMedia = ((nDriveType == DRIVE_REMOVABLE) ||
						(nDriveType == DRIVE_CDROM));
	}

	return bRemovableMedia;
}
Esempio n. 10
0
wxString wxFileData::GetFileType() const
{
    if (IsDir())
        return _("<DIR>");
    else if (IsLink())
        return _("<LINK>");
    else if (IsDrive())
        return _("<DRIVE>");
    else if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND)
        return m_fileName.AfterLast(wxT('.'));

    return wxEmptyString;
}
Esempio n. 11
0
void CTreeFileCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	TV_DISPINFO* pDispInfo = (TV_DISPINFO*)pNMHDR;
  if (pDispInfo->item.pszText)
  {
    SHFILEOPSTRUCT shfo;
    ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
    shfo.hwnd = AfxGetMainWnd()->GetSafeHwnd();
    shfo.wFunc = FO_RENAME;
    shfo.fFlags = FOF_ALLOWUNDO;

    CString sFrom = ItemToPath(pDispInfo->item.hItem);
    int nFromLength = sFrom.GetLength();
    TCHAR* pszFrom = new TCHAR[nFromLength + 2];
    _tcscpy(pszFrom, sFrom);
    pszFrom[nFromLength+1] = _T('\0');
    shfo.pFrom = pszFrom;
    HTREEITEM hParent = GetParentItem(pDispInfo->item.hItem);
    CString sParent = ItemToPath(hParent);
    CString sTo;
    if (IsDrive(sParent))
      sTo = sParent + pDispInfo->item.pszText;
    else
      sTo = sParent + _T("\\") + pDispInfo->item.pszText;

    int nToLength = _tcslen(sTo);
    TCHAR* pszTo = new TCHAR[nToLength + 2];
    _tcscpy(pszTo, sTo);
    pszTo[nToLength+1] = _T('\0');
    shfo.pTo = pszTo;

    //Let the shell perform the actual rename
    if (SHFileOperation(&shfo) == 0 && shfo.fAnyOperationsAborted == FALSE)
    {
      *pResult = TRUE;

      //Update its text  
      SetItemText(pDispInfo->item.hItem, pDispInfo->item.pszText);

      //Also update the icons for it
      CString sPath = ItemToPath(pDispInfo->item.hItem);
      SetItemImage(pDispInfo->item.hItem, GetIconIndex(sPath), GetSelIconIndex(sPath));
    }

    //Don't forget to free up the memory we allocated
    delete [] pszFrom;
    delete [] pszTo;
  }
	
	*pResult = 0;
}
Esempio n. 12
0
HTREEITEM FolderTree::InsertFileItem(HTREEITEM hParent, FolderTreeItemInfo *pItem, bool bShared, int nIcon, int nSelIcon, bool bCheckForChildren)
{
	tstring sLabel;

	//Correct the label if need be
	if(IsDrive(pItem->m_sFQPath) && m_bShowDriveLabels)
		sLabel = GetDriveLabel(pItem->m_sFQPath);
	else
		sLabel = GetCorrectedLabel(pItem);

	//Add the actual item
	TV_INSERTSTRUCT tvis;
	memzero(&tvis, sizeof(TV_INSERTSTRUCT));
	tvis.hParent = hParent;
	tvis.hInsertAfter = TVI_LAST;
	tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
	tvis.item.iImage = nIcon;
	tvis.item.iSelectedImage = nSelIcon;

	tvis.item.lParam = (LPARAM) pItem;
	tvis.item.pszText = (LPWSTR)sLabel.c_str();
	if (bCheckForChildren)
		tvis.item.cChildren = HasGotSubEntries(pItem->m_sFQPath);
	else
		tvis.item.cChildren = true;

	if(bShared)
	{
		tvis.item.mask |= TVIF_STATE;
		tvis.item.stateMask |= TVIS_OVERLAYMASK;
		tvis.item.state |= INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
	}

	HTREEITEM hItem = InsertItem(&tvis);
	
	bool bChecked = false;
	if (!pItem->m_sFQPath.empty()) {
		string path = Text::fromT(pItem->m_sFQPath);
		if( path[ path.length() -1 ] != PATH_SEPARATOR )
			path += PATH_SEPARATOR;

		bChecked = sp->shareFolder(path);
		SetChecked(hItem, bChecked);
	}

	if(!bChecked)
		SetHasSharedChildren(hItem);

	return hItem;
}
Esempio n. 13
0
BOOL CTreeFileCtrl::Delete(HTREEITEM hItem)
{
  BOOL bSuccess = FALSE;
  if (!IsDrive(hItem) && m_bAllowDelete)
  {
    //Create a Multi SZ string with the filename to delete
    CString sFileToDelete = ItemToPath(hItem);
    int nChars = sFileToDelete.GetLength() + 1;
    nChars++;
    SHFILEOPSTRUCT shfo;
    ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
    shfo.hwnd = AfxGetMainWnd()->GetSafeHwnd();
    shfo.wFunc = FO_DELETE;

    //Undo is not allowed if the SHIFT key is held down
    if (!(GetKeyState(VK_SHIFT) & 0x8000))
      shfo.fFlags = FOF_ALLOWUNDO;

    TCHAR* pszFrom = new TCHAR[nChars];
    TCHAR* pszCur = pszFrom;
    _tcscpy(pszCur, sFileToDelete);
    pszCur[nChars-1] = _T('\0');
    shfo.pFrom = pszFrom;

    //Let the shell perform the actual deletion
    if (SHFileOperation(&shfo) == 0 && shfo.fAnyOperationsAborted == FALSE)
    {
      //Delete the item from the view
      bSuccess = DeleteItem(hItem);
    }

    //Free up the memory we had allocated
    delete [] pszFrom;
  }
  return bSuccess;
}
Esempio n. 14
0
void wxFileData::ReadData()
{
    if (IsDrive())
    {
        m_size = 0;
        return;
    }

#if defined(__DOS__) || (defined(__WINDOWS__) && !defined(__WXWINCE__)) || defined(__OS2__)
    // c:\.. is a drive don't stat it
    if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5))
    {
        m_type = is_drive;
        m_size = 0;
        return;
    }
#endif // __DOS__ || __WINDOWS__

#ifdef __WXWINCE__

    // WinCE

    DWORD fileAttribs = GetFileAttributes(m_filePath.fn_str());
    m_type |= (fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0 ? is_dir : 0;

    wxString p, f, ext;
    wxSplitPath(m_filePath, & p, & f, & ext);
    if (wxStricmp(ext, wxT("exe")) == 0)
        m_type |= is_exe;

    // Find out size
    m_size = 0;
    HANDLE fileHandle = CreateFile(m_filePath.fn_str(),
                                   GENERIC_READ,
                                   FILE_SHARE_READ,
                                   NULL,
                                   OPEN_EXISTING,
                                   FILE_ATTRIBUTE_NORMAL,
                                   NULL);

    if (fileHandle != INVALID_HANDLE_VALUE)
    {
        m_size = GetFileSize(fileHandle, 0);
        CloseHandle(fileHandle);
    }

    m_dateTime = wxFileModificationTime(m_filePath);

#else

    // OTHER PLATFORMS

    wxStructStat buff;

#if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS))
    lstat( m_filePath.fn_str(), &buff );
    m_type |= S_ISLNK( buff.st_mode ) != 0 ? is_link : 0;
#else // no lstat()
    // only translate to file charset if we don't go by our
    // wxStat implementation
#ifndef wxNEED_WX_UNISTD_H
    wxStat( m_filePath.fn_str() , &buff );
#else
    wxStat( m_filePath, &buff );
#endif
#endif

    m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0;
    m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0;
    m_size = (long)buff.st_size;

    m_dateTime = buff.st_mtime;
#endif
    // __WXWINCE__

#if defined(__UNIX__)
    m_permissions.Printf(_T("%c%c%c%c%c%c%c%c%c"),
                         buff.st_mode & wxS_IRUSR ? _T('r') : _T('-'),
                         buff.st_mode & wxS_IWUSR ? _T('w') : _T('-'),
                         buff.st_mode & wxS_IXUSR ? _T('x') : _T('-'),
                         buff.st_mode & wxS_IRGRP ? _T('r') : _T('-'),
                         buff.st_mode & wxS_IWGRP ? _T('w') : _T('-'),
                         buff.st_mode & wxS_IXGRP ? _T('x') : _T('-'),
                         buff.st_mode & wxS_IROTH ? _T('r') : _T('-'),
                         buff.st_mode & wxS_IWOTH ? _T('w') : _T('-'),
                         buff.st_mode & wxS_IXOTH ? _T('x') : _T('-'));
#elif defined(__WIN32__)
    DWORD attribs = GetFileAttributes(m_filePath.fn_str());
    if (attribs != (DWORD)-1)
    {
        m_permissions.Printf(_T("%c%c%c%c"),
                             attribs & FILE_ATTRIBUTE_ARCHIVE  ? _T('A') : _T(' '),
                             attribs & FILE_ATTRIBUTE_READONLY ? _T('R') : _T(' '),
                             attribs & FILE_ATTRIBUTE_HIDDEN   ? _T('H') : _T(' '),
                             attribs & FILE_ATTRIBUTE_SYSTEM   ? _T('S') : _T(' '));
    }
#endif

    // try to get a better icon
    if (m_image == wxFileIconsTable::file)
    {
        if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND)
        {
            m_image = wxTheFileIconsTable->GetIconID( m_fileName.AfterLast(wxT('.')));
        } else if (IsExe())
        {
            m_image = wxFileIconsTable::executable;
        }
    }
}
Esempio n. 15
0
void wxFileData::ReadData()
{
    if (IsDrive())
    {
        m_size = 0;
        return;
    }

#if defined(__WINDOWS__)
    // c:\.. is a drive don't stat it
    if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5))
    {
        m_type = is_drive;
        m_size = 0;
        return;
    }
#endif // __WINDOWS__

    // OTHER PLATFORMS

    wxStructStat buff;

#if defined(__UNIX__) && !defined(__VMS)
    const bool hasStat = lstat( m_filePath.fn_str(), &buff ) == 0;
    if ( hasStat )
        m_type |= S_ISLNK(buff.st_mode) ? is_link : 0;
#else // no lstat()
    const bool hasStat = wxStat( m_filePath, &buff ) == 0;
#endif

    if ( hasStat )
    {
        m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0;
        m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0;

        m_size = buff.st_size;

        m_dateTime = buff.st_mtime;
    }

#if defined(__UNIX__)
    if ( hasStat )
    {
        m_permissions.Printf(wxT("%c%c%c%c%c%c%c%c%c"),
                             buff.st_mode & wxS_IRUSR ? wxT('r') : wxT('-'),
                             buff.st_mode & wxS_IWUSR ? wxT('w') : wxT('-'),
                             buff.st_mode & wxS_IXUSR ? wxT('x') : wxT('-'),
                             buff.st_mode & wxS_IRGRP ? wxT('r') : wxT('-'),
                             buff.st_mode & wxS_IWGRP ? wxT('w') : wxT('-'),
                             buff.st_mode & wxS_IXGRP ? wxT('x') : wxT('-'),
                             buff.st_mode & wxS_IROTH ? wxT('r') : wxT('-'),
                             buff.st_mode & wxS_IWOTH ? wxT('w') : wxT('-'),
                             buff.st_mode & wxS_IXOTH ? wxT('x') : wxT('-'));
    }
#elif defined(__WIN32__)
    DWORD attribs = ::GetFileAttributes(m_filePath.c_str());
    if (attribs != (DWORD)-1)
    {
        m_permissions.Printf(wxT("%c%c%c%c"),
                             attribs & FILE_ATTRIBUTE_ARCHIVE  ? wxT('A') : wxT(' '),
                             attribs & FILE_ATTRIBUTE_READONLY ? wxT('R') : wxT(' '),
                             attribs & FILE_ATTRIBUTE_HIDDEN   ? wxT('H') : wxT(' '),
                             attribs & FILE_ATTRIBUTE_SYSTEM   ? wxT('S') : wxT(' '));
    }
#endif

    // try to get a better icon
    if (m_image == wxFileIconsTable::file)
    {
        if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND)
        {
            m_image = wxTheFileIconsTable->GetIconID( m_fileName.AfterLast(wxT('.')));
        } else if (IsExe())
        {
            m_image = wxFileIconsTable::executable;
        }
    }
}
Esempio n. 16
0
bool FolderTree::IsDrive(HTREEITEM hItem)
{
	return IsDrive(ItemToPath(hItem));
}
Esempio n. 17
0
HTREEITEM FolderTree::SetSelectedPath(const tstring &sPath, bool bExpanded /* = false */)
{
	tstring sSearch = sPath;
	sSearch = Text::toLower(sSearch);
	int nSearchLength = sSearch.size();
	if(nSearchLength == 0)
	{
		//TRACE(_T("Cannot select a empty path\n"));
		return NULL;
	}

	//Remove initial part of path if the root folder is setup
	tstring sRootFolder = m_sRootFolder;
	sRootFolder = Text::toLower(sRootFolder);
	int nRootLength = sRootFolder.size();
	if (nRootLength)
	{
		if(sSearch.find(sRootFolder) != 0)
		{
			//TRACE(_T("Could not select the path %s as the root has been configued as %s\n"), sPath, m_sRootFolder);
			return NULL;
		}
		sSearch = sSearch.substr(nRootLength);
	}

	//Remove trailing "\" from the path
	nSearchLength = sSearch.size();
	if (nSearchLength > 3 && sSearch[nSearchLength-1] == _T('\\'))
		sSearch = sSearch.substr(0, nSearchLength-1);

	if (sSearch.empty())
		return NULL;

	SetRedraw(FALSE);

	HTREEITEM hItemFound = TVI_ROOT;
	if (nRootLength && m_hRootedFolder)
		hItemFound = m_hRootedFolder;
	bool bDriveMatch = sRootFolder.empty();
	bool bNetworkMatch = m_bDisplayNetwork && ((sSearch.size() > 2) && sSearch.find(_T("\\\\")) == 0);
	if (bNetworkMatch)
	{
		bDriveMatch = false;

		//Working here
		bool bHasPlus = HasPlusButton(m_hNetworkRoot);
		bool bHasChildren = (GetChildItem(m_hNetworkRoot) != NULL);

		if (bHasPlus && !bHasChildren)
			DoExpand(m_hNetworkRoot);
		else
			Expand(m_hNetworkRoot, TVE_EXPAND);

		hItemFound = FindServersNode(m_hNetworkRoot);
		sSearch = sSearch.substr(2);
	}
	if (bDriveMatch)
	{
		if (m_hMyComputerRoot)
		{
			//Working here
			bool bHasPlus = HasPlusButton(m_hMyComputerRoot);
			bool bHasChildren = (GetChildItem(m_hMyComputerRoot) != NULL);

			if (bHasPlus && !bHasChildren)
				DoExpand(m_hMyComputerRoot);
			else
				Expand(m_hMyComputerRoot, TVE_EXPAND);

			hItemFound = m_hMyComputerRoot;
		}
	}

	int nFound = sSearch.find(_T('\\'));
	while(nFound != tstring::npos)
	{
		tstring sMatch;
		if (bDriveMatch)
		{
			sMatch = sSearch.substr(0, nFound + 1);
			bDriveMatch = false;
		}
		else
			sMatch = sSearch.substr(0, nFound);

		hItemFound = FindSibling(hItemFound, sMatch);
		if (hItemFound == NULL)
			break;
		else if (!IsDrive(sPath))
		{
			SelectItem(hItemFound);

			//Working here
			bool bHasPlus = HasPlusButton(hItemFound);
			bool bHasChildren = (GetChildItem(hItemFound) != NULL);

			if (bHasPlus && !bHasChildren)
				DoExpand(hItemFound);
			else
				Expand(hItemFound, TVE_EXPAND);
		}

		sSearch = sSearch.substr(nFound - 1);
		nFound = sSearch.find(_T('\\'));
	};

	//The last item
	if (hItemFound)
	{
		if (sSearch.size())
			hItemFound = FindSibling(hItemFound, sSearch);
		if (hItemFound)
			SelectItem(hItemFound);

		if (bExpanded)
		{
			//Working here
			bool bHasPlus = HasPlusButton(hItemFound);
			bool bHasChildren = (GetChildItem(hItemFound) != NULL);

			if (bHasPlus && !bHasChildren)
				DoExpand(hItemFound);
			else
				Expand(hItemFound, TVE_EXPAND);
		}
	}

	//Turn back on the redraw flag
	SetRedraw(TRUE);

	return hItemFound;
}
Esempio n. 18
0
BOOL CFileAndFolder::IsDrive(HTREEITEM hItem)
{
  return IsDrive(ItemToPath(hItem));
}
Esempio n. 19
0
void CTreeFileCtrl::OnUpdateFileDelete(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable(!IsDrive(GetSelectedItem()) && m_bAllowDelete);
}
Esempio n. 20
0
BOOL CDirstatDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	CDocument::OnNewDocument(); // --> DeleteContents()

	CString spec= lpszPathName;
	CString folder;
	CStringArray drives;
	DecodeSelection(spec, folder, drives);
	
	CStringArray rootFolders;
	if (drives.GetSize() > 0)
	{
		m_showMyComputer= (drives.GetSize() > 1);
		for (int i=0; i < drives.GetSize(); i++)
			rootFolders.Add(drives[i]);
	}
	else
	{
		ASSERT(!folder.IsEmpty());
		m_showMyComputer= false;
		rootFolders.Add(folder);
	}

	CArray<CItem *, CItem *> driveItems;

	if (m_showMyComputer)
	{
		m_rootItem= new CItem((ITEMTYPE)(IT_MYCOMPUTER|ITF_ROOTITEM), LoadString(IDS_MYCOMPUTER));
		for (int i=0; i < rootFolders.GetSize(); i++)
		{
			CItem *drive= new CItem(IT_DRIVE, rootFolders[i]);
			driveItems.Add(drive);
			m_rootItem->AddChild(drive);
		}
	}
	else
	{
		ITEMTYPE type= IsDrive(rootFolders[0]) ? IT_DRIVE : IT_DIRECTORY;
		m_rootItem= new CItem((ITEMTYPE)(type|ITF_ROOTITEM), rootFolders[0], false);
		if (m_rootItem->GetType() == IT_DRIVE)
			driveItems.Add(m_rootItem);
		m_rootItem->UpdateLastChange();
	}
	m_zoomItem= m_rootItem;

	for (int i=0; i < driveItems.GetSize(); i++)
	{
		if (OptionShowFreeSpace())
			driveItems[i]->CreateFreeSpaceItem();
		if (OptionShowUnknown())
			driveItems[i]->CreateUnknownItem();
	}

	SetWorkingItem(m_rootItem);

	GetMainFrame()->MinimizeGraphView();
	GetMainFrame()->MinimizeTypeView();

	UpdateAllViews(NULL, HINT_NEWROOT);
	return true;
}
Esempio n. 21
0
BOOL CTreeFileCtrl::IsDropSource(HTREEITEM hItem)
{
  return !IsDrive(hItem);
}
Esempio n. 22
0
BOOL CTreeFileCtrl::IsDrive(HTREEITEM hItem)
{
  return IsDrive(ItemToPath(hItem));
}