Ejemplo n.º 1
0
FileReference toFileReference(const QVariant& variant, const VersionString& version) {
    QVariantMap map = variant.toMap();
    OptionalDateTime timestampCreate, timestampLast;
    if (version < VersionString("1.0.4")) {
        timestampCreate = DateTime(map["timestamp_create"].toString().toStdString());
        timestampLast = DateTime(map["timestamp_last"].toString().toStdString());
    }
    else {
        timestampCreate = DateTime::fromISO8601(map["timestamp_create"].toString().toStdString());
        timestampLast = DateTime::fromISO8601(map["timestamp_last"].toString().toStdString());
    }
    OS_ASSERT(timestampCreate);
    OS_ASSERT(timestampLast);
    return FileReference(toUUID(map["uuid"].toString().toStdString()),
                         toUUID(map["version_uuid"].toString().toStdString()),
                         map.contains("name") ? map["name"].toString().toStdString() : std::string(),
                         map.contains("display_name") ? map["display_name"].toString().toStdString() : std::string(),
                         map.contains("description") ? map["description"].toString().toStdString() : std::string(),
                         toPath(map["path"].toString()),
                         FileReferenceType(map["file_type"].toString().toStdString()),
                         timestampCreate.get(),
                         timestampLast.get(),
                         map["checksum_create"].toString().toStdString(),
                         map["checksum_last"].toString().toStdString());
}
Ejemplo n.º 2
0
FileReference::FileReference(const openstudio::path& p)
  : m_uuid(createUUID()),
    m_versionUUID(createUUID()),
    m_name(toString(p)),
    m_displayName(toString(p.filename())),
    m_path(completeAndNormalize(p)),
    m_timestampLast(),
    m_checksumCreate(checksum(m_path)),
    m_checksumLast(m_checksumCreate)
{
  try {
    m_fileType = FileReferenceType(getFileExtension(p));
  }
  catch (...) {
    m_fileType = FileReferenceType::Unknown;
  }
  update(openstudio::path());
}