示例#1
0
  /**
  ** makePath - ensure all directories in path exist
  ** Algorithm takes the pessimistic view and works top-down to ensure
  ** each directory in path exists, rather than optimistically creating
  ** the last element and working backwards.
  */
  bool makePath(const char* path, mode_t mode)
  {

    char           *pp;
    char           *sp;
    int             status;
    char           *copypath = strdup(path);

    status = 0;
    pp = copypath;
    while (status == 0 && (sp = strchr(pp, '/')) != 0)
    {
        if (sp != pp)
        {
            /* Neither root nor double slash in path */
            *sp = '\0';
            status = makeDir(copypath, mode);
            *sp = '/';
        }
        pp = sp + 1;
    }
    if (status == 0)
        status = makeDir(path, mode);
    free(copypath);
    return (status);

  }
示例#2
0
static char *getPartPslFile(char *outDir, int partNum)
/* compute the name for the partition psl file, creating directories.
 * freeMem result */
{
    struct dyString *partPath = dyStringNew(128);
    char partStr[64];
    int i, partStrLen;

    /* part number, with leading zeros */
    safef(partStr, sizeof(partStr), "%0*d", gOutLevels, partNum);
    partStrLen = strlen(partStr);

    dyStringAppend(partPath, outDir);
    makeDir(partPath->string);

    /* create with multiple levels of directories, with least-signficant part of
     * number being lowest directory */
    for (i = 0; i < gOutLevels; i++)
    {
        dyStringAppendC(partPath, '/');
        dyStringAppendC(partPath, partStr[(partStrLen-gOutLevels)+i]);
        makeDir(partPath->string);
    }
    dyStringAppendC(partPath, '/');
    dyStringAppend(partPath, partStr);
    dyStringAppend(partPath, ".psl");

    return dyStringCannibalize(&partPath);
}
示例#3
0
/* Main */
void 
main(){

	/* Init Disco Virtual */
	vDisk = (virtualDisk*)malloc(sizeof(virtualDisk));
	vDisk->disk = (void *)malloc(DISK_SIZE);

	/* Init Global Variables */	
	masterBootRecord * mbr = (masterBootRecord *)malloc(512);
	superblock = (masterBlock*)malloc(512);		
	bitmap = (BM*)calloc(BITMAP_SIZE,1);	
	inodemap = (IM*)calloc(INODEMAP_SIZE,1);
	
	
	
	/* Create & Init File System */
	mbr = (masterBootRecord *)read_disk(vDisk->disk,0,mbr,BLOCK_SIZE,0);

	if ( mbr->existFS == 0 ){
		init_filesystem("Chinux", mbr);
	}else{
		load_filesystem();
	}

	printf("mbr:%d\n",mbr->existFS);
	superblock = read_disk(vDisk->disk,1,superblock,BLOCK_SIZE,0);
	printf("name:%s\nblock:%d\nfreeBlocks:%d\nusedBlocks:%d\n",superblock->name, superblock->blockSize, superblock->freeBlocks, superblock->usedBlocks);
	printf("InodeSize:%d\n",sizeof(iNode));
	printf("Directory:%d\n",sizeof(directoryEntry));//16 Directorios o archivos en bloques directos..

	iNode * nodo = fs_creat_inode(DIRECTORY,777,512,superblock->root);
	fs_insert_inode(nodo);
	iNode * nodo3 = fs_creat_inode(DIRECTORY,737,512,superblock->root);
	fs_insert_inode(nodo3);

	//nodo->iNode_number = 20;
	printf("\n\nTABLA DATOS\n");
	printf("inode-number:%d\n",nodo->iNode_number);		
	printf("mode:%d\n",nodo->mode);
	printf("size:%d\n",nodo->size);
	printf("iden:%d\n",nodo->identifier);

	
	iNode * nodo2 = fs_get_inode(nodo->iNode_number);
	printf("inode-number:%d\n",nodo->iNode_number);		
	printf("mode:%d\n",nodo2->mode);
	printf("size:%d\n",nodo2->size);
	printf("iden:%d\n",nodo2->identifier);

	insert_directory("Hola",superblock->root);
	//ls("asd");
	makeDir("comostas");
	print_directories(superblock->root);
	makeDir("Hola/Comocomo");
	cd("Hola");
	print_directories(current);

	
}
示例#4
0
文件: rfs.c 项目: karajrish/OS
//============= TESTING APPLICATION USING THESE FS CALLS ==============
// Menu driven testing application for creation of fs, 
// and all file and directory related operations
int main(int argc, char** argv){
	int fd = openDevice(0);
	init_FS(fd);
	makeDir(fd, "Folder 1", 1, 1, 1);
	makeDir(fd, "Folder 2", 1, 1, 1);
	makeDir(fd, "Folder 3", 1, 1, 1);
	removeDir(fd, "Folder 2");
	int dirhandle = openDir(fd, "Folder 1");
	closeDir(dirhandle);
	shutdownDevice(0);
}
bool
ComponentImplementation::install ()
{
    //
	// if already installed increment counter only
	//
	if (installation_count_)
	{
		installation_count_++;
		return true;
	}

	//
	// create directories for the component implementation
	//
	makeDir(installation_dir_);
    makeDir(build_dir_);

	//
	// get info from the software package
    //
	CSDReader reader;
	try 
	{
		reader.readCSD( package_, &data_, build_path_ );
	}
	catch( CSDReadException ) 
	{
		removeFileOrDirectory(installation_dir_);
		removeFileOrDirectory(build_dir_);
        return false;
	}

    //
	// install code for servants and executors
	//
    try	
	{
		installCode();
	}
	catch( Components::CreateFailure )
	{
		removeFileOrDirectory(installation_dir_);
		removeFileOrDirectory(build_dir_);
        return false;
	}

	// increment installation counter ( to 1 )
	installation_count_++;

	return true;
}
示例#6
0
void splitSeqFile(char *inputFileName, char *logFileName, char *outputDirBasename, int filesPerDir)
{
FILE *outputFileHandle = NULL;
FILE *logFileHandle = mustOpen(logFileName, "w");
char outputFileName[64];
char dirName[64];
int fileCount = 0;
int dirCount = 0;
struct lineFile *lf = lineFileOpen(inputFileName, TRUE);
char *line;
int lineSize;
boolean firstLine = TRUE;
char *row[9], *rsId[2];

safef(dirName, sizeof(dirName), "%s-%d", outputDirBasename, dirCount);
makeDir(dirName);

while (lineFileNext(lf, &line, &lineSize))
    {
    if (line[0] == '>')
        {
	if (!firstLine)
	    carefulClose(&outputFileHandle);
	else
	    firstLine = FALSE;
        fileCount++;
	if (fileCount == filesPerDir)
	    {
	    fileCount = 0;
	    dirCount++;
            safef(dirName, sizeof(dirName), "%s-%d", outputDirBasename, dirCount);
            makeDir(dirName);
	}
	/* use rsId for filename */
	chopString(line, "|", row, ArraySize(row));
	chopString(row[2], " ", rsId, ArraySize(rsId));
        safef(outputFileName, sizeof(outputFileName), "%s/%s", dirName, rsId[0]);
        outputFileHandle = mustOpen(outputFileName, "w");
        fprintf(logFileHandle, "%s\t%s/%s\n", rsId[0], dirName, rsId[0]);
	}
    else
       fprintf(outputFileHandle, "%s\n", line);
    }

carefulClose(&outputFileHandle);
carefulClose(&logFileHandle);
lineFileClose(&lf);
}
示例#7
0
/**
 * @brief RsCollectionDialog::eventFilter: Proccess event in object
 * @param obj: object where event occured
 * @param event: event occured
 * @return If we don't have to process event in parent.
 */
bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
{
	if (obj == ui._fileEntriesTW) {
		if (event->type() == QEvent::KeyPress) {
			QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
			if (keyEvent && (keyEvent->key() == Qt::Key_Space)) {
				// Space pressed

				// get state of current item
				QTreeWidgetItem *item = ui._fileEntriesTW->currentItem();
				if (item) {
					Qt::CheckState checkState = (item->checkState(COLUMN_FILE) == Qt::Checked) ? Qt::Unchecked : Qt::Checked;

					// set state of all selected items
					QList<QTreeWidgetItem*> selectedItems = ui._fileEntriesTW->selectedItems();
					QList<QTreeWidgetItem*>::iterator it;
					for (it = selectedItems.begin(); it != selectedItems.end(); ++it) {
						if ((*it)->checkState(COLUMN_FILE) != checkState)
							(*it)->setCheckState(COLUMN_FILE, checkState);
					}//for (it
				}//if (item)

				return true; // eat event
			}//if (keyEvent && keyEvent->key() == Qt::Key_Space)

			if (keyEvent && (keyEvent->key() == Qt::Key_Delete)) {
				// Delete pressed
				remove();
				return true; // eat event
			}//if (keyEvent && keyEvent->key() == Qt::Key_Delete)

			if (keyEvent && (keyEvent->key() == Qt::Key_Plus)) {
				// Plus pressed
				makeDir();
				return true; // eat event
			}//if (keyEvent && keyEvent->key() == Qt::Key_Plus)

		}//if (event->type() == QEvent::KeyPress)
	}//if (obj == ui._fileEntriesTW)

	if (obj == ui._systemFileTW) {
		if (event->type() == QEvent::KeyPress) {
			QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
			if (keyEvent && ((keyEvent->key() == Qt::Key_Enter)
			                 || keyEvent->key() == Qt::Key_Return)) {
				// Enter pressed
				if (keyEvent->modifiers() == Qt::ShiftModifier)
					addRecursive();
				else if(keyEvent->modifiers() == Qt::NoModifier) {
					add();
				}

				return true; // eat event
			}//if (keyEvent && keyEvent->key() == Qt::Key_Enter...
		}//if (event->type() == QEvent::KeyPress)
	}//if (obj == ui._systemFileTW)

	// pass the event on to the parent class
	return QDialog::eventFilter(obj, event);
}
void splitNcbiFa(char *ncbiIn, char *outDir)
/* splitNcbiFa - Split up NCBI format fa file into UCSC formatted ones.. */
{
struct lineFile *lf = lineFileOpen(ncbiIn, TRUE);
static struct dnaSeq seq;
ZeroVar(&seq);

makeDir(outDir);
while (faSpeedReadNext(lf, &seq.dna, &seq.size, &seq.name))
    {
    FILE *f;
    char fileName[512];
    char *row[5];
    int wordCount;
    char ourName[129];
    char cloneName[128];

    wordCount = chopByChar(seq.name, '|', row, ArraySize(row));
    if (wordCount != 5)
        errAbort("Expecting 5 | separated fields line %d of %s", lf->lineIx, lf->fileName);
    strcpy(cloneName, row[3]);
    chopSuffix(cloneName);
    sprintf(fileName, "%s/%s.fa", outDir, cloneName);
    sprintf(ourName, "%s_1", row[3]);
    faWrite(fileName, ourName, seq.dna, seq.size);
    }
}
示例#9
0
int main(int argc, char** arg) {
	_controller = new DBController();
	char currentDir[256];
	memset(currentDir, 0, 256);
	getcwd(currentDir, 256);
	printf("%s\n", currentDir);
	char* datadir = combinePath(currentDir, "datadir/");
	boost::filesystem::remove_all(datadir);
	makeDir(datadir);
	setSetting("DATA_DIR", std::string(datadir));
	_controller->initialize(datadir);

	/*
	testTransactionSimplest();
	testTransaction();
	testTransactionSimpleCommit();
	testTransactionCommit();
	testTransactionRollback();
	testTransactionManager();
	testTransactionMergedData();
	*/
	_controller->shutdown();
	free(datadir);
	return 0;
}
示例#10
0
void mafsInRegion(char *regionFile, char *out, int mafCount, char *mafFiles[])
/* Extract MAFs in regions listed in regin file */
{
int i = 0;
struct hash *bedHash = NULL;
FILE *f = NULL;
struct mafFile *mf = NULL;

verbose(1, "Extracting from %d files to %s\n", mafCount, out);
bedHash = loadRegions(regionFile);

/* get scoring scheme */
mf = mafOpen(mafFiles[0]);
if (!mf)
    errAbort("can't open MAF file: %s\n", mafFiles[0]);
scoring = cloneString(mf->scoring);
mafFileFree(&mf);

/* set up output dir */
if (outDir)
    {
    dir = out;
    makeDir(dir);
    }
else
    f = startOutFile(out);
for (i = 0; i < mafCount; i++)
    extractMafs(mafFiles[i], f, bedHash);
if (!outDir)
    endOutFile(f);
}
void mkOutPath(char *outPath, char* outRoot, int digits, int fileCount)
/* generate output file name */
{
char dir[PATH_LEN], fname[PATH_LEN];
splitPath(outRoot, dir, fname, NULL);

strcpy(outPath, dir);
if (outDirDepth > 0)
    {
    /* add directory levels, using training digits for names */
    char fcntStr[64], dirBuf[3];
    int i, iDir;
    safef(fcntStr, sizeof(fcntStr), "%0*d", outDirDepth, fileCount);
    iDir = strlen(fcntStr)-outDirDepth;
    strcpy(dirBuf, "X/");
    for (i = 0; i < outDirDepth; i++, iDir++)
        {
        dirBuf[0] = fcntStr[iDir];
        strcat(outPath, dirBuf);
        makeDir(outPath);
        }
    }

if (digits)
    sprintf(outPath+strlen(outPath), "%s%0*d.fa", fname, digits, fileCount);
}
示例#12
0
文件: iox.c 项目: misaka-mikoto/bkx
int fileCopy(char *sorceFile,char *targetFile)
{
    FILE *sF,*oF;
    char buffer[1024]= {0};
    int len;
    makeDir(targetFile);
    if((sF=fopen(sorceFile,"r"))==NULL)
    {
        ERROR(6);
    }
    else if((oF=fopen(targetFile,"w"))==NULL)
    {
        ERROR(6);
    }
    else
    {
        while((len=fread(buffer,1,1024,sF))>0)
        {
            fwrite(buffer,1,len,oF);
            memset(buffer,0,1024);
        }
        fclose(oF);
        fclose(sF);
        return 1;
    }
    return 0;
}
示例#13
0
void eapToHub(char *outDir)
/* eapToHub - Convert some analysis results to a hub for easy viz.. */
{
struct sqlConnection *conn = eapConnect();
struct eapGraph *eg = eapGraphNew(conn);
makeDirsOnPath(outDir);
char path[PATH_LEN];
safef(path, sizeof(path), "%s/%s", outDir, "hub.txt");
writeHubTxt(conn, path);
safef(path, sizeof(path), "%s/%s", outDir, "genomes.txt");
writeGenomesTxt(conn, path);
int i;
struct edwExperiment *eeList = getUwDnaseExps(conn);
for (i=0; i<ArraySize(assemblyArray); ++i)
    {
    char *a = assemblyArray[i];
    safef(path, sizeof(path), "%s/%s", outDir, a);
    makeDir(path);
    safef(path, sizeof(path), "%s/%s/%s", outDir, a, "trackDb.txt");
    struct fullExperiment *expList = getGoodExperiments(conn, eeList, a);
    slSort(&expList, fullExperimentCmp);
    writeTrackDbTxt(conn, eg, expList, a, path);
    safef(path, sizeof(path), "%s/%s/%s", outDir, a, "table.html");
    writeTableHtml(conn, eg, expList, a, path);
    safef(path, sizeof(path), "%s/%s/%s", outDir, a, "fastq.tab");
    writeFastqTab(conn, eg, expList, a, path);
    }
}
示例#14
0
void initWorld() {
	// number of bytes needed to hold the root world path
	savePathLength = strlen(WORLD_DB_PATH);

	// Create the root world directory
	makeDir(WORLD_DB_PATH);
}
示例#15
0
文件: c.c 项目: AlwaysLately/c
// Prints the comment for the current directory
void printCurrentComment(const char *path) {
	makeDir(path);
	// Append /.comment to the end of the current path
	// Append ..comment to the end of that path
	char *fin = NULL;
	asprintf(&fin, "%s/" COMMENT "/" DOT ".comment", path);

	if (dirOrFileExists(fin)) {
		// Open that file to print the conents
		FILE *fp;
		char ch;
		char newch[1000];
		fp = fopen(fin, "r");
		int i = 0;
		while (1) {
			ch = fgetc(fp);
			newch[i] = ch;
			if (ch == EOF) {
				newch[i] = '\0';
				break;
			}
			i++;
		}
		printf(BLUE "Current Directory:" RESETCOLOR "\t");
		put_multiline(newch, 50);
		printf("\n");

		fclose(fp);
	} else {
		printf(BLUE "Current directory" RESETCOLOR "\thas no comment\n");
	}

	free(fin);
}
示例#16
0
void saveBlock(block_s * block)
{
	// Get region path
	char * regionPath;
	int regionPathLength = setRegionPath(&regionPath, 0, 0);

	// Make the path
	makeDir(regionPath);

	// Get chunk path
	char * chunkPath;
	setChunkPath(&chunkPath, regionPath, regionPathLength, block->cx, block->cy);

	uv_fs_t open_req;
	uv_fs_t write_req;
	uv_fs_t close_req;

	// store type in buffer
	unsigned char typeBuffer[2];
	shortToBuffer(4, 0, typeBuffer);

	// Open
	uv_fs_open(uv_default_loop(), &open_req, chunkPath,  O_WRONLY | O_CREAT, 0700, NULL);
	uv_fs_req_cleanup(&open_req);

	uv_fs_write(uv_default_loop(), &write_req, open_req.result, typeBuffer, 2,(block->z * 512 + ((block->x  * 2) + block->y * 16 * 2)), NULL);
	uv_fs_req_cleanup(&write_req);

	// Close
	uv_fs_close(uv_default_loop(), &close_req, open_req.result, NULL);
	uv_fs_req_cleanup(&close_req);

	free(regionPath);
	free(chunkPath);
}
示例#17
0
AbstractFSProvider::status_t ZIPProvider::makeDirRecursive(const FileName & url) {
	if(isDir(url)) {
		return AbstractFSProvider::OK;
	}

	std::string archiveFileName;
	FileName file;
	decomposeURL(url, archiveFileName, file);

	const std::string path = file.getPath();
	// Split path into directory components
	size_t pos = 0;
	while(pos != path.size()) {
		pos = path.find('/', pos);
		if(pos == std::string::npos) {
			break;
		}

		const std::string subPath = path.substr(0, pos + 1);
		++pos;

		if(makeDir(FileName(archiveFileName + '$' + subPath)) != AbstractFSProvider::OK) {
			return AbstractFSProvider::FAILURE;
		}
	}
	return AbstractFSProvider::OK;
}
示例#18
0
int qdbConsole(CONFIG *config) {

    if (!makeDir(config->dir)) {
        return 55;
    }

    FILE *stream = redirectStdout(config);
    if (stream == NULL) {
        return 55;
    }

    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));

    // Start the child process.
    if (!CreateProcess(config->javaExec, config->javaArgs, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
        eprintf("CreateProcess failed (%lu).\n", GetLastError());
        return 1;
    }

    // Wait until child process exits.
    WaitForSingleObject(pi.hProcess, INFINITE);

    // Close process and thread handles.
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    fclose(stream);
    return 0;
}
示例#19
0
// Uses root buffer as scratch space.
// On success, writes full path of created directory to root.
// \param root Buffer that, on entry, contains directory path where searching should start.
// \param rootLen Length of string in root, excluding the terminating zero.
// \param name Name of the directory to create. Must end with '/'.
// \param bufLen Length of the buffer pointed to by \a root, in bytes.
static bool makeDir(char* root, int rootLen, const char* name, int bufLen) {
	// find a root path
	printf("makeDir(%s)\n", root);
	MAHandle list = maFileListStart(root, "*");
	MAT(list);
	int freeBufSpace = bufLen - rootLen;
	while(1) {
		int res;
		res = maFileListNext(list, root + rootLen, freeBufSpace);
		MAT_CUSTOM(res, _res < 0 || _res >= freeBufSpace);
		if(res == 0)
			return false;
		int resLen = rootLen + res;
		if(root[resLen-1] == '/') {
			MAASSERT(resLen + (int)strlen(name) < bufLen);
			//printf("Dir: '%s'\n", file.c_str());
			strcpy(root + resLen, name);
			if(tryToMake(root))
				return true;
			root[resLen] = 0;
			if(makeDir(root, resLen, name, bufLen))
				return true;
		}
	}
}
示例#20
0
void cp_dir(char * filename, iNode * path_inode)
{
	iNode * aux;
	aux = current;
	current = path_inode;
	makeDir(filename);
	current = aux;
}
示例#21
0
void init_filesystem(char * filesystem_name, masterBootRecord * mbr) {

	/*mbr sector*/
	int fd;

	user * users = calloc(sizeof(user), 100);

	memcpy(users[0].name, "chinux", str_len("chinux"));
	memcpy(users[0].password, "chinux", str_len("chinux"));
	users[0].usrID = 1;
	users[0].group = ADMIN;
	mbr->existFS = 1;

	write_disk(0, MBRSECTOR, mbr, BLOCK_SIZE, 0); //BLOCK_SIZE

	/* superBlock sector */
	superblock->name = "Chinux";
	superblock->blockSize = BLOCK_SIZE;
	superblock->freeBlocks = DISK_SIZE / BLOCK_SIZE;
	superblock->usedBlocks = 0;
	superblock->root = NULL;
	write_disk(0, SUPERBLOCKSECTOR, superblock, BLOCK_SIZE, 0);

	/* bitmap Sectors */
	init_bitmap();

	/* inodemap Sectors */
	init_inodemap();

	/* Root node & current node */

	init_root();

	write_disk(0, 1, superblock, BLOCK_SIZE, 0);

	current = superblock->root;

	makeDir("users");
	makeDir("etc");

	fd = do_creat("usersfile", 777);
	write(fd, (char *) users, sizeof(user) * 100);
	close(fd);

	return;
}
示例#22
0
文件: main.cpp 项目: meilu2two/apps
/// This function writes data to file
std::string writeFile( std::string t_foldername, std::string t_filename )
{
    std::stringstream r_filepath;
    r_filepath.str( std::string() );
    r_filepath.clear();
    r_filepath << t_foldername << t_filename;
    std::cout << "Path: " << r_filepath.str() << std::endl;

    bool a_dirExists( false );
    if( !isDirExistent( t_foldername ) ){
        a_dirExists = makeDir( t_foldername );
    }
    else {
        a_dirExists = true;
    }

    std::ofstream a_outputFile;
    if( a_dirExists )
    {
        a_outputFile.open( r_filepath.str().c_str(), std::ios_base::trunc );
    }

    if( !a_outputFile.is_open() )
    {
      std::cout << "Error at opening file: " << r_filepath.str() << std::endl;
    }
    else
    {
      int a_numberOfDataItems( 10 );

      // Write Header
      a_outputFile << "FileVersion=23.42" << std::endl;
      a_outputFile << "NumberOfDataItems=" << a_numberOfDataItems << std::endl;


      // Write Data
      std::vector< int > a_pointIndex( a_numberOfDataItems, 0 );
      std::vector< int >::iterator a_pointIndexIt = a_pointIndex.begin();
      for ( int a_i( 0 ); a_numberOfDataItems > a_i ; ++a_i )
      {
          *a_pointIndexIt = a_i;
          ++a_pointIndexIt;
      }

      a_pointIndexIt = a_pointIndex.begin();
      while( a_pointIndex.end() != a_pointIndexIt )
      {
         std::string a_separator( ";" );
         a_outputFile << *a_pointIndexIt << a_separator << 100 + *a_pointIndexIt << a_separator << 200 + *a_pointIndexIt << std::endl;

         ++a_pointIndexIt;
      }

      a_outputFile.close();
    }

    return r_filepath.str();
}
示例#23
0
void writeLiftFiles(char *chromName, int chromSize, struct agpData *startAgpData, char *destDir)
/*
Writes the lift and list files out for a single chromsome

param chromName - The name of the chromsome.
param chromSize - The number of bases in this chromosome.
param startGap - Pointer to the dna gap or fragment at which we are starting to
 write data. The data will include the contents of this gap/frag.
param destDir - The destination dir to which to write the agp file.
 */
{
char liftDir[DEFAULT_PATH_SIZE];
char filename[DEFAULT_PATH_SIZE];
struct agpData *loopStartData = NULL;
struct agpData *curData = NULL;
FILE *fpLft = NULL;
FILE *fpLst = NULL;
FILE *fpLstOut = NULL;

int contigSize = 0;

sprintf(liftDir, "%s/lift", destDir);
makeDir(liftDir);

sprintf(filename, "%s/lift/ordered.lft", destDir);
fpLft = fopen(filename, "w");

sprintf(filename, "%s/lift/ordered.lst", destDir);
fpLst = fopen(filename, "w");

sprintf(filename, "%s/lift/oOut.lst", destDir);
fpLstOut = fopen(filename, "w");

curData = startAgpData;
while (NULL != curData) 
    {
    if (NULL == loopStartData)
	{
	loopStartData = curData;
	}

    if (curData->endOfContig)
	{
	contigSize = curData->data.pGap->chromEnd - loopStartData->data.pGap->chromStart;
	writeLiftData(loopStartData, chromSize, contigSize, fpLft, '\t', '\n');
	writeListData(loopStartData, fpLst);
	writeListOutData(loopStartData, fpLstOut);
	loopStartData = NULL;
	}

    curData = curData->next;
    }

fclose(fpLft);
fclose(fpLst);
fclose(fpLstOut);
}
示例#24
0
文件: c.c 项目: LucasAbreu/c
// Checks if entered file/dir has a comment
// If so prints it. If not just prints file/dir name
void checkComment(const char file[], char path[]) {
    char *dir;
    char *s;

    // First add the comment path to the end of the current path
    if (dirOrFileExists(file)) {
        int ford = fileOrDirectory(file);
        switch(ford) {
            // Directory was entered
            case 0:
                // Appends the directory name to the end of current path
                dir = allocFilename("%s/%s", path, file);
                makeDir(dir);

                // Add .comment directory to that path
                char * commentDir = allocFilename("%s/%s", dir, COMMENT);

                // Ands ..comment to that path to get the comment for that directory
                char * fin = allocFilename("%s/%s.comment", commentDir, DOT);

                if (dirOrFileExists(fin)) {
                    printComment(file, fin);
                } else {
                    printf(BLUE "%s" RESETCOLOR "\n", file);
                }

                freeFilename(commentDir);
                freeFilename(fin);
                freeFilename(dir);
                break;
                // File is entered
            case 1:
                // makeDir(path);
                // Adds /.comment to the end of the current path
                s = allocFilename("%s/%s", path, COMMENT);

                //Next add the file to the end of that path
                char * r = allocFilename("%s/%s.comment", s, file);


                if (dirOrFileExists(r)) {
                    printComment(file, r);
                } else {
                    printf(BLUE "%s" RESETCOLOR "\n", file);
                }

                freeFilename(s);
                freeFilename(r);
                break;
                // Unknown what was entered
            default: printf("Not sure what to do here...");
                     break;
        }
    } else {
        printf("Sorry cant find a file called %s\n", file);
    }
}
示例#25
0
QString KStandardDirs::saveLocation(const char *type,
				    const QString& suffix,
				    bool create) const
{
    checkConfig();

    QString *pPath = savelocations.find(type);
    if (!pPath)
    {
       QStringList *dirs = relatives.find(type);
       if (!dirs && (
                     (strcmp(type, "socket") == 0) ||
                     (strcmp(type, "tmp") == 0) ||
                     (strcmp(type, "cache") == 0) ))
       {
          (void) resourceDirs(type); // Generate socket|tmp|cache resource.
          dirs = relatives.find(type); // Search again.
       }
       if (dirs)
       {
          // Check for existence of typed directory + suffix
          if (strncmp(type, "xdgdata-", 8) == 0)
             pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
          else if (strncmp(type, "xdgconf-", 8) == 0)
             pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
          else
             pPath = new QString(realPath(localkdedir() + dirs->last()));
       }
       else {
          dirs = absolutes.find(type);
          if (!dirs)
             qFatal("KStandardDirs: The resource type %s is not registered", type);
          pPath = new QString(realPath(dirs->last()));
       }

       savelocations.insert(type, pPath);
    }
    QString fullPath = *pPath + (pPath->endsWith("/") ? "" : "/") + suffix;

    KDE_struct_stat st;
    if (KDE_stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) {
	if(!create) {
#ifndef NDEBUG
	    kdDebug() << QString("save location %1 doesn't exist").arg(fullPath) << endl;
#endif
	    return fullPath;
	}
	if(!makeDir(fullPath, 0700)) {
	    return fullPath;
	}
        dircache.remove(type);
    }
    if (!fullPath.endsWith("/"))
	    fullPath += "/";
    return fullPath;
}
示例#26
0
int logReader(int choice,char* diruser){	//diruser chi khi nao in userlog thi moi xai
	int num;
	FILE *fp;
	char dir[30];
	khachHang temp;
	Nhap:
	system("cls");
	if (choice == 1){
		printf("\n================Xem Lich Su Giao Dich================\n");		
		strcpy(dir,diruser);
		dir[strlen(dir) - 4] = NULL;
		strcat(dir,"_log_user.dat");
	}
	else if (choice == 0){
		printf("\n====================Xem File Log=====================\n");
		printf("\n #Nhap Ma So The : ");
		scanf("%d",&num);
		makeDir(dir,num);
		dir[strlen(dir) - 4] = NULL;
		strcat(dir,"_log.dat");
	}
	if((fp=fopen(dir,"rb")) == NULL){
		fclose(fp);
		int choice;
		do{
			printf("\n Account Nay Chua Co File Log. Ban Muon\n");
			printf("\n ---1.Nhap Ma So The Khac\n");
			printf("\n ---2.Tro Ve Menu\n");
			printf("\n #Chon : ");
			fflush(stdin); scanf("%d",&choice);
			switch (choice){
				case 1 :
					system("cls");
					goto Nhap;
					break;
				case 2 :
					return 0;
				default :
				system("cls");
				printf("\n====================Xem File Log=====================\n");
				printf("\n #Nhap Ma So The : %d\n",num);
				break;
			}
		}while(choice > 2 || choice < 1 );
	}
	else{
		printf("\n\n\n\n");
		while(fread(&temp,sizeof(temp),1,fp) == 1){
			printInfo(temp,2,temp.trangThai);
			printf("\n\n");
		}
		printf("\n Nhan Phim Bat Ky De Quay Ve Menu\n");
		getch();	
		return 1;
	}
}
示例#27
0
文件: myshell.c 项目: abaheti95/OSlab
void caller(){
    char buffer[BUFFER];
    char currWDir[BUFFER];
    int err;
    char *token;
    token = strtok(buffer," \t");


    while(1){
        bzero(buffer, BUFFER);
        prompt();
        fgets(buffer, BUFFER, stdin);

        if(compare(buffer, "cd") == 0){
            token = strchr(buffer,' ');
            
            if(token != NULL){
                token += 1;
                *strchr(token,'\n')='\0';
                 // printf("here\n");
                changeDir(token);
            }else{
                chdir("/home");
            }
        }else if(compare(buffer,"mkdir") == 0){
            makeDir(buffer);
        }else if(compare(buffer,"pwd") == 0){
            getcwd(currWDir, BUFFER);
            printf("%s\n", currWDir);
        }else if(compare(buffer,"rmdir") == 0){
            remDir(buffer);
        }else if(compare(buffer,"ls") == 0){
            token = strtok(buffer," \t");
            char *token2 = strtok(NULL," \t");
            if(token2 == NULL){
                listDir();
            }else if(compare(token2, "-l") == 0){
                listDirL();
            }else{
                printf("Command not recognized!\n");
            }
        }else if(compare(buffer, "exit") == 0){
            exit(0);
        }else if(compare(buffer, "cp") == 0){
            token = strtok(buffer," \t");
            char *src = strtok(NULL," \t");
            char *dest = strtok(NULL," \t");
            copy(src, dest);
        }else{
            exec(buffer);
            exit(1);
        }
    }
}
示例#28
0
void CSDirection::doDir() {
  if (m_lX > 0 && m_lY > 0 && m_dir) {
    std::unique_ptr<UCHAR[]> sel(new UCHAR[m_lX * m_lY]);
    if (!sel) throw SMemAllocError("in directionMap");
    size_t length = (size_t)(m_lX * m_lY * sizeof(UCHAR));
    memcpy(sel.get(), m_dir.get(), length);
    makeDir(sel.get());
    memcpy(sel.get(), m_dir.get(), length);
    equalizeDir(sel.get(), 3);
  }
}
示例#29
0
void foldGfx(char *destDir)
/* foldGfx - make graphics for Science foldout for draft genome issue. */
{
char *testChrom = "chrY";

makeDir(destDir);
gcSquiggle(testChrom, destDir, "Plot", FALSE, TRUE);
gcSquiggle(testChrom, destDir, "Dot", FALSE, FALSE);
gcSquiggle(testChrom, destDir, "Plot2", TRUE, TRUE);
gcSquiggle(testChrom, destDir, "Dot2", TRUE, FALSE);
}
示例#30
0
struct agpData* makeSuperContigs(struct lineFile *agpFile, DNA *dna, int dnaSize, char *destDir)
/*
Makes supercontig files for each chromosome

param agpFile - The agpFile we are examining.
param dna - The dna sequence we are splitting up.
param dnaSize - The size of the dna sequence we are splitting up.
param destDir - The destination directory where to store files.

return startAgpData - The first agp entry in the sequence.
 */
{
struct agpData *startAgpData = NULL;
struct agpData *endAgpData = NULL;
struct agpData *prevAgpData = NULL;
struct agpData *startChromAgpData = NULL;

char filename[DEFAULT_PATH_SIZE];
char contigDir[DEFAULT_PATH_SIZE];
int sequenceNum = 0;

do
    {
    endAgpData = nextAgpEntryToSplitOn(agpFile, dnaSize, &startAgpData);
    /* Point the end of the previous loop iteration's linked list at
       the start of this new one */
    if (NULL != prevAgpData)
	{
	prevAgpData->next = startAgpData;
	startAgpData->prev = prevAgpData;
	}
    prevAgpData = endAgpData;

    sequenceNum++;
    sprintf(contigDir, "%s/%s_%d", destDir, startAgpData->data.pGap->chrom, sequenceNum);
    makeDir(contigDir);

    sprintf(startAgpData->contigName, "%s_%d", startAgpData->data.pGap->chrom, sequenceNum);

    sprintf(filename, "%s/%s_%d.fa", contigDir, startAgpData->data.pGap->chrom, sequenceNum);
    writeSuperContigFaFile(dna, startAgpData, endAgpData, filename, sequenceNum);

    sprintf(filename, "%s/%s_%d.agp", contigDir, startAgpData->data.pGap->chrom, sequenceNum);
    writeSuperContigAgpFile(startAgpData, endAgpData, filename, sequenceNum);

    /* Save the start of the whole chromosome */
    if (NULL == startChromAgpData)
	{
	startChromAgpData = startAgpData;
	}
    } while (endAgpData->data.pGap->chromEnd < dnaSize);

return startChromAgpData;
}