Ejemplo n.º 1
0
static void getWritePaths(Paths& paths)
{
	paths.push_back(PathInfo(SlPaths::GetLobbyWriteDir(), "LobbyWriteDir", true));
	paths.push_back(PathInfo(SlPaths::GetCachePath(), "CachePath", true));
	paths.push_back(PathInfo(SlPaths::GetExecutableFolder(), "ExecutableFolder", false));
	paths.push_back(PathInfo(SlPaths::GetDownloadDir(), "DownloadDir", true));
	paths.push_back(PathInfo(SlPaths::GetDataDir(), "Current SpringData:", true));
}
Ejemplo n.º 2
0
bool clsPathValidator::validate(const intfConfigurable &_item, QString &_errorMessage)
{
    QString Path = _item.toVariant().toString();
    QFileInfo PathInfo(Path);

    if (this->RequiredAccess.testFlag(PathAccess::Dir) && PathInfo.isDir() == false){
        _errorMessage = _item.configPath() + ": <"+Path+"> must be a directory";
        return false;
    }else if (this->RequiredAccess.testFlag(PathAccess::File) && PathInfo.isFile() == false){
        _errorMessage = _item.configPath() + ": <"+Path+"> must be a file";
        return false;
    }
    if (this->RequiredAccess.testFlag(PathAccess::Executable) && PathInfo.isExecutable() == false){
        _errorMessage = _item.configPath() + ": <"+Path+"> must be executable";
        return false;
    }

    if (this->RequiredAccess.testFlag(PathAccess::Readable) && PathInfo.isReadable() == false){
        _errorMessage = _item.configPath() + ": Unable to open <"+Path+"> for READING";
        return false;
    }
    if (this->RequiredAccess.testFlag(PathAccess::Writeatble) && PathInfo.isWritable() == false){
        _errorMessage = _item.configPath() + ": Unable to open <"+Path+"> for WRITING";
        return false;
    }
    _errorMessage.clear();
    return true;
}
Ejemplo n.º 3
0
/*!
    Store a path command in the command list
    \sa QPaintEngine::drawPath()
*/
void QwtGraphic::drawPath( const QPainterPath &path )
{
    const QPainter *painter = paintEngine()->painter();
    if ( painter == NULL )
        return;

    d_data->commands += QwtPainterCommand( path );

    if ( !path.isEmpty() )
    {
        const QPainterPath scaledPath = painter->transform().map( path );

        QRectF pointRect = scaledPath.boundingRect();
        QRectF boundingRect = pointRect;

        if ( painter->pen().style() != Qt::NoPen 
            && painter->pen().brush().style() != Qt::NoBrush )
        {
            boundingRect = qwtStrokedPathRect( painter, path );
        }

        updateControlPointRect( pointRect );
        updateBoundingRect( boundingRect );

        d_data->pathInfos += PathInfo( pointRect, 
            boundingRect, qwtHasScalablePen( painter ) );
    }
}
static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInfo &fileInfo,
                          const QString &path)
{
    PathInfoList &list = pathHash[key];
    list.push_back(PathInfo(path,
                            fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_D).toUtf8()));
    pathHash.insert(key, list);
}
Ejemplo n.º 5
0
    // Reads all materials from the materials assets folder.
    MaterialManager()
    {
      // Gather info about the path to the materials folder.
      auto pathInfo = PathInfo(config::Materials);
      if (!pathInfo.Valid() || pathInfo.Files().empty()) return;

      // Iterate over files in the materials folder.
      for (const string& file : pathInfo.Files())
      {
        // Emplace the material in the object map.
        auto fileInfo = PathInfo(file);
        string lowercaseName = fileInfo.BaseFilename();
        transform(lowercaseName.begin(), lowercaseName.end(), lowercaseName.begin(), tolower);
        objects.emplace(lowercaseName, lowercaseName);
      }

      objects.emplace("", string("default"));
    }
Ejemplo n.º 6
0
void path_points::StartPL(m2::PointD const & pt)
{
  EndPL();

  m_points.push_back(PathInfo(m_length + m_prev.Length(pt)));
  push_point(pt);

  m_newPL = false;
}
Ejemplo n.º 7
0
bool C4Reloc::AddPath(const char* path, PathType pathType)
{
	if(!IsGlobalPath(path))
		return false;

	if(std::find(Paths.begin(), Paths.end(), path) != Paths.end())
		return false;

	Paths.push_back(PathInfo(StdCopyStrBuf(path), pathType));
	return true;
}
Ejemplo n.º 8
0
    // Initializes FMOD Studio and loads all sound banks.
    Audio() :
      Listener(system)
    {
      // Create the FMOD Studio system.
      FmodCall(fmod::System::create(&system));
      // Initialize the system.
      FmodCall(system->initialize(
        maxChannels,               // max channels capable of playing audio
        FMOD_STUDIO_INIT_NORMAL,   // studio-specific flags
        FMOD_INIT_3D_RIGHTHANDED,  // regular flags
        nullptr));                 // extra driver data

      vector<fmod::Bank*> banks;

      // For each file in the Sounds directory with a *.bank extension:
      for (const string& file : PathInfo(config::Sounds).FilesWithExtension("bank"))
      {
        // Load the sound bank from file.
        fmod::Bank* bank = nullptr;
        FmodCall(system->loadBankFile(file.c_str(), FMOD_STUDIO_LOAD_BANK_NORMAL, &bank));

        banks.push_back(bank);
      }

      for (fmod::Bank* bank : banks)
      {
        // Get the number of events in the bank.
        int eventCount = 0;
        FmodCall(bank->getEventCount(&eventCount));
        if (eventCount == 0) continue;

        // Get the list of event descriptions from the bank.
        auto eventArray = vector<fmod::EventDescription*>(static_cast<size_t>(eventCount), nullptr);
        FmodCall(bank->getEventList(eventArray.data(), eventArray.size(), nullptr));

        // For each event description:
        for (fmod::EventDescription* eventDescription : eventArray)
        {
          // Get the path to the event, e.g. "event:/Ambience/Country"
          auto path = string(512, ' ');
          int retrieved = 0;
          FmodCall(eventDescription->getPath(&path[0], path.size(), &retrieved));
          path.resize(static_cast<size_t>(retrieved - 1)); // - 1 to account for null character

          // Save the event description in the event map.
          eventDescriptionMap.emplace(path, EventDescription(eventDescription, path));
        }
      }

      Note(*this);
    }
Ejemplo n.º 9
0
	void TrackableDownloadItem::onAddedQueue(const string& aPath, int64_t aSize) noexcept {
		bool first = false;

		{
			WLock l(cs);
			first = downloads.empty();
			downloads.emplace(aPath, PathInfo(aSize));
		}

		if (first) {
			DownloadManager::getInstance()->addListener(this);
		}

		onStateChanged();
	}
Ejemplo n.º 10
0
void cut_path_intervals::operator()(m2::PointD const & pt)
{
  if (m_hasPrevPt)
  {
    double const segLen = pt.Length(m_prev);

    for (; m_pos != m_intervals->size(); m_pos += 2)
    {
      double const start = (*m_intervals)[m_pos];
      if (start >= m_length + segLen)
        break;

      m2::PointD const dir = (pt - m_prev) / segLen;

      if (start >= m_length)
      {
        m_points.push_back(PathInfo(start));
        push_point(m_prev + dir * (start - m_length));
      }

      double const end = (*m_intervals)[m_pos+1];
      if (end >= m_length + segLen)
      {
        push_point(pt);
        break;
      }

      if (end < m_length + segLen)
      {
        push_point(m_prev + dir * (end - m_length));
#ifdef DEBUG
        double const len = m_points.back().GetLength();
        ASSERT_LESS_OR_EQUAL ( fabs(len - (end - start)), 1.0E-4, (len, end - start) );
#endif
      }
    }

    m_prev = pt;
    m_length += segLen;
  }
  else
  {
    m_hasPrevPt = true;
    m_prev = pt;
  }
}
Ejemplo n.º 11
0
   bool tmplPathAccessValidator (const intfConfigurable& _item,
                                  QString& _errorMessage){
        if (_required == false &&
            _item.toVariant().toString().isEmpty() &&
            _item.wasConfigured() == false)
            return true;

        QString Path = _item.toVariant().toString();
        QFileInfo PathInfo(Path);

        if (Targoman::Common::testFlag(_requiredAccess, Targoman::Common::enuPathAccess::Dir) &&
                (PathInfo.exists() == false || PathInfo.isDir() == false)){
            _errorMessage = _item.configPath() + ": <"+Path+"> must be a directory";
            return false;
        }else if (Targoman::Common::testFlag(_requiredAccess, Targoman::Common::enuPathAccess::File) &&
                  (PathInfo.exists() == false || PathInfo.isFile() == false)){
            _errorMessage = _item.configPath() + ": <"+Path+"> must be a file";
            return false;
        }
        if (Targoman::Common::testFlag(_requiredAccess, Targoman::Common::enuPathAccess::Executable) &&
                PathInfo.isExecutable() == false){
            _errorMessage = _item.configPath() + ": <"+Path+"> must be executable";
            return false;
        }

        if (Targoman::Common::testFlag(_requiredAccess, Targoman::Common::enuPathAccess::Readable) &&
                PathInfo.isReadable() == false){
            _errorMessage = _item.configPath() + ": Unable to open <"+Path+"> for READING";
            return false;
        }
        if (Targoman::Common::testFlag(_requiredAccess, Targoman::Common::enuPathAccess::Writeatble)){
            if (PathInfo.exists() == false){
                if (QFileInfo(PathInfo.path()).isWritable() == false){
                    _errorMessage = _item.configPath() + ": Unable to create <"+Path+">";
                    return false;
                }
            }else if (PathInfo.isWritable() == false){
                _errorMessage = _item.configPath() + ": Unable to open <"+Path+"> for WRITING";
                return false;
            }
        }
        _errorMessage.clear();

        return true;
    }