QVariant RecordingsModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
    {
        return QVariant();
    }

    auto fileInfo = mData[index.row()];

    switch (role)
    {
    case FilePath:
        return fileInfo.absoluteFilePath();
    case FileName:
        return fileInfo.fileName();
    case FileDir:
        return fileInfo.absolutePath();
    case Modified:
        return fileInfo.lastModified();
    case Section:
        return RecordingsModel::sectionName(fileInfo.lastModified().date());
    default:
        return QVariant();
    }
}
bool Foam::regIOobject::modified() const
{
    return
    (
        lastModified_
     && lastModified(filePath()) > (lastModified_ + fileModificationSkew)
    );
}
Beispiel #3
0
    void FrameBuffer::postCommit(RenderContext &)
    {
      bool removeToneMapper = false;
      bool toneMapperEnabled = false;
      if (hasChild("toneMapper")) {
        toneMapperEnabled = child("toneMapper").child("enabled").valueAs<bool>();
        if (toneMapperActive && !toneMapperEnabled)
          removeToneMapper = true;
      }
      // Avoid clearing the framebuffer when only tonemapping parameters have been changed
      if (lastModified() >= lastCommitted()
          || child("size").lastModified() >= lastCommitted()
          || child("displayWall").lastModified() >= lastCommitted()
          || child("useAccumBuffer").lastModified() >= lastCommitted()
          || child("useVarianceBuffer").lastModified() >= lastCommitted()
#ifdef OSPRAY_APPS_ENABLE_DENOISER
          || child("useDenoiser").lastModified() >= lastCommitted()
#endif
          || child("colorFormat").lastModified() >= lastCommitted()
          || removeToneMapper)
      {
        std::string displayWall = child("displayWall").valueAs<std::string>();
        this->displayWallStream = displayWall;

        updateFB();

        if (displayWall != "") {
          // TODO move into own sg::Node
          ospLoadModule("displayWald");
          OSPPixelOp pixelOp = ospNewPixelOp("display_wald");
          ospSetString(pixelOp, "streamName", displayWall.c_str());
          ospCommit(pixelOp);
          ospSetPixelOp(ospFrameBuffer, pixelOp);
          std::cout << "-------------------------------------------------------"
                    << std::endl;
          std::cout << "this is the display wall framebuffer .. size is "
                    << size() << std::endl;
          std::cout << "added display wall pixel op ..." << std::endl;

          std::cout << "created display wall pixelop, and assigned to frame buffer!"
                  << std::endl;
        }
        ospCommit(ospFrameBuffer);
      }

      if (toneMapperEnabled && !toneMapperActive) {
        ospSetPixelOp(ospFrameBuffer, child("toneMapper").valueAs<OSPPixelOp>());
        toneMapperActive = true;
      }
    }
Foam::Istream& Foam::regIOobject::readStream()
{
    if (IFstream::debug)
    {
        Info<< "regIOobject::readStream() : "
            << "reading object " << name()
            << " from file " << objectPath()
            << endl;
    }

    if (readOpt() == NO_READ)
    {
        FatalErrorIn("regIOobject::readStream()")
            << "NO_READ specified for read-constructor of object " << name()
            << " of class " << headerClassName()
            << abort(FatalError);
    }

    // Construct object stream and read header if not already constructed
    if (!isPtr_)
    {
        if (!(isPtr_ = objectStream()))
        {
            FatalIOError
            (
                "regIOobject::readStream()",
                __FILE__,
                __LINE__,
                objectPath(),
                0
            )   << "cannot open file"
                << exit(FatalIOError);
        }
        else if (!readHeader(*isPtr_))
        {
            FatalIOErrorIn("regIOobject::readStream()", *isPtr_)
                << "problem while reading header for object " << name()
                << exit(FatalIOError);
        }
    }

    if (!lastModified_)
    {
        lastModified_ = lastModified(filePath());
    }

    return *isPtr_;
}
bool Foam::regIOobject::readIfModified()
{
    if (lastModified_)
    {
        time_t newTimeStamp = lastModified(filePath());

        bool readFile = false;

        if (newTimeStamp > (lastModified_ + fileModificationSkew))
        {
            readFile = true;
        }

        if (Pstream::parRun())
        {
            bool readFileOnThisProc = readFile;
            reduce(readFile, andOp<bool>());

            if (readFileOnThisProc && !readFile)
            {
                WarningIn("regIOobject::readIfModified()")
                    << "Delaying reading " << name()
                    << " of class " << headerClassName()
                    << " due to inconsistent "
                       "file time-stamps between processors"
                    << endl;
            }
        }

        if (readFile)
        {
            lastModified_ = newTimeStamp;
            Info<< "regIOobject::readIfModified() : " << nl
                << "    Reading object " << name()
                << " from file " << filePath() << endl;
            return read();
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
Beispiel #6
0
bool File::lastAccessed(time_t accesstime)
{
# ifdef _WIN32
  HANDLE hf = CreateFile(pathname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
  if (hf == INVALID_HANDLE_VALUE)
    return false;
  FILETIME cft = ::NetworkTimeToFileTime(accesstime);
  BOOL bret = SetFileTime(hf, NULL, &cft, NULL);
  CloseHandle(hf);
  return bret == TRUE;    
# else
  utimbuf buf;
  buf.actime = (long)(accesstime / 1000);
  buf.modtime = (long)lastModified() / 1000;
  return ::utime(pathname, &buf) == 0;
# endif
}
Beispiel #7
0
//--------------------------------------------------------------------------------------------------
void generateResponse(int socket, char* filename, int lengthfile)
{
    
    char response[512];
    
    char *status = STATUS_200;
    char *server = "Server: FNU Pramono/1.0 (WIN 32)\r\n";
    
    char *connection_status = "Connection: closed\r\n";
    
    file_extension fe = determineTypeOfFile(filename);
    char *string_fe = changeExtensionToString (fe);
    
    strcpy(response, status);
    strcat(response, datetime());
    strcat(response, server);
    strcat(response, lastModified(filename));
    strcat(response, clength(lengthfile));
    strcat(response, string_fe);
    strcat(response, connection_status);
    
    printf("\n\nresponse: %s\n\n", response);
    
}
Beispiel #8
0
 bool Node::subtreeModifiedButNotCommitted() const
 {
   return (lastModified() > lastCommitted()) ||
          (childrenLastModified() > lastCommitted());
 }
Beispiel #9
0
bool Foam::regIOobject::writeObject
(
    IOstream::streamFormat fmt,
    IOstream::versionNumber ver,
    IOstream::compressionType cmp
) const
{
    if (!good())
    {
        SeriousErrorIn("regIOobject::write()")
            << "bad object " << name()
            << endl;

        return false;
    }

    if (instance().empty())
    {
        SeriousErrorIn("regIOobject::write()")
            << "instance undefined for object " << name()
            << endl;

        return false;
    }

    if
    (
        instance() != time().timeName()
     && instance() != time().system()
     && instance() != time().caseSystem()
     && instance() != time().constant()
     && instance() != time().caseConstant()
    )
    {
        const_cast<regIOobject&>(*this).instance() = time().timeName();
    }

    mkDir(path());

    if (OFstream::debug)
    {
        Info<< "regIOobject::write() : "
            << "writing file " << objectPath();
    }


    bool osGood = false;

    {
        // Try opening an OFstream for object
        OFstream os(objectPath(), fmt, ver, cmp);

        // If any of these fail, return (leave error handling to Ostream class)
        if (!os.good())
        {
            return false;
        }

        if (!writeHeader(os))
        {
            return false;
        }

        // Write the data to the Ostream
        if (!writeData(os))
        {
            return false;
        }

        writeEndDivider(os);

        osGood = os.good();
    }

    if (OFstream::debug)
    {
        Info<< " .... written" << endl;
    }

    // Only update the lastModified_ time if this object is re-readable,
    // i.e. lastModified_ is already set
    if (lastModified_)
    {
        lastModified_ = lastModified(objectPath());
    }

    return osGood;
}
void RecordingsModel::scanRecords(const QString &path)
{
    Q_ASSERT(mRecorder);

    // Current watching directories
    auto currentDirs = mWatcher->directories();

    // Is the recursive search enabled
    auto recursiveSearch = mRecorder->recursiveSearch();

    // Check if directory exists and add or remove it and
    // its subdirectories to the wathing list
    QDir dir(path);
    QStringList paths(path);
    if (dir.exists())
    {
        // Check for subdirectories that should be added
        if (recursiveSearch)
        {
            QDirIterator it(path, QDir::Dirs, QDirIterator::Subdirectories);
            while (it.hasNext())
            {
                paths << it.next();
            }
        }
        mWatcher->addPaths(paths);
    }
    else
    {
        // Check for subdirectories that should be removed
        for (auto d: currentDirs)
        {
            if (d.startsWith(path))
            {
                paths << d;
            }
        }
        mWatcher->removePaths(paths);
    }

    // Scan for updated and removed records
    for (int row = mData.size() - 1; row > -1; --row)
    {
        auto oldFileInfo = mData[row];
        // Process entries only of the changed path
        if (oldFileInfo.absolutePath() != path)
        {
            continue;
        }
        QFileInfo newFileInfo(oldFileInfo);
        newFileInfo.refresh();
        if (newFileInfo.exists())
        {
            if (newFileInfo.lastModified() != oldFileInfo.lastModified())
            {
                // The record was updated
                auto index = this->createIndex(row, 0);
                emit this->dataChanged(index, index, { Modified });
            }
        }
        else
        {
            // The record was removed
            this->beginRemoveRows(QModelIndex(), row, row);
            mData.removeAt(row);
            this->endRemoveRows();
        }
    }

    // Scan for new records
    auto flags = recursiveSearch ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags;
    QDirIterator it(path, RecordingsModel::filters, QDir::Files, flags);
    QFileInfoList newRecords;
    while (it.hasNext())
    {
        // Add a new record
        QFileInfo fileInfo(it.next());
        if (!mData.contains(fileInfo))
        {
            newRecords << fileInfo;
        }
    }
    if (!newRecords.empty())
    {
        auto pos = mData.size();
        this->beginInsertRows(QModelIndex(), pos, pos + newRecords.size() - 1);
        mData.append(newRecords);
        this->endInsertRows();
    }
}
Beispiel #11
0
bool Settings::hasChanged() const
{
   return(m_PreviouslyLastModified < lastModified());
}
Beispiel #12
0
void Settings::clearChanged()
{
   m_PreviouslyLastModified = lastModified();
}
Beispiel #13
0
Settings::Settings() : m_Settings(configureQSettings()), m_PreviouslyLastModified(lastModified())
{
}