Exemplo n.º 1
0
void TrashImpl::migrateOldTrash()
{
    kdDebug() << k_funcinfo << endl;
    const TQString oldTrashDir = TDEGlobalSettings::trashPath();
    const TQStrList entries = listDir( oldTrashDir );
    bool allOK = true;
    TQStrListIterator entryIt( entries );
    for (; entryIt.current(); ++entryIt) {
        TQString srcPath = TQFile::decodeName( *entryIt );
        if ( srcPath == "." || srcPath == ".." || srcPath == ".directory" )
            continue;
        srcPath.prepend( oldTrashDir ); // make absolute
        int trashId;
        TQString fileId;
        if ( !createInfo( srcPath, trashId, fileId ) ) {
            kdWarning() << "Trash migration: failed to create info for " << srcPath << endl;
            allOK = false;
        } else {
            bool ok = moveToTrash( srcPath, trashId, fileId );
            if ( !ok ) {
                (void)deleteInfo( trashId, fileId );
                kdWarning() << "Trash migration: failed to create info for " << srcPath << endl;
                allOK = false;
            } else {
                kdDebug() << "Trash migration: moved " << srcPath << endl;
            }
        }
    }
    if ( allOK ) {
        // We need to remove the old one, otherwise the desktop will have two trashcans...
        kdDebug() << "Trash migration: all OK, removing old trash directory" << endl;
        synchronousDel( oldTrashDir, false, true );
    }
}
void CommandHistoryWindow::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
	bool drawDull = false;
	size_t index = 0;

	states.transform *= getTransform();
	target.draw(m_rectangle, states);

	for(std::list<CommandHistoryEntry>::const_iterator entryIt(m_commandList.begin()); entryIt != m_commandList.end(); entryIt++)
	{
		if(entryIt == m_iterator)
		{
			target.draw(m_selectedRectangle, states);
			sf::Text text = m_selectedText;
			text.setString(entryIt->m_text);
			target.draw(text, states);
			drawDull = true;
		}
		else if(drawDull)
		{
			target.draw(m_dullRectangle, states);
			sf::Text text = m_dullText;
			text.setString(entryIt->m_text);
			target.draw(text, states);
		}
		else
		{
			target.draw(m_normalRectangle, states);
			sf::Text text = m_normalText;
			text.setString(entryIt->m_text);
			target.draw(text, states);
		}


		index++;
		states.transform.translate(0, m_entrySize.y);
		//target.draw(entryIt->m_rectangle, states);
	}
}
Exemplo n.º 3
0
TrashImpl::TrashedFileInfoList TrashImpl::list()
{
    // Here we scan for trash directories unconditionally. This allows
    // noticing plugged-in [e.g. removeable] devices, or new mounts etc.
    scanTrashDirectories();

    TrashedFileInfoList lst;
    // For each known trash directory...
    TrashDirMap::const_iterator it = m_trashDirectories.begin();
    for ( ; it != m_trashDirectories.end() ; ++it ) {
        const int trashId = it.key();
        TQString infoPath = it.data();
        infoPath += "/info";
        // Code taken from tdeio_file
        TQStrList entryNames = listDir( infoPath );
        //char path_buffer[PATH_MAX];
        //getcwd(path_buffer, PATH_MAX - 1);
        //if ( chdir( infoPathEnc ) )
        //    continue;
        TQStrListIterator entryIt( entryNames );
        for (; entryIt.current(); ++entryIt) {
            TQString fileName = TQFile::decodeName( *entryIt );
            if ( fileName == "." || fileName == ".." )
                continue;
            if ( !fileName.endsWith( ".trashinfo" ) ) {
                kdWarning() << "Invalid info file found in " << infoPath << " : " << fileName << endl;
                continue;
            }
            fileName.truncate( fileName.length() - 10 );

            TrashedFileInfo info;
            if ( infoForFile( trashId, fileName, info ) )
                lst << info;
        }
    }
    return lst;
}
Exemplo n.º 4
0
void TrashProtocol::listDir(const KURL &url)
{
    INIT_IMPL;
    kdDebug() << "listdir: " << url << endl;
    if(url.path().length() <= 1)
    {
        listRoot();
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL(url, trashId, fileId, relativePath);
    if(!ok)
    {
        error(KIO::ERR_SLAVE_DEFINED, i18n("Malformed URL %1").arg(url.prettyURL()));
        return;
    }
    // was: const QString physicalPath = impl.physicalPath( trashId, fileId, relativePath );

    // Get info for deleted directory - the date of deletion and orig path will be used
    // for all the items in it, and we need the physicalPath.
    TrashedFileInfo info;
    ok = impl.infoForFile(trashId, fileId, info);
    if(!ok || info.physicalPath.isEmpty())
    {
        error(impl.lastErrorCode(), impl.lastErrorMessage());
        return;
    }
    if(!relativePath.isEmpty())
    {
        info.physicalPath += "/";
        info.physicalPath += relativePath;
    }

    // List subdir. Can't use kio_file here since we provide our own info...
    kdDebug() << k_funcinfo << "listing " << info.physicalPath << endl;
    QStrList entryNames = impl.listDir(info.physicalPath);
    totalSize(entryNames.count());
    KIO::UDSEntry entry;
    QStrListIterator entryIt(entryNames);
    for(; entryIt.current(); ++entryIt)
    {
        QString fileName = QFile::decodeName(entryIt.current());
        if(fileName == "..")
            continue;
        const QString filePath = info.physicalPath + "/" + fileName;
        // shouldn't be necessary
        // const QString url = TrashImpl::makeURL( trashId, fileId, relativePath + "/" + fileName );
        entry.clear();
        TrashedFileInfo infoForItem(info);
        infoForItem.origPath += '/';
        infoForItem.origPath += fileName;
        if(ok && createUDSEntry(filePath, fileName, QString::null /*url*/, entry, infoForItem))
        {
            listEntry(entry, false);
        }
    }
    entry.clear();
    listEntry(entry, true);
    finished();
}