当前位置: 首页>>代码示例>>C++>>正文


C++ writefile函数代码示例

本文整理汇总了C++中writefile函数的典型用法代码示例。如果您正苦于以下问题:C++ writefile函数的具体用法?C++ writefile怎么用?C++ writefile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了writefile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: copyfiles

copyfiles() {
	writefile(TMPFILE);
	int page_number1 = -1;
	int page_number2 = -1;

	int *buf1, *buf2;

	int fd_inpfile, fd_finalfile;

	if ((fd_inpfile=PF_OpenFile(TMPFILE))<0){
		PF_PrintError("Error in opening file");
		exit(1);
	}

	if ((fd_finalfile=PF_OpenFile(FILE))<0){
		PF_PrintError("Error in opening file");
		exit(1);
	}

	//transferring contents of finalfile to tmpfile
	int i, error;
	for(i = 0 ; i < B_R ; i++) {
		// get the page page_number of each file
		if((error=PF_GetNextPage(fd_finalfile,&page_number1,&buf1))!= PFE_OK) {
			PF_PrintError("Error");
			exit(1);
		}
		if((error=PF_GetNextPage(fd_inpfile,&page_number2,&buf2))!= PFE_OK) {
			PF_PrintError("Error");
			exit(1);
		}

		*((int *)buf2) = *((int *)buf1);
		//printf("%d ", *((int *)buf2));

		if ((error=PF_UnfixPage(fd_finalfile,page_number1,TRUE))!= PFE_OK){
			PF_PrintError("unfix buffer\n");
			exit(1);
		}

		if ((error=PF_UnfixPage(fd_inpfile,page_number2,TRUE))!= PFE_OK){
			PF_PrintError("unfix buffer\n");
			exit(1);
		}
	}
	if ((error=PF_CloseFile(fd_inpfile))!= PFE_OK){
		PF_PrintError("Error in closing input file\n");
		exit(1);
	}

	if ((error=PF_CloseFile(fd_finalfile))!= PFE_OK){
		PF_PrintError("Error in closing temporary file\n");
		exit(1);
	}
}
开发者ID:amangoeliitb,项目名称:external-merge-sort-and-hash-join,代码行数:55,代码来源:external_merge_sort.c

示例2: adjust

/**
 * Interactively adjust the backlight on a device
 * 
 * @param  cols    The number of columns on the terminal
 * @param  device  The device on which to adjust backlight
 */
static void adjust(int cols, const char* device)
{
  int min, max, cur, step, init, i, d;
  size_t lendir;
  char* dir = alloca(PATH_MAX * sizeof(char));
  char* buf = alloca(256 * sizeof(char));
  
  *dir = 0;
  dir = strcat(dir, BACKLIGHT_DIR "/");
  dir = strcat(dir, device);
  dir = strcat(dir, "/");
  lendir = strlen(dir);
  
  /* Get brightness parameters */
  min = 0;
  if (readfile(buf, strcat(dir, "max_brightness")))
    return;
  max = atoi(unnl(buf));
  *(dir + lendir) = 0;
  if (readfile(buf, strcat(dir, "brightness")))
    return;
  cur = atoi(unnl(buf));
  
  if (max <= min)
    return; /* what the buck */
  
  step = (max - min) / 200 ?: 1;
  init = cur;
  
  P("\n\n\n\n\n");
  bars(min, max, init, cur, cols);
  
  while ((d = getchar()) != -1)
    switch (d)
      {
      case 'q':
      case '\n':
      case 4:
	P("");
	return;
	
      case 'A':
      case 'C':
	cur += step << 1;
	/* fall through */
      case 'B':
      case 'D':
	cur -= step;
	if (cur < min)  cur = min;
	if (cur > max)  cur = max;
	if (writefile(buf, cur, dir))
	  return;
	bars(min, max, init, cur, cols);
      }
}
开发者ID:ehegnes,项目名称:adjbacklight,代码行数:61,代码来源:adjbacklight.c

示例3: docopy

/*copy a file*/
void docopy()
{
	char sname[7];
	char dname[7];
	char line[80];
	char file[12800];
	char dirsector[512];
	int index,i;

	/*prompt for the first file name*/
	printstring("Name of the source file? \0");
	readstring(line);
	for (i=0; i<6; i++)
	{
		sname[i]=line[i];
		if (line[i]==0xd)
			break;
	}
	sname[i]=0x0;

	/*make sure it exists - find the directory entry*/
	readsector(2,dirsector);
	index=findname(sname,dirsector);
	if (index==-1)
	{
		printstring("File not found\r\n\0");
		return;
	}

	/*read the source file*/
	readfile(sname,file);

	/*prompt for the destination file name*/
	printstring("Name of the destination file? \0");
	readstring(line);
	for (i=0; i<6; i++)
	{
		dname[i]=line[i];
		if (line[i]==0xd)
			break;
	}
	dname[i]=0x0;

	/*figure out how long the source file is*/
	i=0;
	index=index+6;
	while(dirsector[index]!=0x0)
	{
		index++;
		i++;
	}

	/*write the file*/
	writefile(dname,file,i);
}
开发者ID:anamarce,项目名称:proyectoFinalSISO,代码行数:56,代码来源:shell.c

示例4: main

int
main(void)
{
	writefile("/tmp/f1", "file1.txt");
	writefile("/tmp/f2", "file2.txt");
	writefile("/tmp/f3", "file3.txt");
	writefile("/tmp/f4", "file4.txt");
	writefile("/tmp/f5", "file5.txt");
	writefile("/tmp/f6", "file6.txt");
	writefile("/tmp/f7", "file7.txt");
	writefile("/tmp/f8", "file8.txt");
	return 0;
}
开发者ID:cicerocomp,项目名称:fisl13,代码行数:13,代码来源:create.c

示例5: Add2Log

//-----------------------------------------------------------------------
// Add2Log - Add string to the the file
//
void Add2Log (TCHAR *lpszFormat, ...) {
    int nBuf;//, i;
    TCHAR szBuffer[512];

    va_list args;
    va_start(args, lpszFormat);

    nBuf = vswprintf(szBuffer, lpszFormat, args);
	writefile(szBuffer);
    va_end(args);
}
开发者ID:hjgode,项目名称:VMusage,代码行数:14,代码来源:log2file.cpp

示例6: callASort

void callASort(T* buff, size_t size, T*(*asort)(T* buff, size_t n), LPCTSTR fileOut)
{
	T* forSort = duplicateBuff(buff, size);

	T* sortRes = asort(forSort, size);

	if (outputOutput)
		outputBuff(sortRes, size);

	writefile(fileOut, sortRes, size);
	delete[] forSort;
}
开发者ID:falsevapor,项目名称:StronkStinkCPloosPloosElevenPloos,代码行数:12,代码来源:zort.cpp

示例7: dump2file

void dump2file (int signum) {
	static char filename[1024];
	if (!activevents) goto end;
	makename(filename);
	E("creat", creat(filename, 0666));
	// TODO I think creat() will always return 1 here.  Be sure.
	writefile();
	close(1);
	activevents = 0; // Removes all events.
 end:
	alarm(timeout);
	signal(SIGALRM, dump2file); }
开发者ID:bsummer4,项目名称:midiutils,代码行数:12,代码来源:brainstorm.c

示例8: snprintf

bool Motor::writeMotorInt(const char *motorFile, int v)
{
	const size_t pathSize = MOTORPATHNAME_MAX;
	char path[pathSize];
	const size_t strsize = 30;
	char intstr[strsize];
	unsigned int n;

	snprintf(path, pathSize, "%s/%s", motorPath, motorFile);
	n = snprintf(intstr, strsize, "%d", v);
	return writefile(path, intstr, n);
}
开发者ID:cunctator,项目名称:holorobot,代码行数:12,代码来源:motor.cpp

示例9: copy

// copy copies the file src to dst, via memory (so only good for small files).
static void
copy(char *dst, char *src, int exec)
{
	Buf b;

	if(vflag > 1)
		errprintf("cp %s %s\n", src, dst);

	binit(&b);
	readfile(&b, src);
	writefile(&b, dst, exec);
	bfree(&b);
}
开发者ID:rosrad,项目名称:go-rep,代码行数:14,代码来源:build.c

示例10: ibs_stop

void
ibs_stop(int cid)
{
    if (!ibs_enabled)
	return;
    cid = lcpu_to_pcpu[cid];
    char path[512];
    // set opctl to stop
    sprintf(path, "/sys/kernel/amd10h-ibs/cpu%d/opctl", cid);
    writefile(path, "0");
    sprintf(path, "/sys/kernel/amd10h-ibs/cpu%d/record", cid);
    readsamples(path);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:13,代码来源:ibs.c

示例11: main

int main(int argc, char **argv){

	if(argc != 3){
		printf("Error: invalid number of arguments\n");
		return -1;
	}
	
	if(strcmp(argv[1],argv[2])==0){
		printf("input arguments are the same file. Cannot overwrite. Exiting Indexer.\n");

		return 0;
	}

	int rval;
	char* output=argv[1];
	rval = access(output,F_OK);
	if(rval==0){
	//file exists
	}
	else if(errno==EACCES){
		printf("%s is not accessible\n", output);
		return 0;
	}

	rval = access(output, W_OK);
	if(rval==0){
		//permission to write
	}else if (errno==EACCES){
		printf("you do not have permission to write to %s\n",output);
		return 0;

	}

	struct List *list = SLCreate(); //create list to store words

	struct stat fileStat; //check if directory or file to be indexed exists
	if(stat(argv[2], &fileStat) == 0){

		directoryTraverse(list, argv[2]);


	}else{
		fprintf(stderr, "Directory or file you are trying to index does not exist.\n");	
		return -1;
	}	

	writefile(argv[1],list);
	destroyList(list);
	return 0;
}
开发者ID:zackcolello,项目名称:Search,代码行数:50,代码来源:index.c

示例12: gcopnames

// gcopnames creates opnames.h from go.h.
// It finds the OXXX enum, pulls out all the constants
// from OXXX to OEND, and writes a table mapping
// op to string.
void
gcopnames(char *dir, char *file)
{
	char *p, *q;
	int i, j, end;
	Buf in, b, out;
	Vec lines, fields;
	
	binit(&in);
	binit(&b);
	binit(&out);
	vinit(&lines);
	vinit(&fields);
	
	bwritestr(&out, bprintf(&b, "// auto generated by go tool dist\n"));
	bwritestr(&out, bprintf(&b, "static char *opnames[] = {\n"));

	readfile(&in, bprintf(&b, "%s/go.h", dir));
	splitlines(&lines, bstr(&in));
	i = 0;
	while(i<lines.len && !contains(lines.p[i], "OXXX"))
		i++;
	end = 0;
	for(; i<lines.len && !end; i++) {
		p = xstrstr(lines.p[i], "//");
		if(p != nil)
			*p = '\0';
		end = contains(lines.p[i], "OEND");
		splitfields(&fields, lines.p[i]);
		for(j=0; j<fields.len; j++) {
			q = fields.p[j];
			if(*q == 'O')
				q++;
			p = q+xstrlen(q)-1;
			if(*p == ',')
				*p = '\0';
			bwritestr(&out, bprintf(&b, "	[O%s] = \"%s\",\n", q, q));
		}
	}
	
	bwritestr(&out, bprintf(&b, "};\n"));

	writefile(&out, file, 0);

	bfree(&in);
	bfree(&b);
	bfree(&out);
	vfree(&lines);
	vfree(&fields);
}
开发者ID:8l,项目名称:go,代码行数:54,代码来源:buildgc.c

示例13: update_cfgfile_parameters

void update_cfgfile_parameters(struct DirectoryEntry *pDirEnt,unsigned char slot_index)
{
	cfgfile * cfgf;

	readfile(pDirEnt,0,0xc,0xd);

	cfgf=(cfgfile *)&sectorBuffer;
	cfgf->update_cnt++;
	cfgf->slot_index=slot_index;

	writefile(pDirEnt,0,0xc,0xd);

	return;
}
开发者ID:Peruonto,项目名称:HXCFE_Amiga_file_selector,代码行数:14,代码来源:cfg_file.c

示例14: test_odb_largefiles__streamwrite

void test_odb_largefiles__streamwrite(void)
{
	git_oid expected, oid;

#ifndef GIT_ARCH_64
	cl_skip();
#endif

	if (!cl_is_env_set("GITTEST_INVASIVE_FS_SIZE") ||
		!cl_is_env_set("GITTEST_SLOW"))
		cl_skip();

	git_oid_fromstr(&expected, "3fb56989cca483b21ba7cb0a6edb229d10e1c26c");
	writefile(&oid);

	cl_assert_equal_oid(&expected, &oid);
}
开发者ID:csware,项目名称:libgit2,代码行数:17,代码来源:largefiles.c

示例15: ReadFile

//将本地文件保存到远程,
int fileclient::putfile(const char *local_file_name, const char *remote_file_name)
{
	if(local_file_name == NULL || remote_file_name == NULL)
		return FILE_PARAM_ERROR;

    int len = 0;
    string name = _local_root + local_file_name;
    char *buffer = ReadFile(name.c_str() , len );
    if(buffer == NULL || len <= 0)
    {
    	return FILE_FAIL;
    }

    int ret = writefile(buffer, len, remote_file_name);
    free(buffer);
    return ret;
}
开发者ID:BotterLiu,项目名称:cnet,代码行数:18,代码来源:fileclient.cpp


注:本文中的writefile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。