Пример #1
0
AbcObjectCache* getObjectCacheFromArchive(std::string const& path, std::string const& identifier)
{
	AbcArchiveCache* abcArchiveCache = getArchiveCache( resolvePath( path ) );
	if( abcArchiveCache == NULL ) {
		return NULL;
	}
	AbcArchiveCache::iterator it = abcArchiveCache->find( identifier );
	if( it == abcArchiveCache->end() ) {
		return NULL;
	}
	return &(it->second);
}
Пример #2
0
bool Info::isImage(const String &path, size_t &width, size_t &height, const String &root) const {
	auto str = resolvePath(path, root);
	auto it = _manifest.find(str);
	if (it != _manifest.end()) {
		if (it->second.type == ManifestFile::Type::Image) {
			width = it->second.width;
			height = it->second.height;
			return true;
		}
	}
	return false;
}
Пример #3
0
void fn_cat (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   string filename = *(words.end()-1);
   inode_ptr ogcwd = state.getCwd();
   inode_ptr res = resolvePath(words[1], state.getCwd());
   if (res == nullptr){
      throw command_error ("cat: " + filename + ": file does not exist");
      return; }
   if (res->isDirectory()) return; //error here
   cout << res->getContents()->readfile() << endl;
}
Пример #4
0
    void KukieControlQueue::computeCurrentCartPose() {

        if(!kinematicsInitialized) {

            kin = KUKADU_SHARED_PTR<Kinematics>(new KomoPlanner(shared_from_this(),
                                                                     resolvePath("$KUKADU_HOME/external/komo/share/data/kuka/data/iis_robot.kvg"),
                                                                     resolvePath("$KUKADU_HOME/external/komo/share/data/kuka/config/MT.cfg"),
                                                                     getRobotSidePrefix(), acceptCollisions));
            kinematicsInitialized = true;

        }

        while(getQueueRunning()) {

            forwadKinMutex.lock();
                currCarts = kin->computeFk(armadilloToStdVec(getCurrentJoints().joints));
            forwadKinMutex.unlock();

        }

    }
int FilesystemManager::unlinkHelper(string& path)
{
    //Do everything while keeping the mutex locked to prevent someone to
    //concurrently mount a filesystem on the directory we're unlinking
    Lock<FastMutex> l(mutex);
    ResolvedPath openData=resolvePath(path,true);
    if(openData.result<0) return openData.result;
    //After resolvePath() so path is in canonical form and symlinks are followed
    if(filesystems.find(StringPart(path))!=filesystems.end()) return -EBUSY;
    StringPart sp(path,string::npos,openData.off);
    return openData.fs->unlink(sp);
}
Пример #6
0
    void KukieControlQueue::cartPtpInternal(geometry_msgs::Pose pos, double maxForce) {

        cartesianPtpReached = false;

        komoMutex.lock();
            if(!plannerInitialized) {

                planner = KUKADU_SHARED_PTR<PathPlanner>(new KomoPlanner(shared_from_this(),
                                                                         resolvePath("$KUKADU_HOME/external/komo/share/data/kuka/data/iis_robot.kvg"),
                                                                         resolvePath("$KUKADU_HOME/external/komo/share/data/kuka/config/MT.cfg"),
                                                                         getRobotSidePrefix(), acceptCollisions));
                plannerInitialized = true;
            }

            vector<geometry_msgs::Pose> desiredPlan;
            desiredPlan.push_back(getCurrentCartesianPose());
            desiredPlan.push_back(pos);
            vector<vec> desiredJointPlan = planner->planCartesianTrajectory(desiredPlan, false, true);

        komoMutex.unlock();

        bool maxForceExceeded = false;
        if(desiredJointPlan.size() > 0) {

            for(int i = 0; i < desiredJointPlan.size() && !maxForceExceeded; ++i) {

                if(getAbsoluteCartForce() > maxForce)
                    maxForceExceeded = true;
                else
                    addJointsPosToQueue(desiredJointPlan.at(i));
                synchronizeToControlQueue(1);

            }

        } else {
            ROS_ERROR("(KukieControlQueue) Cartesian position not reachable");
        }

    }
void deleteArchive(std::string const& path)
{
  ESS_PROFILE_SCOPE("deleteArchive");
  std::string resolvedPath = resolvePath(path);
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) return;

  EC_LOG_INFO("Closing Abc Archive: " << it->second.archive->getName());
  it->second.archive->reset();
  delete (it->second.archive);
  gArchives.erase(it);
}
int decRefArchive(std::string const& path)
{
  ESS_PROFILE_SCOPE("decRefArchive");
  std::string resolvedPath = resolvePath(path);
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) return -1;
  it->second.refCount--;
#ifdef _DEBUG
  EC_LOG_INFO("ref count (d): " << it->second.refCount);
#endif
  return it->second.refCount;
}
int FilesystemManager::renameHelper(string& oldPath, string& newPath)
{
    //Do everything while keeping the mutex locked to prevent someone to
    //concurrently mount a filesystem on the directory we're renaming
    Lock<FastMutex> l(mutex);
    ResolvedPath oldOpenData=resolvePath(oldPath,true);
    if(oldOpenData.result<0) return oldOpenData.result;
    ResolvedPath newOpenData=resolvePath(newPath,true);
    if(newOpenData.result<0) return newOpenData.result;
    
    if(oldOpenData.fs!=newOpenData.fs) return -EXDEV; //Can't rename across fs
    
    //After resolvePath() so path is in canonical form and symlinks are followed
    if(filesystems.find(StringPart(oldPath))!=filesystems.end()) return -EBUSY;
    if(filesystems.find(StringPart(newPath))!=filesystems.end()) return -EBUSY;
    
    StringPart oldSp(oldPath,string::npos,oldOpenData.off);
    StringPart newSp(newPath,string::npos,newOpenData.off);
    
    //Can't rename a directory into a subdirectory of itself
    if(newSp.startsWith(oldSp)) return -EINVAL;
    return oldOpenData.fs->rename(oldSp,newSp);
}
Пример #10
0
bool MpqArchive::writeFile(const QString &name, const QString &user, const QString &group, const char *data, qint64 size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
{
	iarraystream stream(data, size);
	BOOST_SCOPED_ENUM(mpq::MpqFile::Locale) locale;
	BOOST_SCOPED_ENUM(mpq::MpqFile::Platform) platform;
	QString path(resolvePath(name, locale, platform));
	// TODO Change!
	//mpq::MpqFile *file = m_mpq->addFile(path.toUtf8().constData(), locale, platform, &stream);

	//if (file == 0)
		//return false;

	return true;
}
Пример #11
0
bool MpqArchive::doWriteSymLink(const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
{
	iarraystream stream(target.toUtf8().constData(), target.toUtf8().size());
	BOOST_SCOPED_ENUM(mpq::MpqFile::Locale) locale;
	BOOST_SCOPED_ENUM(mpq::MpqFile::Platform) platform;
	QString path(resolvePath(name, locale, platform));
	// TODO FIXME
	//mpq::MpqFile *file = m_mpq->addFile(path.toUtf8().constData(), locale, platform, &stream);

	//if (file == 0)
		//return false;

	return true;
}
Пример #12
0
bool MpqArchive::doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
{
	BOOST_SCOPED_ENUM(mpq::MpqFile::Locale) locale;
	BOOST_SCOPED_ENUM(mpq::MpqFile::Platform) platform;
	QString path(resolvePath(name, locale, platform));
	mpq::MpqFile *file = this->m_mpq->findFile(path.toUtf8().constData(), locale, platform);

	if (file == 0 || file->size() < size)
		return false;

	m_mpqFile = file;

	return true;
}
Пример #13
0
void fn_cd (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   inode_ptr ogcwd = state.getCwd();
   if (words.size() == 1){
      state.setCwd(state.getRoot()->getContents()->getNode("/"));
      return;
   }
   if (words.size() > 2) return;
   if (ogcwd == state.getRoot()->getContents()->getNode("/") && words[1] == "..") return;
   inode_ptr res = resolvePath(words[1], state.getCwd());
   if (res == nullptr) return;
   if (!res->isDirectory()) return;
   state.setCwd(res);
}
Пример #14
0
// NOTE: The load() command is similar to the include() command except that it loads the script
// as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which
// the Application or other context will connect to in order to know to actually load the script
void ScriptEngine::load(const QString& loadFile) {
    if (_stoppingAllScripts) {
        qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "
                 << "loadFile:" << loadFile << "parent script:" << getFilename();
        return; // bail early
    }

    QUrl url = resolvePath(loadFile);
    if (_isReloading) {
        auto scriptCache = DependencyManager::get<ScriptCache>();
        scriptCache->deleteScript(url.toString());
        emit reloadScript(url.toString(), false);
    } else {
        emit loadScript(url.toString(), false);
    }
}
Пример #15
0
void fn_ls (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   inode_ptr ogcwd = state.getCwd();
   inode_ptr res = ogcwd;
   if(words.size() > 1)
      res = resolvePath(words[1], state.getCwd());
   if (res == nullptr) return;
   auto pathList = res->getContents()->getAllPaths();
   state.setCwd(res);
   fn_pwd(state, words);
   for (size_t i = 0; i < pathList.size(); i++){
      cout << pathList[i] << endl;
   }
   state.setCwd(ogcwd);
}
Пример #16
0
void searchJavaSystemLocations(LauncherProperties * props) {
    if ( props->jvms->size > 0 ) {
        DWORD i=0;
        writeMessageA(props, OUTPUT_LEVEL_NORMAL, 0, "Search jvm using some predefined locations", 1);
        for(i=0;i<props->jvms->size && !isTerminated(props);i++) {
            resolvePath(props, props->jvms->items[i]);
            if(props->jvms->items[i]->type!=0) { // bundled JVMs are already checked
                trySetCompatibleJava(props->jvms->items[i]->resolved, props);
                if(props->java!=NULL) {
                    break;
                }
            }
        }
        
    }
}
Пример #17
0
result_t SandBox::require(const char *id, v8::Local<v8::Value> &retVal)
{
    std::string fname = resolvePath(id);
    std::map<std::string, VariantEx >::iterator it;

    // remove .js ext name if exists
    if (fname.length() > 3 && !qstrcmp(&fname[fname.length() - 3], ".js"))
        fname.resize(fname.length() - 3);

    it = m_mods.find(fname);

    if (it != m_mods.end())
    {
        retVal = it->second;
        return 1;
    }

    if (!m_require.IsEmpty())
    {
        v8::Local<v8::Value> arg = v8::String::NewFromUtf8(isolate, fname.c_str());
        retVal = v8::Local<v8::Function>::New(isolate, m_require)->Call(wrap(), 1, &arg);
        if (retVal.IsEmpty())
            return CALL_E_JAVASCRIPT;

        if (!IsEmpty(retVal))
        {
            if (retVal->IsObject() && !object_base::getInstance(retVal))
                retVal = retVal->ToObject()->Clone();
            InstallModule(fname, retVal);

            return 0;
        }
    }

    // append .js ext name
    fname += ".js";

    result_t hr;
    const char *pname = fname.c_str();

    std::string buf;
    hr = fs_base::ac_readFile(pname, buf);
    if (hr < 0)
        return hr;

    return addScript(pname, buf.c_str(), retVal);
}
Пример #18
0
int addRefArchive(std::string const& path)
{
  ESS_PROFILE_SCOPE("addRefArchive");
  if (path.empty()) return -1;
  std::string resolvedPath = resolvePath(path);

  // call get archive to ensure to create it!
  getArchiveFromID(path);
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) return -1;
  it->second.refCount++;
#ifdef _DEBUG
  EC_LOG_INFO("ref count (a): " << it->second.refCount);
#endif
  return it->second.refCount;
}
Пример #19
0
Texture *SceneParser::loadTexture(KeyValues *data)
{
  const char* identifier = data->getString("identifier");
  if(!identifier) {
    fprintf(stderr, "Key 'identifier' not found on Texture\n");
    return NULL;
  }

  const char *file = data->getString("file");
  if(!file) {
    fprintf(stderr, "Key 'file' not found on Texture\n");
    return NULL;
  }
  char *filename = resolvePath(file);

  return new Texture(filename, identifier);
}
Пример #20
0
void fn_lsr (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);

   inode_ptr ogcwd = state.getCwd();
   inode_ptr newCwd = ogcwd;
   if (words.size() > 0){
      newCwd = resolvePath(words[1], state.getCwd());
      state.setCwd(newCwd);
   }
   auto pathList = newCwd->getContents()->getAllDirs();
   wordvec ls {"ls"};
   fn_ls(state, ls);
   for(int i = 0; i < pathList.size(); i++){
      DFS(pathList[i], state);
   }
   state.setCwd(ogcwd);
}
Пример #21
0
// If a callback is specified, the included files will be loaded asynchronously and the callback will be called
// when all of the files have finished loading.
// If no callback is specified, the included files will be loaded synchronously and will block execution until
// all of the files have finished loading.
void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) {
    if (_stoppingAllScripts) {
        qCDebug(scriptengine) << "Script.include() while shutting down is ignored..."
                 << "includeFiles:" << includeFiles << "parent script:" << getFilename();
        return; // bail early
    }
    QList<QUrl> urls;
    for (QString file : includeFiles) {
        urls.append(resolvePath(file));
    }

    BatchLoader* loader = new BatchLoader(urls);

    auto evaluateScripts = [=](const QMap<QUrl, QString>& data) {
        for (QUrl url : urls) {
            QString contents = data[url];
            if (contents.isNull()) {
                qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
            } else {
                QScriptValue result = evaluate(contents, url.toString());
            }
        }

        if (callback.isFunction()) {
            QScriptValue(callback).call();
        }

        loader->deleteLater();
    };

    connect(loader, &BatchLoader::finished, this, evaluateScripts);

    // If we are destroyed before the loader completes, make sure to clean it up
    connect(this, &QObject::destroyed, loader, &QObject::deleteLater);

    loader->start();

    if (!callback.isFunction() && !loader->isFinished()) {
        QEventLoop loop;
        QObject::connect(loader, &BatchLoader::finished, &loop, &QEventLoop::quit);
        loop.exec();
    }
}
Пример #22
0
void fn_mkdir (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);

   if (words.size() <= 0){
      cout << "mkdir: missing operand" << endl;
      return;
   }
   //root case?
   if (words[1] == "/"){
      inode_ptr ogcwd = state.getCwd();
      auto root = state.getCwd()->getContents()->mkdir(words[1]);
      root->getContents()->setPath("..", ogcwd);
      root->getContents()->setPath(".", root);
      return;
   }

   wordvec pathvec = split(words[1], "/");
   string dirname = *(pathvec.end()-1);
   string fullpath = "";
   for (auto it = pathvec.begin(); it != pathvec.end()-1; ++it)
      fullpath += (*it + "/");
   inode_ptr res = resolvePath(fullpath,state.getCwd());
   if (res == nullptr) return;
   inode_ptr directory = res->getContents()->getNode(dirname);
   if (directory != nullptr && res != nullptr) //if filename exists and path exists
      //dont overwrite anything (ie file or directory)
      return;
   inode_ptr dir = res->getContents()->mkdir(dirname);
   dir->getContents()->setPath("..", res);
   dir->getContents()->setPath(".",res->getContents()->getNode(dirname));

   /*if (state.getCwd()->getContents()->getNode(filename) != nullptr)
      return; */
   /*
   inode_ptr ogcwd = state.getCwd();
   for (auto it = words.begin()+1; it != words.end(); ++it){
      auto newDir = state.getCwd()->getContents()->mkdir(*it);
      newDir->getContents()->setPath("..", ogcwd);
      newDir->getContents()->setPath(".", newDir);
   }
   */
}
Пример #23
0
AbcArchiveCache* getArchiveCache(std::string const& path,
                                 CommonProgressBar* pBar)
{
  ESS_PROFILE_SCOPE("getArchiveCache");
  getArchiveFromID(path);
  std::string resolvedPath = resolvePath(path);
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) return NULL;

  // compute cache if required.
  if (it->second.archiveCache.size() == 0) {
    if (!createAbcArchiveCache(it->second.archive, &(it->second.archiveCache),
                               pBar)) {
      it->second.archiveCache.clear();
      return 0;
    }
  }
  return &(it->second.archiveCache);
}
Пример #24
0
QGLShader *SceneParser::loadShader(KeyValues *data)
{
  const char *type = data->getString("type");
  if(!type) {
    fprintf(stderr, "Key 'type' not found on Shader\n");
    return NULL;
  }

  const char *file = data->getString("file");
  if(!file) {
    fprintf(stderr, "Key 'file' not found on Shader\n");
    return NULL;
  }
  char *filename = resolvePath(file);

  QGLShader::ShaderType shaderType;
  if(strcmp(type, "vertex") == 0) {
    shaderType = QGLShader::Vertex;
  }
  else if(strcmp(type, "fragment") == 0) {
    shaderType = QGLShader::Fragment;
  }
  else {
    fprintf(stderr, "Invalid shader type: %s\n", type);
    delete[] filename;
    return NULL;
  }

  QGLShader *shader = new QGLShader(shaderType);
  if(!shader->compileSourceFile(filename)) {
    fprintf(stderr, "Failed to load shader %s\n", filename);
    fprintf(stdout, shader->log().toStdString().c_str());
    delete shader;
    delete[] filename;
    return NULL;
  }
  delete[] filename;

  return shader;
}
Пример #25
0
bool FileSystem::fileExists(const char* filePath, bool external)
{
    GP_ASSERT(filePath);

    std::string fullPath;

#ifdef __ANDROID__
    fullPath = __assetPath;
    fullPath += resolvePath(filePath);

    if (androidFileExists(fullPath.c_str()))
    {
        return true;
    }
#endif

    getFullPath(filePath, fullPath, external);

    gp_stat_struct s;
    return stat(fullPath.c_str(), &s) == 0;

}
void QgsExternalResourceWidget::loadDocument( const QString &path )
{
  QString resolvedPath;

  if ( path.isEmpty() )
  {
#ifdef WITH_QTWEBKIT
    if ( mDocumentViewerContent == Web )
    {
      mWebView->setUrl( QUrl( QStringLiteral( "about:blank" ) ) );
    }
#endif
    if ( mDocumentViewerContent == Image )
    {
      mPixmapLabel->clear();
      updateDocumentViewer();
    }
  }
  else
  {
    resolvedPath = resolvePath( path );

#ifdef WITH_QTWEBKIT
    if ( mDocumentViewerContent == Web )
    {
      mWebView->setUrl( QUrl( resolvedPath ) );
    }
#endif

    if ( mDocumentViewerContent == Image )
    {
      QPixmap pm( resolvedPath );
      mPixmapLabel->setPixmap( pm );
      updateDocumentViewer();
    }
  }
}
Пример #27
0
std::wstring findFile(const std::wstring& f)
{
	ODBGS(f);

	if (mol::Path::exists(f))
	{
		ODBGS("FOUND");
		return f;
	}

	std::wstring modulePath = mol::Path::pathname(mol::app<mol::win::AppBase>().getModulePath());

	modulePath = mol::Path::addBackSlash(modulePath);

	modulePath.append(f);
	ODBGS(modulePath);
	if (mol::Path::exists(modulePath))
	{
		ODBGS("FOUND");
		return modulePath;
	}

	return mol::towstring(resolvePath(mol::tostring(f)));
}
Пример #28
0
Alembic::Abc::IArchive* getArchiveFromID(std::string const& path)
{
  ESS_PROFILE_SCOPE("getArchiveFromID-1");
  std::map<std::string, AlembicArchiveInfo>::iterator it;
  std::string resolvedPath = resolvePath(path);
  it = gArchives.find(resolvedPath);
  if (it == gArchives.end()) {
    // check if the file exists

    if (!boost::filesystem::exists(resolvedPath.c_str())) {
      ESS_LOG_ERROR("Can't find Alembic file.  Path: "
                    << path << "  Resolved path: " << resolvedPath);
      return NULL;
    }

    FILE* file = fopen(resolvedPath.c_str(), "rb");
    if (file == NULL) {
      return NULL;
    }
    else {
      fclose(file);

      AbcF::IFactory iFactory;
      AbcF::IFactory::CoreType oType;
      addArchive(new Abc::IArchive(iFactory.getArchive(resolvedPath, oType)));

      // addArchive(new Abc::IArchive( Alembic::AbcCoreHDF5::ReadArchive(),
      // resolvedPath));

      Abc::IArchive* pArchive = gArchives.find(resolvedPath)->second.archive;
      EC_LOG_INFO("Opening Abc Archive: " << pArchive->getName());
      return pArchive;
    }
  }
  return it->second.archive;
}
Пример #29
0
Template::Ptr TemplateCache::getTemplate(const Path& path)
{
	if ( _logger )
	{
		poco_trace_f1(*_logger, "Trying to load %s", path.toString());
	}
	Path templatePath = resolvePath(path);
	std::string templatePathname = templatePath.toString();
	if ( _logger )
	{
		poco_trace_f1(*_logger, "Path resolved to %s", templatePathname);
	}
	File templateFile(templatePathname);

	Template::Ptr tpl;

	std::map<std::string, Template::Ptr>::iterator it = _cache.find(templatePathname);
	if ( it == _cache.end() )
	{
		if ( templateFile.exists() )
		{
			if ( _logger )
			{
				poco_information_f1(*_logger, "Loading template %s", templatePath.toString());
			}

			tpl = new Template(templatePath);

			try
			{
				tpl->parse();
				_cache[templatePathname] = tpl;
			}
			catch(JSONTemplateException& jte)
			{
				if ( _logger )
				{
					poco_error_f2(*_logger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
				}
			}
		}
		else
		{
			if ( _logger )
			{
				poco_error_f1(*_logger, "Template file %s doesn't exist", templatePath.toString());
			}
			throw FileNotFoundException(templatePathname);
		}
	}
	else
	{
		tpl = it->second;
		if ( tpl->parseTime() < templateFile.getLastModified() )
		{
			if ( _logger )
			{
				poco_information_f1(*_logger, "Reloading template %s", templatePath.toString());
			}

			tpl = new Template(templatePath);

			try
			{
				tpl->parse();
				_cache[templatePathname] = tpl;
			}
			catch(JSONTemplateException& jte)
			{
				if ( _logger )
				{
					poco_error_f2(*_logger, "Template %s contains an error: %s", templatePath.toString(), jte.message());
				}
			}
		}
	}

	return tpl;
}
Пример #30
0
LLView* LLUI::resolvePath(LLView* context, const std::string& path)
{
	// Nothing about resolvePath() should require non-const LLView*. If caller
	// wants non-const, call the const flavor and then cast away const-ness.
	return const_cast<LLView*>(resolvePath(const_cast<const LLView*>(context), path));
}