Esempio n. 1
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);
  }
}
void getRelativePaths(const String& fromAbsPath, StringVec& toAbsPaths)
{
  StringVec::iterator pathsIt = toAbsPaths.begin();
  for (; pathsIt != toAbsPaths.end(); pathsIt++) {
    *pathsIt = getRelativePath(fromAbsPath, *pathsIt);
  }
}
Esempio n. 3
0
VCProject* SBTarget::constructVCProject(VSTemplateProject* projTemplate)
{
  // Create the project
  VCProject* proj = new VCProject(projTemplate);

  // Get path to WinObjC SDK
  const BuildSettings& projBS = m_parentProject.getBuildSettings();
  String useRelativeSdkPath = projBS.getValue("VSIMPORTER_RELATIVE_SDK_PATH");
  String sdkDir = projBS.getValue("WINOBJC_SDK_ROOT");

  // Try to create a relative path to the SDK, if requested
  if (strToUpper(useRelativeSdkPath) == "YES") {
    String projectDir = sb_dirname(projTemplate->getPath());
    sdkDir = getRelativePath(projectDir, sdkDir);
  }
  proj->addGlobalProperty("WINOBJC_SDK_ROOT", platformPath(sdkDir), "'$(WINOBJC_SDK_ROOT)' == ''");

  // Set configuration properties
  for (auto configBS : m_buildSettings) {
    VCProjectConfiguration *projConfig = proj->addConfiguration(configBS.first);
    String productName = configBS.second->getValue("PRODUCT_NAME");
    if (!productName.empty()) {
      projConfig->setProperty("TargetName", productName);
    }
  }

  // Write files associated with each build phase
  SBBuildPhaseList::const_iterator phaseIt = m_buildPhases.begin();
  for (; phaseIt != m_buildPhases.end(); ++phaseIt)
    (*phaseIt)->writeVCProjectFiles(*proj);

  return proj;
}
Esempio n. 4
0
	std::string UtlDirectory::getFullPath() const {
		std::string sFullPath;
		std::string sRelativePath = getRelativePath();
#ifdef WIN32
		char tcFullPath[2048];
		char* pFileName;
		std::string sCrazyFile = sRelativePath;
		if (GetFullPathName(sCrazyFile.c_str(), 2048, tcFullPath, &pFileName) != 0) {
			sFullPath = tcFullPath;
			if (!sFullPath.empty()) {
				if ((sFullPath[sFullPath.size() - 1] != '\\') && (sFullPath[sFullPath.size() - 1] != '/')) sFullPath += "/";
			}
		}
#else
		if (sRelativePath[0]=='/') {
			sFullPath= sRelativePath;
		} else {
			char pcFullPath[CW_PATH_MAX];
			pcFullPath[0] = '\0';
			getcwd(pcFullPath, CW_PATH_MAX - 1);
			sFullPath= pcFullPath;
			if (!sFullPath.empty()) {
				if (sFullPath[sFullPath.size() - 1] != '/') sFullPath += "/";
				sFullPath += sRelativePath;
			} else {
				sFullPath = "/" + sRelativePath;
			}
		}
#endif
		return sFullPath;
	}
Esempio n. 5
0
void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR* fn2write)
{
    TCHAR textBuffer[MAX_PATH];
    TVITEM tvItem;
    tvItem.mask = TVIF_TEXT | TVIF_PARAM;
    tvItem.pszText = textBuffer;
    tvItem.cchTextMax = MAX_PATH;

    for (HTREEITEM hItemNode = _treeView.getChildFrom(hItem);
            hItemNode != NULL;
            hItemNode = _treeView.getNextSibling(hItemNode))
    {
        tvItem.hItem = hItemNode;
        SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem);
        if (tvItem.lParam != NULL)
        {
            generic_string *fn = (generic_string *)tvItem.lParam;
            generic_string newFn = getRelativePath(*fn, fn2write);
            TiXmlNode *fileLeaf = node->InsertEndChild(TiXmlElement(TEXT("File")));
            fileLeaf->ToElement()->SetAttribute(TEXT("name"), newFn.c_str());
        }
        else
        {
            TiXmlNode *folderNode = node->InsertEndChild(TiXmlElement(TEXT("Folder")));
            folderNode->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText);
            buildProjectXml(folderNode, hItemNode, fn2write);
        }
    }
}
std::string VSBuildableSolutionProject::getPath() const
{
  // Return a path relative to the solution directory
  std::string solutionDir = sb_dirname(m_parent.getPath());
  std::string relativePath = getRelativePath(solutionDir, m_project->getPath());
  relativePath = winPath(relativePath);
  return relativePath;
}
Esempio n. 7
0
wxString
SfsEntry::getRelativePath(void) const
{
	if (parent_ != 0)
		return (getRelativePath(parent_->getPath()));
	else
		return (getPath());
}
Esempio n. 8
0
VCProjectItem* addRelativeFilePathToVS(const String& itemName, const String& filePath, const String& filterPath, VCProject& proj, const BuildSettings& bs)
{
  // Get relative path to file
  String xcProjectDir = bs.getValue("PROJECT_DIR");
  String vsProjectDir = sb_dirname(proj.getPath());
  String absFilePath = joinPaths(xcProjectDir, bs.expand(filePath));
  String relPath = getRelativePath(vsProjectDir, absFilePath);
  relPath = winPath(relPath);
  return proj.addItem(itemName, relPath, filterPath);
}
Esempio n. 9
0
// ===================================================================
void ShapeNode::setTextureFromFile (const char* s)
{
	string path = getRelativePath(string(s));
	
	// don't do anything if the current texture is already loaded:
	if (path==texturePath) return;
	else texturePath=path;
	
	//drawTexture();

	BROADCAST(this, "ss", "setTextureFromFile", texturePath.c_str());
}
Esempio n. 10
0
void VCProject::writeProjectReferences(pugi::xml_node& node) const
{
  std::string projectPath = getPath();
  std::string projectDir = sb_dirname(projectPath);

  for (auto dep : m_projectRefs) {
    std::string depGUID = formatVSGUID(dep->getId());
    std::string depRelativePath = getRelativePath(projectDir, dep->getPath());
    pugi::xml_node projRef = node.append_child("ProjectReference");
    projRef.append_attribute("Include") = depRelativePath.c_str();
    appendNodeWithText(projRef, "Project", depGUID);
  }
}
Esempio n. 11
0
void VCProject::writeSharedProjects(pugi::xml_node& node) const
{
  std::string projectPath = getPath();
  std::string projectDir = sb_dirname(projectPath);

  pugi::xml_node tempNode = node.parent().append_child("Temp");
  for (auto sproj : m_sharedProjects) {
    std::string sprojRelativePath = getRelativePath(projectDir, sproj->getPath());
    pugi::xml_node importProj = tempNode.append_child("Import");
    importProj.append_attribute("Project") = sprojRelativePath.c_str();
    importProj.append_attribute("Label") = "Shared";
  }
  mergeNodes(node, tempNode);
}
Esempio n. 12
0
VCProject* SBWorkspace::generateGlueProject() const
{
  // Get a set of all configurations appearing in all projects
  StringSet slnConfigs;
  for (auto project : m_openProjects) {
    const StringSet& configs = project.second->getSelectedConfigurations();
    slnConfigs.insert(configs.begin(), configs.end());
  }

  // Get the template
  VSTemplate* vstemplate = VSTemplate::getTemplate("WinRT");
  sbAssertWithTelemetry(vstemplate, "Failed to get WinRT VS template");

  // Set up basis template parameters
  string projectName = getName() + "WinRT";
  VSTemplateParameters templateParams;
  templateParams.setProjectName(projectName);

  // Expand the template and get the template project
  vstemplate->expand(sb_dirname(getPath()), templateParams);
  const VSTemplateProjectVec& projTemplates = vstemplate->getProjects();
  sbAssertWithTelemetry(projTemplates.size() == 1, "Unexpected WinRT template size");

  // Create the glue project and add it to the solution
  VCProject* glueProject = new VCProject(projTemplates.front());

  // Get path to WinObjC SDK
  BuildSettings globalBS(NULL);
  String useRelativeSdkPath = globalBS.getValue("VSIMPORTER_RELATIVE_SDK_PATH");
  String sdkDir = globalBS.getValue("WINOBJC_SDK_ROOT");

  // Try to create a relative path to the SDK, if requested
  if (strToUpper(useRelativeSdkPath) == "YES") {
    String projectDir = sb_dirname(projTemplates.front()->getPath());
    sdkDir = getRelativePath(projectDir, sdkDir);
  }
  glueProject->addGlobalProperty("WINOBJC_SDK_ROOT", platformPath(sdkDir), "'$(WINOBJC_SDK_ROOT)' == ''");

  // Set configuration properties
  for (auto configName : slnConfigs) {
    VCProjectConfiguration *projConfig = glueProject->addConfiguration(configName);
    projConfig->setProperty("TargetName", getName());
  }

  // Set RootNamespace
  glueProject->addGlobalProperty("RootNamespace", getName());

  return glueProject;
}
Esempio n. 13
0
void ProjectLeafNode::setEntrySize( const Filesystem& fs )
{
   std::string relativePath = getRelativePath();

   std::size_t fileSize = 0;
   File* file = fs.open( relativePath );
   if ( file )
   {
      fileSize = file->size();
      delete file;
   }
   else
   {
      fileSize = 0;
   }

   char fileSizeStr[ 32 ];
   sprintf_s( fileSizeStr, "%d", fileSize );
   setText( 1, fileSizeStr );
}
Esempio n. 14
0
void Project::scanRoot()
{
    QStack<QDir> directoryStack;
    directoryStack.push(m_root);

    while (!directoryStack.empty()) {
        QDir directory(directoryStack.pop());
        qint64 updated = QDateTime::currentDateTime().toTime_t();
        QFileInfoList entries(directory.entryInfoList(QDir::NoFilter, QDir::DirsLast));

        for (int i = 0; i < entries.length(); i++) {
            if (entries[i].fileName() == "." || entries[i].fileName() == "..")
                continue;

            QString absolutePath(entries[i].absoluteFilePath());
            addOrUpdateEntry(getRelativePath(absolutePath), updated);

            if (entries[i].isDir())
                directoryStack.push(QDir(absolutePath));
        }
    }
}
Esempio n. 15
0
static int matchInode(const char *pathname, const struct stat *sbuf, int type,
        struct FTW *ftwb) {

    fileop_t *f;
    fileop_t *finode;
    char relpath[PATH_MAX];
    int64_t inode;

    // if stat has succeeded, get ino
    if (type != FTW_NS)
        inode = sbuf->st_ino;
    else
        return 0;
    
    // if this ino is in inodefiles, add entry to files hash table and merge
    // the operations into it
    HASH_FIND_INT(inodefiles, &inode, finode);
    if (finode != NULL) {
        getRelativePath(relpath, config.snapshot, pathname);
        if (initializeFileop(relpath, &f) != 0)
            return -1;

        if (mergeOperations(f, finode) != 0)
            return -1;

        finode->order = fileorder++;
        HASH_ADD_STR(files, relpath, f);

        free(finode->operations);
        HASH_DEL(inodefiles, finode);
        free(finode);
    }

    // if there are no entries in inodefiles left, we are done
    if (HASH_COUNT(inodefiles) == 0) // HASH_COUNT is cheap
        return 1;

    return 0;
}
Esempio n. 16
0
void ProjectLeafNode::setEntryIcon( const Filesystem& fs, TreeWidgetDescFactory& itemsFactory )
{
   std::string iconsDir = fs.getShortcut( "editorIcons" );
   std::string extension = FilesystemUtils::extractExtension( m_projectNodeName );

   QIcon icon;

   const SerializableReflectionType* resourceType = Resource::findResourceClass( extension.c_str() );
   if ( resourceType )
   {
      // as the first shot, try creating an icon corresponding to the type of the resource
      QString typeName, group;
      itemsFactory.getDesc( *resourceType, typeName, group, icon );
   }

   if ( icon.isNull() )
   {
      // if the resource is of an unknown type, try finding an icon matching the file extension
      std::string iconName = iconsDir + "/" + extension + "Icon.png";
      if ( fs.doesExist( fs.toRelativePath( iconName ) ) )
      {
         icon = QIcon( iconName.c_str() );
      }
   }

   if ( icon.isNull() )
   {
      // as a last resort, try using a system icon
      QFileIconProvider iconProvider;

      std::string absolutePath = fs.toAbsolutePath( getRelativePath() );
      QFileInfo fileInfo( absolutePath.c_str() );
      icon = iconProvider.icon( fileInfo );
   }

   setIcon( 0, icon );
}
Esempio n. 17
0
/*virtual*/ std::string File::getRelativePath(void) const
{
	char directory[2048];
	GetCurrentDir(directory, 2048);
	return getRelativePath(directory);
}
Esempio n. 18
0
bool UrlValue::loadPng(UrlValue_Img &img) const {

#ifdef WITH_LIBPNG
  unsigned char header[8];    // 8 is the maximum size that can be checked
  /* open file and test for it being a png */
  
  png_structp png_ptr;
  png_infop info_ptr;
  png_byte color_type;
  int channels;
  
  std::string path = getRelativePath();
  
#ifdef WITH_LIBGLOG
  VLOG(3) << "PNG path: " << path;
#endif
    
  FILE *fp = fopen(path.c_str(), "rb");
  if (!fp)
    return false; //"Image file could not be opened"

  fread(header, 1, 8, fp);
  
  if (png_sig_cmp(header, 0, 8))
    return false; //"Image is not a PNG file"

  /* initialize stuff */
  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

  if (!png_ptr)
    throw new ValueException("png_create_read_struct failed",
                             *this->getTokens());

  info_ptr = png_create_info_struct(png_ptr);
  if (!info_ptr)
    throw new ValueException("png_create_info_struct failed",
                             *this->getTokens());

  if (setjmp(png_jmpbuf(png_ptr)))
    throw new ValueException("Error during init_io",
                             *this->getTokens());

  png_init_io(png_ptr, fp);
  png_set_sig_bytes(png_ptr, 8);

  png_read_info(png_ptr, info_ptr);

  img.width = png_get_image_width(png_ptr, info_ptr);
  img.height = png_get_image_height(png_ptr, info_ptr);
  channels = png_get_channels(png_ptr, info_ptr);
  color_type = png_get_color_type(png_ptr, info_ptr);
  
  if(color_type == PNG_COLOR_TYPE_PALETTE) {
    png_set_palette_to_rgb(png_ptr);
    channels = 3;
  }
  if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
    png_set_tRNS_to_alpha(png_ptr);
    channels += 1;
  }

#ifdef WITH_LIBGLOG
  VLOG(3) << "Width: " << img.width << ", Height: " << img.height <<
    ", Channels: " << channels;
#endif

  png_color_16p pBackground;
  if (png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) {
    png_get_bKGD(png_ptr, info_ptr, &pBackground);
    img.background.setRGB(pBackground->red,
                          pBackground->green,
                          pBackground->blue);
  }else {
    img.background.setRGB(255,255,255);
  }

  png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
  png_ptr = NULL;
  info_ptr = NULL;
  fclose(fp);
  
#ifdef WITH_LIBGLOG
  VLOG(3) << "Read successful";
#endif

  return true;
  
#else
  return false;
#endif  
}
Esempio n. 19
0
void ProjectLeafNode::openItem( ProjectTree& tree )
{
   std::string pathToResource = getRelativePath();
   ResourceManagementUtil::editResource( pathToResource, icon(0) );
}
Esempio n. 20
0
static String makeRelativePath(const String& path, const String& oldProjDir, const String& newProjDir) {
    String absPath = joinPaths(oldProjDir, path);
    String relPath = getRelativePath(newProjDir, absPath);
    return winPath(relPath);
}
Esempio n. 21
0
QString QtSE::CProjectTreeItem::getFullPath( const QString &basePath ) const
{
	QString relativePath = basePath;
	getRelativePath( relativePath );
	return relativePath;
}
Esempio n. 22
0
bool UrlValue::loadJpeg(UrlValue_Img &img) const {
#ifdef WITH_LIBJPEG
  struct jpeg_decompress_struct cinfo;
  
  struct urlvalue_jpeg_error_mgr jerr;
  /* More stuff */
  FILE * infile;
  JSAMPARRAY buffer;	/* Output row buffer */
  int row_stride;	/* physical row width in output buffer */
  std::string path = getRelativePath();
  
  if ((infile = fopen(path.c_str(), "rb")) == NULL) {
    return false;
  }

  /* Step 1: allocate and initialize JPEG decompression object */

  /* We set up the normal JPEG error routines, then override error_exit. */
  cinfo.err = jpeg_std_error(&jerr.pub);
  jerr.pub.error_exit = urlvalue_jpeg_error_exit;
  /* Establish the setjmp return context for urlvalue_jpeg_error_exit to use. */
  if (setjmp(jerr.setjmp_buffer)) {
    /* If we get here, the JPEG code has signaled an error.
     * We need to clean up the JPEG object, close the input file, and return.
     */
    jpeg_destroy_decompress(&cinfo);
    fclose(infile);
    return false;
  }
  /* Now we can initialize the JPEG decompression object. */
  jpeg_create_decompress(&cinfo);

  /* Step 2: specify data source (eg, a file) */

  jpeg_stdio_src(&cinfo, infile);

  /* Step 3: read file parameters with jpeg_read_header() */

  (void) jpeg_read_header(&cinfo, TRUE);
  /* We can ignore the return value from jpeg_read_header since
   * (a) suspension is not possible with the stdio data source, and
   * (b) we passed TRUE to reject a tables-only JPEG file as an error.
   * See libjpeg.txt for more info.
   */

  /* Step 4: set parameters for decompression */

  /* In this example, we don't need to change any of the defaults set by
   * jpeg_read_header(), so we do nothing here.
   */

  /* Step 5: Start decompressor */

  (void) jpeg_start_decompress(&cinfo);
  /* We can ignore the return value since suspension is not possible
   * with the stdio data source.
   */

  img.width = cinfo.output_width;
  img.height = cinfo.output_height;
  
  /* We may need to do some setup of our own at this point before reading
   * the data. After jpeg_start_decompress() we have the correct scaled
   * output image dimensions available, as well as the output colormap
   * if we asked for color quantization.
   * In this example, we need to make an output work buffer of the right size.
   */
  /* JSAMPLEs per row in output buffer */
  row_stride = cinfo.output_width * cinfo.output_components;
  /* Make a one-row-high sample array that will go away when done with image */
  buffer = (*cinfo.mem->alloc_sarray)
    ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);

  /* Step 6: while (scan lines remain to be read) */
  /* jpeg_read_scanlines(...); */

  /* Here we use the library's state variable cinfo.output_scanline as the
   * loop counter, so that we don't have to keep track ourselves.
   */
  while (cinfo.output_scanline < cinfo.output_height) {
    /* jpeg_read_scanlines expects an array of pointers to scanlines.
     * Here the array is only one element long, but you could ask for
     * more than one scanline at a time if that's more convenient.
     */
    (void) jpeg_read_scanlines(&cinfo, buffer, 1);
    /* Assume put_scanline_someplace wants a pointer and sample count. */
    //put_scanline_someplace(buffer[0], row_stride);
    if (cinfo.out_color_space == JCS_RGB && 
        (cinfo.output_scanline == 1 ||
         cinfo.output_scanline == cinfo.output_height)) {

      if (cinfo.output_scanline == 1) {
        img.background.setRGB(buffer[0][0], buffer[0][1], buffer[0][2]);
      }
      if (img.background.getRed() != buffer[0][0] ||
          img.background.getGreen() != buffer[0][1] ||
          img.background.getBlue() != buffer[0][2] ||

          img.background.getRed() != buffer[0][row_stride - cinfo.output_components] ||
          img.background.getGreen() != buffer[0][row_stride - cinfo.output_components + 1] ||
          img.background.getBlue() != buffer[0][row_stride - cinfo.output_components + 2]) {
        img.background.setRGB(0,0,0);
      }
    }
  }

  /* Step 7: Finish decompression */

  (void) jpeg_finish_decompress(&cinfo);
  /* We can ignore the return value since suspension is not possible
   * with the stdio data source.
   */

  /* Step 8: Release JPEG decompression object */

  /* This is an important step since it will release a good deal of memory. */
  jpeg_destroy_decompress(&cinfo);

  /* After finish_decompress, we can close the input file.
   * Here we postpone it until after no more JPEG errors are possible,
   * so as to simplify the setjmp error logic above. (Actually, I don't
   * think that jpeg_destroy can do an error exit, but why assume anything...)
   */
  fclose(infile);
  return true;
#else
  return false;
#endif
}
Esempio n. 23
0
bool UrlValue::loadPng(UrlValue_Img &img) const {

#ifdef WITH_LIBPNG
  unsigned char header[8];    // 8 is the maximum size that can be checked
  /* open file and test for it being a png */
  
  png_structp png_ptr;
  png_infop info_ptr;
  png_bytep* row_pointers;
  png_uint_32 rowbytes;
  unsigned int y;
  std::string path = getRelativePath();
  
    
  FILE *fp = fopen(path.c_str(), "rb");
  if (!fp)
    return false; //"Image file could not be opened"

  fread(header, 1, 8, fp);
  if (png_sig_cmp(header, 0, 8))
    return false; //"Image is not a PNG file"
  
  /* initialize stuff */
  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

  if (!png_ptr)
    throw new ValueException("png_create_read_struct failed",
                             *this->getTokens());

  info_ptr = png_create_info_struct(png_ptr);
  if (!info_ptr)
    throw new ValueException("png_create_info_struct failed",
                             *this->getTokens());

  if (setjmp(png_jmpbuf(png_ptr)))
    throw new ValueException("Error during init_io",
                             *this->getTokens());

  png_init_io(png_ptr, fp);
  png_set_sig_bytes(png_ptr, 8);

  png_read_info(png_ptr, info_ptr);

  img.width = png_get_image_width(png_ptr, info_ptr);
  img.height = png_get_image_height(png_ptr, info_ptr);
  int channels = png_get_channels(png_ptr, info_ptr);
  
  if(png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
    png_set_palette_to_rgb(png_ptr);
    channels = 3;
  }
  if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
    png_set_tRNS_to_alpha(png_ptr);
    channels += 1;
  }

  /* read file */
  if (setjmp(png_jmpbuf(png_ptr)))
    throw new ValueException("Error during read_image",
                             *this->getTokens());

  rowbytes = png_get_rowbytes(png_ptr,info_ptr);
  
  row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * img.height);

  for (y = 0; y < img.height; y++)
    row_pointers[y] = (png_byte*)malloc(rowbytes);

  png_read_image(png_ptr, row_pointers);

  if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB ||
      png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGBA ||
      png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {

    png_byte* color1 = row_pointers[0];
    png_byte* color2 = row_pointers[0] + (img.width - 1) * channels;
    png_byte* color3 = row_pointers[img.height - 1];
    png_byte* color4 = row_pointers[img.height - 1] + (img.width - 1) * channels;

    if (memcmp(color1, color2, channels) == 0 &&
        memcmp(color1, color3, channels) == 0 &&
        memcmp(color1, color4, channels) == 0) {
        
      img.background.setRGB(color1[0], color1[1], color1[2]);
      if (channels == 4)
        img.background.setAlpha(color1[3]);
    } else {
      img.background.setRGB(0,0,0);
    }
  }
    
  fclose(fp);
  return true;
  
#else
  return false;
#endif  
}