Exemple #1
0
boolean bamFileExists(char *fileOrUrl)
/* Return TRUE if we can successfully open the bam file and its index file. */
{
    char *bamFileName = fileOrUrl;
    samfile_t *fh = samopen(bamFileName, "rb", NULL);
    boolean usingUrl = TRUE;
    usingUrl = (strstr(fileOrUrl, "tp://") || strstr(fileOrUrl, "https://"));
    if (fh != NULL)
    {
#ifndef KNETFILE_HOOKS
        // When file is an URL, this caches the index file in addition to validating:
        // Since samtools's url-handling code saves the .bai file to the current directory,
        // chdir to a trash directory before calling bam_index_load, then chdir back.
        char *runDir = getCurrentDir();
        char *samDir = getSamDir();
        if (usingUrl)
            setCurrentDir(samDir);
#endif//ndef KNETFILE_HOOKS
        bam_index_t *idx = bam_index_load(bamFileName);
#ifndef KNETFILE_HOOKS
        if (usingUrl)
            setCurrentDir(runDir);
#endif//ndef KNETFILE_HOOKS
        samclose(fh);
        if (idx == NULL)
        {
            warn("bamFileExists: failed to read index corresponding to %s", bamFileName);
            return FALSE;
        }
        free(idx); // Not freeMem, freez etc -- sam just uses malloc/calloc.
        return TRUE;
    }
    return FALSE;
}
/** 
 * Reads the layout info stored in the given (XML) file and creates figure templates.
 * Existing templates remain in where they are but are replaced if a new definition with an existing name is found.
 *
 * @param filename The name of the file to load.
 * @return Returns GC_NO_ERROR if everything was ok, otherwise an error code.
 */
TGCError CGenericCanvas::addLayoutsFromFile(const char* filename)
{
  TGCError result = GC_NO_ERROR;
  xmlNodePtr root, current;
  CFigureParser parser(this);
  parser.addListener(&FListener);

  string currentDir = getCurrentDir();
  xmlDocPtr document = xmlParseFile(utf8ToANSI(string(filename)).c_str());

  if (document == NULL)
    return GC_XML_PARSE_ERROR;

  root = xmlDocGetRootElement(document);

  if (root == NULL)
  {
    xmlFreeDoc(document);
    error(this, "XML Error: Template file is empty.");
    return GC_XML_EMPTY_DOCUMENT;
  }
  
  if (!XML_IS(root, "gc-layouts"))
  {
    xmlFreeDoc(document);
    error(this, "XML Error: Template file invalid.");
    return GC_XML_INVALID_DOCUMENT;
  }

  // Switch to the directory of the given file. This is necessary to make relative file names working.
  string path = extractFilePath(filename);
  setCurrentDir(path);

  // Parse description elements.
  glMatrixMode(GL_MODELVIEW);
  current = root->children;
  while (current != NULL)
  {
    // Be flexible, ignore any unknown layout entries.
    if (XML_IS(current, "layout-definition"))
      parser.parseLayoutDefinition(current, FModel);
    else
      if (XML_IS(current, "connection-definition"))
        parser.parseDecorDefinition(current, FModel);

    current = current->next;
  }

  setCurrentDir(currentDir);
  xmlFreeDoc(document);

  parser.removeListener(&FListener);

  return result;
}
struct fileInfo *listDirX(char *dir, char *pattern, boolean fullPath)
/* Return list of files matching wildcard pattern with
 * extra info. If full path is true then the path will be
 * included in the name of each file. */
{
  struct fileInfo *list = NULL, *el;
  long hFile;
  struct _finddata_t fileInfo;
  boolean otherDir = FALSE;
  char *currentDir;
  int dirNameSize = strlen(dir);
  int fileNameOffset = dirNameSize+1;
  char pathName[512];

  if (dir == NULL || sameString(".", dir) || sameString("", dir))
    dir = "";
  else
    {
      currentDir = getCurrentDir();
      setCurrentDir(dir);
      otherDir = TRUE;
    }

  if (pattern == NULL)
    pattern = "*";
  if( (hFile = _findfirst( pattern, &fileInfo)) == -1L )
    return NULL;

  memcpy(pathName, dir, dirNameSize);
  pathName[dirNameSize] = '/';

  do
    {
      if (!sameString(".", fileInfo.name) && !sameString("..", fileInfo.name))
        {
          char *fileName = fileInfo.name;
          strcpy(pathName+fileNameOffset, fileName);
          if (fullPath)
            fileName = pathName;
          el = newFileInfo(fileInfo.name, fileInfo.size,
                           fileInfo.attrib & _A_SUBDIR, 0,
                           fileInfo.time_access);
          slAddHead(&list, el);
        }
    }
  while( _findnext( hFile, &fileInfo) == 0 );
  _findclose( hFile );
  if (otherDir)
    setCurrentDir(currentDir);
  slSort(&list, cmpFileInfo);
  return list;
}
int main(int argc, char *argv[])
{
optionInit(&argc, argv, options);
if (argc != 9)
    usage("wrong number of args");
if (optionExists("-help"))
    usage("help");

startTag = argv[1];
endTag = argv[2];
startDate = argv[3];
endDate = argv[4];
title = argv[5];
repoDir = argv[6];
outDir = argv[7];
outPrefix = argv[8];

contextSize = optionInt("-context", 15);

userHash = hashNew(5);

setCurrentDir(repoDir);

gitReports();

hashFree(&userHash);
printf("Done.\n");
return 0;
}
Exemple #5
0
// --------------------------------------------------------------------------------------------------------
void KFileTreeWidget::refresh ()
{
    if (current_dir_node) // redisplay the current directory
    {
        std::string currentDirPath = current_dir_node->getAbsPathName();
        removeAllPickables();
        delete current_dir_node;
        current_dir_node = NULL;
        setCurrentDir(currentDirPath);
    }
}
int main(int argc, char *argv[])
/* Process command line. */
{
optionInit(&argc, argv, options);
if (argc != 2)
    usage();
char *workDir = optionVal("workDir", CGI_BIN);
setCurrentDir(workDir);
refreshNamedSessionCustomTracks(argv[1]);
return 0;
}
Exemple #7
0
struct slName *listDir(char *dir, char *pattern)
/* Return an alphabetized list of all files that match 
 * the wildcard pattern in directory. */
{
long hFile;
struct _finddata_t fileInfo;
struct slName *list = NULL, *name;
boolean otherDir = FALSE;
char *currentDir;

if (dir == NULL || sameString(".", dir) || sameString("", dir))
    dir = "";
else
    {
    currentDir = getCurrentDir();
    setCurrentDir(dir);
    otherDir = TRUE;
    }

if (pattern == NULL)
    pattern = *;
if( (hFile = _findfirst( pattern, &fileInfo)) == -1L )
    return NULL;

do
    {
    if (!sameString(".", fileInfo.name) && !sameString("..", fileInfo.name))
        {
        name = newSlName(fileInfo.name);
        slAddHead(&list, name);
        }
    }
while( _findnext( hFile, &fileInfo) == 0 );
_findclose( hFile );
if (otherDir)
    setCurrentDir(currentDir);
slNameSort(&list);
return list;
}
Exemple #8
0
// --------------------------------------------------------------------------------------------------------
void KFileTreeWidget::doubleClicked ()
{
    if (picked_pickable == current_dir_node) return;
    if (((KFileTreeNode*)picked_pickable)->getType() == KDL_FILE_TYPE_DIR)
    {
        setCurrentDir (((KFileTreeNode*)picked_pickable)->getAbsPathName());
    }
    else
    {
        notifyReceivers (((KFileTreeNode*)picked_pickable)->getAbsPathName(), KDL_NOTIFICATION_TYPE_OPEN_FILE);
        notifyReceivers ();
    }
}
Exemple #9
0
void bamFetch(char *fileOrUrl, char *position, bam_fetch_f callbackFunc, void *callbackData,
              samfile_t **pSamFile)
/* Open the .bam file, fetch items in the seq:start-end position range,
 * and call callbackFunc on each bam item retrieved from the file plus callbackData.
 * This handles BAM files with "chr"-less sequence names, e.g. from Ensembl.
 * The pSamFile parameter is optional.  If non-NULL it will be filled in, just for
 * the benefit of the callback function, with the open samFile.  */
{
    char *bamFileName = NULL;
    samfile_t *fh = bamOpen(fileOrUrl, &bamFileName);
    boolean usingUrl = TRUE;
    usingUrl = (strstr(fileOrUrl, "tp://") || strstr(fileOrUrl, "https://"));
    if (pSamFile != NULL)
        *pSamFile = fh;
#ifndef KNETFILE_HOOKS
// Since samtools' url-handling code saves the .bai file to the current directory,
// chdir to a trash directory before calling bam_index_load, then chdir back.
    char *runDir = getCurrentDir();
    char *samDir = getSamDir();
    if (usingUrl)
        setCurrentDir(samDir);
#endif//ndef KNETFILE_HOOKS
    bam_index_t *idx = bam_index_load(bamFileName);
#ifndef KNETFILE_HOOKS
    if (usingUrl)
        setCurrentDir(runDir);
#endif//ndef KNETFILE_HOOKS
    if (idx == NULL)
        warn("bam_index_load(%s) failed.", bamFileName);
    else
    {
        bamFetchAlreadyOpen(fh, idx, bamFileName, position, callbackFunc, callbackData);
        free(idx); // Not freeMem, freez etc -- sam just uses malloc/calloc.
    }
    bamClose(&fh);
}
Exemple #10
0
void newProg(char *module, char *description)
/* newProg - make a new C source skeleton. */
{
char fileName[512];
char dirName[512];
char fileOnly[128];

safef(dirName, sizeof(dirName), "%s", module);
makeDir(dirName);
splitPath(dirName, NULL, fileOnly, NULL);
safef(fileName, sizeof(fileName), "%s/%s.c", dirName, fileOnly);
makeC(fileOnly, description, fileName);

/* makefile is now constructed properly with ../.. paths */
setCurrentDir(dirName);
makeMakefile(fileOnly, "makefile");
}
Exemple #11
0
// --------------------------------------------------------------------------------------------------------
void KFileTreeWidget::menuCallback ( const std::string & itemText )
{
    if (itemText == "show more")
    {
        KFileTreeDir::max_path_depth++;
        refresh();
        return;
    }
    else if (itemText == "show less")
    {
        if (KFileTreeDir::max_path_depth <= 1) return;
        KFileTreeDir::max_path_depth--;
        refresh();
        return;
    }    

    KFileTreeDir * dir;
    if (picked_pickable)
    {
        if (((KFileTreeNode*)picked_pickable)->getType() == KDL_FILE_TYPE_DIR)
        {
            dir = (KFileTreeDir*)picked_pickable;
    
            if (itemText == "cd")
            {
                if (dir != current_dir_node) 
                {
                    setCurrentDir(dir->getAbsPathName());
                }
                return;
            }
            else if (itemText == "show texture(s)")
            {
            }
        }
        else
        {
            if (itemText == "show texture(s)")
            {
                
            }
        }
    }
}
void wigTestMaker(char *outDir)
/* wigTestMaker - Create test wig files.. */
{
makeDir(outDir);
setCurrentDir(outDir);
makeChromSizes("chrom.sizes", 100);
makeEmpty("empty.wig");
makeEmptyFixed("emptyFixed.wig");
makeEmptyVar("emptyVar.wig");
makeShortFixed("shortFixed.wig");
makeShortVar("shortVar.wig");
makeShortBed("shortBed.wig");
makeSineSineFixed("sineSineFixed.wig", 1000, 500, 10, 8);
makeSineSineVar("sineSineVar.wig", 1000, 500, 10, 4);
makeSineSineBed("sineSineBed.wig", 1000, 500, 10, 2);
makeIncreasing("increasing.wig");
makeMixem("mixem.wig");
makeContigSizes("contig.sizes", 666666);
makeManyContigs("contigs.wig", 666666);
}
Exemple #13
0
fs_node_t *initialise_initrd(u32int location)
{
  fs_location = kmalloc(FS_SIZE);

  u32int tempLoc = kmalloc(initrd_end - initrd_location); //random size, make it defined

  /*size = the size of the initrd module (address of end - address of start),
   * end and start are defined by the bootloader*/
  memcpy(tempLoc, location, initrd_end - initrd_location);

  // Initialise the main and file header pointers and populate the root directory.
  initrd_header = (initrd_header_t *)tempLoc; //first part of location is the number of headers (in struct)

  //the location offset with the struct that contains the number of headers
  file_headers = (initrd_file_header_t *)(tempLoc + sizeof(initrd_header_t));

  // Initialise the root directory.
  initrd_root = (fs_node_t*)kmalloc(sizeof(fs_node_t));
  strcpy(initrd_root->name, "/");

  initrd_root->magic = M_VFS;
  initrd_root->mask = initrd_root->uid = initrd_root->gid = initrd_root->inode = initrd_root->length = 0;
  initrd_root->flags = FS_DIRECTORY;
  initrd_root->read = 0;
  initrd_root->write = 0;
  initrd_root->readdir = &initrd_readdir;
  initrd_root->finddir = &initrd_finddir;
  initrd_root->ptr = 0;
  initrd_root->impl = 0;

  //allocate space for the root nodes, default 32KB size
  root_nodes = (fs_node_t*)kmalloc(sizeof(fs_node_t) * (0x8000));
  nroot_nodes = initrd_header->nfiles;

  // For every file...
  u32int i, a, allocSize, nBlocks;
  u32int block;
  for(i = 0; i < initrd_header->nfiles; i++)
  {
    // Edit the file's header - currently it holds the file offset
    // relative to the start of the ramdisk. We want it relative to the start
    // of memory.
    file_headers[i].offset += tempLoc;
    // Create a new file node.
    strcpy(root_nodes[i].name, &file_headers[i].name);

    root_nodes[i].magic = M_VFS;
    root_nodes[i].mask = 0b110110100; //user rw, group rw, other r
    root_nodes[i].uid = root_nodes[i].gid = 0;
    root_nodes[i].length = 0;
    //~ root_nodes[i].length = file_headers[i].length;
    root_nodes[i].inode = i;
    root_nodes[i].flags = FS_FILE;
    root_nodes[i].read = &initrd_read;
    root_nodes[i].write = &initrd_write;
    root_nodes[i].readdir = 0;
    root_nodes[i].finddir = 0;
    root_nodes[i].impl = 0;

    //calculates the number of blocks this file has
    nBlocks = ((u32int)((file_headers[i].length - 1) / BLOCK_SIZE) + 1);

    for(a = 0; a < nBlocks; a++)
    {
      /* /\* This section copies the file's data into the blocks of the node
       *  *
       *  * ((u32int)(root_nodes[i].length / BLOCK_SIZE) + 1) calculates the
       *  * number of blocks this file will take up at a given length
       *  * the rootnode[i].length -1 is to offset that the first bit is at position 0*\/
       * for(a = 0; a < nBlocks; a++)
       * {
       *   /\*This section allocates memory for any initial sets apart from
       *    * the direct blocks, as by default, the set pointers in fs_node_t
       *    * typedef point to nowhere *\/
       *   //if this file only has a singly set
       *   if(a >= BLOCKS_DIRECT && a < BLOCKS_DIRECT + BLOCKS_SINGLY)
       *   {
       *     //allocate the singly typedef
       *     if(!root_nodes[i].singly)
       *     {
       *       root_nodes[i].singly = (u32int*)kmalloc(BLOCK_SIZE);
       * 
       *       //clear the singly block of any junk
       *       memset(root_nodes[i].singly, 0x0, BLOCK_SIZE);
       *     }
       * 
       *     //if this file has a singly set and a doubly set
       *   }else if(a >= BLOCKS_DIRECT + BLOCKS_SINGLY &&
       *            a < BLOCKS_DIRECT + BLOCKS_SINGLY + BLOCKS_DOUBLY)
       *   {
       *     //allocate the doubly typedef
       *     if(!root_nodes[i].doubly)
       *     {
       *       root_nodes[i].doubly = (u32int*)kmalloc(BLOCK_SIZE);
       * 
       *       //clear the doubly block of any junk
       *       memset(root_nodes[i].doubly, 0x0, BLOCK_SIZE);
       *     }
       *     //the doubly_offset is the offset of the doubly block's node pointing towards the singly block          
       *     u32int doubly_offset;
       *     doubly_offset = (a - (BLOCKS_DIRECT + BLOCKS_SINGLY)) / BLOCKS_SINGLY;
       * 
       *     //allocate the singly typedef
       *     if(!*(root_nodes[i].doubly + doubly_offset))
       *       *(root_nodes[i].doubly + doubly_offset) = kmalloc(BLOCK_SIZE);
       * 
       *     //if this file has a singly set, a doubly set, and a triply set
       *   }else if(a >= BLOCKS_DIRECT + BLOCKS_SINGLY + BLOCKS_DOUBLY&&
       *            a < BLOCKS_DIRECT + BLOCKS_SINGLY + BLOCKS_DOUBLY + BLOCKS_TRIPLY)
       *   {
       * 
       *     //allocate the triply typedef
       *     if(!root_nodes[i].triply)
       *       root_nodes[i].triply = (u32int*)kmalloc(BLOCK_SIZE);
       * 
       *     //disregard the other blocks
       *     u32int offset = a - (BLOCKS_DIRECT + BLOCKS_SINGLY + BLOCKS_DOUBLY);
       * 
       *     /\*trpily_offset is the offset in the triply block of the node pointing to the doubly block, 
       *      * the doubly_offset is the offset inside the doubly block of the triply block that points to the
       *      * singly block*\/
       * 
       *     u32int triply_offset = (offset) / BLOCKS_DOUBLY;
       *     u32int doubly_offset = (offset % BLOCKS_DOUBLY) / BLOCKS_DOUBLY;
       * 
       *     //allocate the doubly typedef
       *     if(!*(root_nodes[i].triply + triply_offset))
       *       *(root_nodes[i].triply + triply_offset) = kmalloc(BLOCK_SIZE);          
       * 
       *     //allocate the singly typedef
       *     if(!*((u32int*)*(root_nodes[i].triply + triply_offset) + doubly_offset))
       *       *((u32int*)*(root_nodes[i].triply + triply_offset) + doubly_offset) = kmalloc(BLOCK_SIZE);
       * 
       *   } */

      //~ k_printf("a is : %d, size %d\n", a, file_headers[i].length);
 
      //get the size of data to copy
      allocSize = blockSizeAtIndex(file_headers[i].length, a, 0);

      expand_node(&root_nodes[i], allocSize);

      //get the address of the block to write to
      block = (u32int)block_of_set(&root_nodes[i], a);

      /*The following examples assume that we are in the direct blocks of the node
       * the concept is the same for the indirect blocks
       *
       * (u32int*)block points to the address of the rootnodes[i].blocks[a]
       * e.g. &rootnodes[i].blocks[a]
       *
       * then the *(u32int*)block is the value of that address, i.e. it impersonates
       * that it (u32int block) is rootnodes[i].blocks[a], although
       * they are found at different memory locations, same concept with hard links */

      //allocate space for a block
      *(u32int*)block = kmalloc(BLOCK_SIZE);

      //copy the data to that block
      memcpy(*(u32int*)block, file_headers[i].offset + a * BLOCK_SIZE, allocSize);
    
    }
  }

  initrd_dev = vfs_createDirectory(initrd_root, "/");

  addHardLinkToDir(initrd_dev, initrd_dev, "."); //adds hardlink for root
  addHardLinkToDir(initrd_dev, initrd_dev, ".."); //adds hardlink for root

  setCurrentDir(initrd_dev);

  //create the /dev directory for the virtual files
  fs_node_t *dev = vfs_createDirectory(initrd_dev, "dev");

  //create and open the stdin, stdout, and stderr files and file descriptors
  fs_node_t *stdin = vfs_createFile(dev, "stdin", 1024);
  fs_node_t *stdout = vfs_createFile(dev, "stdout", 1024);
  fs_node_t *stderr = vfs_createFile(dev, "stderr", 1024);

  //create the /etc directory
  fs_node_t *etc = vfs_createDirectory(initrd_dev, "etc");

  //set the initial file descriptor
  initial_fdesc = (file_desc_t*)kmalloc(sizeof(file_desc_t));

  //set the mask for "rw", read and write
  initial_fdesc->permisions = FDESC_READ | FDESC_WRITE;
  initial_fdesc->node = stdin;
  initial_fdesc->next = 0;

  //open the std files, stdin has alreadt been open when setting the initial file_desc
  if(!f_open("stdout", dev, "rw") || !f_open("stderr", dev, "rw"))
  {
    //some sort of error
    kfree((void*)tempLoc);
    return 0;
  }

  //assigns all of the files that were in the file_headers to this dev directory
  for(i = 0; i < initrd_header->nfiles; i++)
    addFileToDir(initrd_dev, &root_nodes[i]);

  kfree((void*)tempLoc);

  return initrd_dev;
}
int main(int argc, char *argv[])
/* Process command line. */
{
struct sqlConnection *conn = NULL;
char *command = NULL;
optionInit(&argc, argv, options);
database = optionVal("database", database);
sqlPath = optionVal("sqlPath", sqlPath);
if (argc < 2)
    usage();
command = argv[1];
if (argc >= 3)
    setCurrentDir(argv[2]);
conn = sqlConnect(database);
if (sameWord(command,"INIT"))
    {
    if (argc != 2)
	usage();
    errAbort("INIT is probably too dangerous. DO NOT USE.");
    /*	    
    init(conn);	    
    */
    }
else if (sameWord(command,"POP"))
    {
    if (argc != 2)
	usage();
    /* populate vgPrb where missing */
    populateMissingVgPrb(conn);
    }
else if (sameWord(command,"SEQ"))
    {
    if (argc != 4)
	usage();
    /* make fake probe sequences */
    makeFakeProbeSeq(conn,argv[3]);
    }
else if (sameWord(command,"ALI"))
    {
    if (argc != 4)
	usage();
    /* blat anything left that is not aligned, 
      nor even attempted */
    doAlignments(conn,argv[3]);
    }
else if (sameWord(command,"EXT"))
    {
    if (argc != 4)
	usage();
    /* update seq and extfile as necessary */
    doSeqAndExtFile(conn,argv[3],"vgProbes");
    }
else if (sameWord(command,"PSLMAP"))
    {
    if (argc != 5)
	usage();
    /* pslMap anything left that is not aligned, 
      nor even attempted */
    doAlignmentsPslMap(conn,argv[3],argv[4]);
    }
else if (sameWord(command,"REMAP"))
    {
    if (argc != 7)
	usage();
    /* re-map anything in track specified that is not aligned, 
      nor even attempted yet, using specified fasta file. */
    doAlignmentsReMap(conn,argv[3],argv[4],argv[5],argv[6]);
    }
else if (sameWord(command,"SELFMAP"))
    {
    if (argc != 4)
	usage();
    /* re-map anything in track specified that is not aligned, 
      nor even attempted yet, using specified fasta file. */
    doAlignmentsSelfMap(conn,argv[3]);
    }
else if (sameWord(command,"EXTALL"))
    {
    if (argc != 4)
	usage();
    /* update seq and extfile as necessary */
    doSeqAndExtFile(conn,argv[3],"vgAllProbes");
    }
else
    usage();
sqlDisconnect(&conn);
return 0;
}
/** 
 * Reads the style template info stored in the given (XML) file and creates style templates (OpenGL display lists).
 * Existing templates remain where they are but are replaced if a new definition with an existing name is found.
 *
 * @param filename The name of the file to load.
 * @param variables A set of name/value pairs to be replaced in the xml text.
 * @return Returns GC_NO_ERROR if everything was ok, otherwise an error code.
 */
TGCError CGenericCanvas::addStylesFromFile(const char* filename, map<wstring, wstring>& variables)
{
  TGCError result = GC_NO_ERROR;
  xmlNodePtr root, current;
  CSVGParser parser;
  xmlDocPtr document = NULL;
  string currentDir = getCurrentDir();
  
  if (!variables.empty())
  {
    char *data;
    size_t length;

    data= preprocessFile(filename, variables, length);
    if (data)
    {
      document = xmlParseMemory(data, (int) length);
      free(data);
    }
  }
  else
    document = xmlParseFile(utf8ToANSI(filename).c_str());

  if (document == NULL)
    return GC_XML_PARSE_ERROR;                       

  root = xmlDocGetRootElement(document);

  if (root == NULL)
  {
    xmlFreeDoc(document);
    error(this, "XML Error: Template file is empty.");
    return GC_XML_EMPTY_DOCUMENT;
  }
  
  if (!XML_IS(root, "gc-styles"))
  {
    xmlFreeDoc(document);
    error(this, "XML Error: Template file invalid.");
    return GC_XML_INVALID_DOCUMENT;
  }

  // Switch to the directory of the given file. This is necessary to make relative file names working.
  string path = extractFilePath(filename);
  setCurrentDir(path);

  // Parse description elements.
  glMatrixMode(GL_MODELVIEW);
  current = root->children;
  while (current != NULL)
  {
    // Be flexible, ignore any unknown layout entries.
    if (XML_IS(current, "style-definition"))
    {
      parser.parseDefinition(current, FModel);
    }
    else
      if (XML_IS(current, "texture"))
      {
        // Adds a new texture to the texture list.
        parseTextureEntry(current, FModel);
        checkError();
      };
    current = current->next;
  }

  setCurrentDir(currentDir);
  xmlFreeDoc(document);

  return result;
}
void cdwFakeManifestFromSubmit(char *submitIdString, char *outDir)
/* cdwFakeManifestFromSubmit - Create a fake submission based on a real one that is in the warehouse. */
{
struct sqlConnection *conn = cdwConnect();
char query[512];
sqlSafef(query, sizeof(query), "select * from cdwSubmit where id=%s", submitIdString);
struct cdwSubmit *submit = cdwSubmitLoadByQuery(conn, query);
if (submit == NULL)
    errAbort("Can't find submission %s", submitIdString);

uglyf("%d files in query\n", submit->newFiles);
sqlSafef(query, sizeof(query), "select * from cdwFile where submitId=%s", submitIdString);
struct cdwFile *ef, *efList = cdwFileLoadByQuery(conn, query);

FILE *maniF = NULL, *valiF = NULL;
for (ef = efList; ef != NULL; ef = ef->next)
    {
    struct cdwValidFile *vf = cdwValidFileFromFileId(conn, ef->id);
    if (vf != NULL)
        {
	/* First time through create out directory and open output files. */
	if (maniF == NULL)
	    {
	    char *fakeVersion = "##validateManifest version 1.7";
	    makeDirsOnPath(outDir);
	    setCurrentDir(outDir);
	    maniF = mustOpen("manifest.txt", "w");
	    printSharedHeader(maniF);
	    fprintf(maniF, "\n");
	    fprintf(maniF, "%s\n", fakeVersion);
	    valiF = mustOpen("validated.txt", "w");
	    printSharedHeader(valiF);
	    fprintf(valiF, "\tmd5_sum\tsize\tmodified\tvalid_key\n");
	    fprintf(valiF, "%s\n", fakeVersion);
	    }

	/* Figure out file names */
	char cdwPath[PATH_LEN], rootName[FILENAME_LEN], ext[FILEEXT_LEN];
	safef(cdwPath, sizeof(cdwPath), "%s%s", cdwRootDir, ef->cdwFileName);
	splitPath(ef->cdwFileName, NULL, rootName, ext);
	char localPath[PATH_LEN];
	safef(localPath, sizeof(localPath), "%s%s", rootName, ext);

	/* Create sym-linked file and write to manifest */
	symlink(cdwPath, localPath);
	fprint2(maniF, valiF, "%s", localPath);

	/* Write other columns shared between manifest and validated */
	fprint2(maniF, valiF, "\t%s", vf->format);
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->outputType));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->experiment));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->enrichedIn));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->ucscDb));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->replicate));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->part));
	fprint2(maniF, valiF, "\t%s", naForEmpty(vf->pairedEnd));
	fprintf(maniF, "\n");

	/* Print out remaining fields in validated.txt */
	fprintf(valiF, "\t%s\t%lld\t%lld\n", ef->md5, ef->size, ef->updateTime);
	}
    }
carefulClose(&maniF);
carefulClose(&valiF);
}
Exemple #17
0
axStatus	axFileSystem::setCurrentDirSameAsFile	( const wchar_t*	filename ) {
	axStringW_<256> str;
	axFilePath::dirName( str, filename );
	return setCurrentDir( str );
}