bool ResourceManifest::loadInclude(IPropertyTree &include, const char *dir)
{
    const char *filename = include.queryProp("@filename");
    StringBuffer includePath;
    makeAbsolutePath(filename, dir, includePath);

    VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str());
    if (manifest->hasProp(xpath.str()))
        return false;

    include.setProp("@originalFilename", includePath.str());
    StringBuffer includeDir;
    splitDirTail(includePath, includeDir);

    Owned<IPropertyTree> manifestInclude = createPTreeFromXMLFile(includePath.str());
    Owned<IPropertyTreeIterator> it = manifestInclude->getElements("*");
    ForEach(*it)
    {
        IPropertyTree &item = it->query();
        if (streq(item.queryName(), "Resource"))
            updateResourcePaths(item, includeDir.str());
        else if (streq(item.queryName(), "Include"))
        {
            if (!loadInclude(item, includeDir.str()))
                continue;
        }
        manifest->addPropTree(item.queryName(), LINK(&item));
    }
    return true;
}
 ResourceManifest(const char *filename)
     : manifest(createPTreeFromXMLFile(filename))
 {
     makeAbsolutePath(filename, absFilename);
     splitDirTail(absFilename, dir);
     expand();
 }
Exemple #3
0
void ResourceManager::addManifest(const char *filename)
{
    StringBuffer path;
    Owned<IPropertyTree> t = createPTree();
    t->setProp("@originalFilename", makeAbsolutePath(filename, path).str());
    ensureManifestInfo()->addPropTree("Include", t.getClear());
    addManifestFile(filename);
}
Exemple #4
0
int store(AQBACKUP *b,  ARGUMENTS *args, CONFIGGROUP *cfg) {
  char cwdbuff[256];
  char absbuff[256];
  const char *dir;

  /* save current working directory */
  if (getcwd(cwdbuff, sizeof(cwdbuff)-1)==0) {
    DBG_ERROR("Error on getcwd(): %s", strerror(errno));
    return 1;
  }

  /* get directory to work on */
  dir=0;
  if (args->params)
    dir=args->params->param;
  if (dir==0) {
    dir=cwdbuff;
  }

  /* make the path absolute to allow looking it up in the repository list */
  if (makeAbsolutePath(dir, absbuff, sizeof(absbuff)-1)==0) {
    return 2;
  }

  /* restore the working directory */
  if (chdir(cwdbuff)) {
    DBG_ERROR("Error on chdir(%s): %s",
	      cwdbuff,
	      strerror(errno));
    return 2;
  }

  DBG_INFO("Storing directory \"%s\"", absbuff);

  /* now open the appropriate repository */
  if (AQBackup_Open(b, absbuff, 1)) {
    DBG_ERROR("Could not open directory \"%s\"", absbuff);
    return 2;
  }

  /* now store the given dir */
  if (AQBackup_HandleDir(b,
			 absbuff,
			 AQBackupJobStore,
			 0,
			 "",
			 args->flags)) {
    DBG_ERROR("Error handling dir \"%s\"", absbuff);
    return 3;
  }

  if (AQBackup_Close(b)) {
    DBG_ERROR("Error closing repository");
    return 4;
  }

  return 0;
}
Exemple #5
0
String SBTarget::makeRelativePath(const String& path, const String& absRoot) const
{
  String absPath = makeAbsolutePath(path);
  if (absRoot.empty()) {
    return getRelativePath(m_parentProject.getProjectDir(), absPath);
  } else {
    return getRelativePath(absRoot, absPath);
  }
}
Exemple #6
0
void updateManifestResourcePaths(IPropertyTree &resource, const char *dir)
{
    StringBuffer filepath;
    makeAbsolutePath(resource.queryProp("@filename"), dir, filepath);
    resource.setProp("@originalFilename", filepath.str());

    StringBuffer respath;
    makePathUniversal(filepath.str(), respath);
    resource.setProp("@resourcePath", respath.str());
}
Exemple #7
0
void Util::setDataPath(const std::string& path, bool makeAbsolute)
{
	if(makeAbsolute)
		dataPath = makeAbsolutePath(path);
	else
		dataPath = path;
	
	// add trailing slash
	if(dataPath.length() > 0 && dataPath.substr(dataPath.length()-2, dataPath.length()-1) != "/")
		dataPath += "/";
}
Exemple #8
0
void ResourceManager::addManifestInclude(IPropertyTree &include, const char *dir)
{
    StringBuffer includePath;
    makeAbsolutePath(include.queryProp("@filename"), dir, includePath);
    VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str());
    if (manifest->hasProp(xpath.str()))
        return;
    include.setProp("@originalFilename", includePath.str());
    manifest->addPropTree("Include", LINK(&include));
    addManifestFile(includePath.str());
}
Exemple #9
0
//
//	data path code from OpenFrameworks: http://openframeworks.cc
//
std::string Util::toDataPath(std::string path, bool makeAbsolute)
{
	if(bUsingDataPath)
	{
		// check if absolute path has been passed or if data path has already been applied
		if(path.length() == 0 ||
		   (!isAbsolutePath(path) && path.substr(0, dataPath.length()) != dataPath))
		{
			path = dataPath + path;
		}

		if(makeAbsolute)
		{
			path = makeAbsolutePath(path);
		}
	}
	return path;	
}
Exemple #10
0
void Mesh::create(char* filepath)
{
	//File load
	char* path = makeAbsolutePath( filepath );
	
	FILE* fp;
	fopen_s( &fp, filepath, "r" );
	if( NULL == fp ) 
	{
		MessageBox( NULL, "Failed to create mesh", "Mesh", MB_ICONERROR );
		exit(1);
	}

	int nVertex,i;
	fscanf( fp, "%d", &nVertex );
	vertices = new Vertex[nVertex];

	float x, y, z;
	for( i=0; i<nVertex; i++ )
	{
		Vertex vtx;
		fscanf_s( fp, "%f %f %f", &x, &y, &z );
		x += pos.x;
		y += pos.y;
		z += pos.z;
		vtx.pos.Set( x, y, z, 1 );
		vtx.color.R = (float)(rand()%256) / 255;
		vtx.color.G = (float)(rand()%256) / 255;
		vtx.color.B = (float)(rand()%256) / 255;

		vertices[i] = vtx;
	}

	fscanf_s( fp, "%d", &nPolygon );
	indices = new int[nPolygon * 3];
	for( i=0; i<nPolygon; i++ )
	{
		fscanf_s( fp, "%d %d %d", &indices[i*3], &indices[i*3+1], &indices[i*3+2] );
	}

	fclose( fp );
}
Exemple #11
0
bool makeRealSystemPath(void* comm_obj, char* relative_path, char result[PATH_MAX])
{
    char ftp_work[PATH_MAX];
    CommObj* conn_obj = comm_obj;

    if ( *relative_path == '/' )
    {
        strcpy(ftp_work, relative_path);
    }
    else
    {
        if ( !makeAbsolutePath(conn_obj->work_path, relative_path, ftp_work) )
            return false;
    }

    UserInfo* user_info = conn_obj->user_info;
    strcpy(result, user_info->home_path);
    strcat(result, ftp_work + 1);
    return true;
}
Exemple #12
0
void ResourceManager::addManifestFile(const char *filename)
{
    Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename);

    StringBuffer dir; 
    splitDirTail(filename, dir);

    ensureManifestInfo();
    Owned<IAttributeIterator> aiter = manifestSrc->getAttributes();
    ForEach (*aiter)
        manifest->setProp(aiter->queryName(), aiter->queryValue());
    Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*");
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        if (streq(item.queryName(), "Include") && item.hasProp("@filename"))
            addManifestInclude(item, dir.str());
        else if (streq(item.queryName(), "Resource") && item.hasProp("@filename"))
        {
            StringBuffer filepath;
            StringBuffer respath;
            makeAbsolutePath(item.queryProp("@filename"), dir.str(), filepath);
            makePathUniversal(filepath.str(), respath);

            item.setProp("@originalFilename", filepath.str());
            item.setProp("@resourcePath", respath.str());

            if (containsFileWildcard(filepath))
            {
                StringBuffer wildpath;
                const char *tail = splitDirTail(filepath, wildpath);
                expandManifestDirectory(manifestSrc, item, dir, wildpath, tail, item.getPropBool("@recursive"));
                manifestSrc->removeTree(&item);
            }

        }
        else
            manifest->addPropTree(item.queryName(), LINK(&item));
    }

    Owned<IPropertyTreeIterator> resources = manifestSrc->getElements("Resource[@filename]");
    ForEach(*resources)
    {
        IPropertyTree &item = resources->query();

        if (!item.hasProp("@type"))
            item.setProp("@type", "UNKNOWN");
        int id;
        if (getDuplicateResourceId(item.queryProp("@type"), item.queryProp("@resourcePath"), NULL, id))
        {
            item.setPropInt("@id", id);
            manifest->addPropTree("Resource", LINK(&item));
        }
        else
        {
            MemoryBuffer content;
            loadResource(item.queryProp("@originalFilename"), content);
            addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item);
        }
    }
}