Ejemplo n.º 1
0
void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector& items)
{
    std::map<QString, SyncFileStatus::SyncFileStatusTag> oldProblems;
    std::swap(_syncProblems, oldProblems);

    foreach (const SyncFileItemPtr &item, items) {
        // qDebug() << Q_FUNC_INFO << "Investigating" << item->destination() << item->_status;

        if (showErrorInSocketApi(*item)) {
            _syncProblems[item->_file] = SyncFileStatus::StatusError;
        } else if (showWarningInSocketApi(*item)) {
            _syncProblems[item->_file] = SyncFileStatus::StatusWarning;
        }
        emit fileStatusChanged(getSystemDestination(item->destination()), syncFileItemStatus(*item));
    }

    // Make sure to push any status that might have been resolved indirectly since the last sync
    // (like an error file being deleted from disk)
    for (auto it = _syncProblems.begin(); it != _syncProblems.end(); ++it)
        oldProblems.erase(it->first);
    for (auto it = oldProblems.begin(); it != oldProblems.end(); ++it) {
        const QString &path = it->first;
        SyncFileStatus::SyncFileStatusTag severity = it->second;
        if (severity == SyncFileStatus::StatusError)
            invalidateParentPaths(path);
        emit fileStatusChanged(getSystemDestination(path), fileStatus(path));
    }
}
// Return time of last file modification
time_t lastModified(const fileName& name)
{
    fileStat fileStatus(name);

    const time_t modifiedTime = fileStatus.isValid() ?
                                fileStatus.status().st_mtime : 0;
    return modifiedTime;
}
// Return size of file
off_t fileSize(const fileName& name)
{
    fileStat fileStatus(name);

    const off_t fileSize = fileStatus.isValid() ?
                           fileStatus.status().st_size : -1;
    return fileSize;
}
// Return the file mode
mode_t mode(const fileName& name)
{
    fileStat fileStatus(name);

    const mode_t m = fileStatus.isValid() ?
                     fileStatus.status().st_mode : 0;
    return m;
}
Ejemplo n.º 5
0
void SyncFileStatusTracker::invalidateParentPaths(const QString& path)
{
    QStringList splitPath = path.split('/', QString::SkipEmptyParts);
    for (int i = 0; i < splitPath.size(); ++i) {
        QString parentPath = QStringList(splitPath.mid(0, i)).join(QLatin1String("/"));
        emit fileStatusChanged(getSystemDestination(parentPath), fileStatus(parentPath));
    }
}
Ejemplo n.º 6
0
// Return time of last file modification
time_t Foam::lastModified(const fileName& name)
{
    fileStat fileStatus(name);
    if (fileStatus.isValid())
    {
        return fileStatus.status().st_mtime;
    }
    else
    {
        return 0;
    }
}
Ejemplo n.º 7
0
// Return size of file
off_t Foam::fileSize(const fileName& name)
{
    fileStat fileStatus(name);
    if (fileStatus.isValid())
    {
        return fileStatus.status().st_size;
    }
    else
    {
        return -1;
    }
}
Ejemplo n.º 8
0
// Return the file mode
mode_t Foam::mode(const fileName& name)
{
    fileStat fileStatus(name);
    if (fileStatus.isValid())
    {
        return fileStatus.status().st_mode;
    }
    else
    {
        return 0;
    }
}
Ejemplo n.º 9
0
void DocumentFile::setProposedFilename(QString filename)
{
    Q_ASSERT(fileStatus() == FileStatus_NotCreated);
    d->filename = filename;
    emit fileStatusChanged();
}