这篇教程C++ yaffs_close函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中yaffs_close函数的典型用法代码示例。如果您正苦于以下问题:C++ yaffs_close函数的具体用法?C++ yaffs_close怎么用?C++ yaffs_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了yaffs_close函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rename_over_testvoid rename_over_test(const char *mountpt){ int i; char a[100]; char b[100]; char c[100]; sprintf(a,"%s/a",mountpt); sprintf(b,"%s/b",mountpt); sprintf(c,"%s/c",mountpt); yaffs_StartUp(); yaffs_mount(mountpt); printf("Existing files/n"); dumpDirFollow(mountpt); i = yaffs_open(c,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); printf("File c handle is %d/n",i); yaffs_close(i); i = yaffs_open(a,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); yaffs_close(i); i = yaffs_open(b,O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); yaffs_close(i); yaffs_rename(a,b); // rename over yaffs_rename(b,a); // rename back again (not renaimng over) yaffs_rename(a,b); // rename back again (not renaimng over) yaffs_unmount(mountpt); }
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:35,
示例2: yWriteFilestatic int yWriteFile(const char *fname, unsigned sz32){ int h; int r; int i; unsigned checksum = 0; printf("Writing file %s/n",fname); h = yaffs_open(fname,O_RDWR | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE); if(h < 0){ printf("could not open file %s/n",fname); return h; } xx[0] = sz32; checksum ^= xx[0]; if((r = yaffs_write(h,xx,sizeof(unsigned))) != sizeof(unsigned)){ goto WRITE_ERROR; } while(sz32> 0){ for(i = 0; i < XX_SIZE; i++){ xx[i] = sz32 + i; checksum ^= xx[i]; } if((r = yaffs_write(h,xx,sizeof(xx))) != sizeof(xx)){ goto WRITE_ERROR; } sz32--; } xx[0] = checksum; if((r = yaffs_write(h,xx,sizeof(unsigned))) != sizeof(unsigned)){ goto WRITE_ERROR; } yaffs_close(h); return 0;WRITE_ERROR: printf("ywrite error at position %d/n",(int)yaffs_lseek(h,0,SEEK_END)); yaffs_close(h); return -1; }
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:51,
示例3: UpdateCounterstatic void UpdateCounter(const char *name, unsigned *val, int initialise){ int inh=-1; int outh=-1; unsigned x[2]; int nread = 0; int nwritten = 0; x[0] = x[1] = 0; if(initialise){ x[0] = 0; x[1] = 1; } else { inh = yaffs_open(name,O_RDONLY, S_IREAD | S_IWRITE); if(inh >= 0){ nread = yaffs_read(inh,x,sizeof(x)); yaffs_close(inh); } if(nread != sizeof(x) || x[0] + 1 != x[1]){ printf("Error reading counter %s handle %d, x[0] %u x[1] %u last error %d/n", name, inh, x[0], x[1],yaffsfs_GetLastError()); FatalError(); } x[0]++; x[1]++; } outh = yaffs_open(fullTempCounterName, O_RDWR | O_TRUNC | O_CREAT, S_IREAD | S_IWRITE); if(outh >= 0){ nwritten = yaffs_write(outh,x,sizeof(x)); yaffs_close(outh); yaffs_rename(fullTempCounterName,name); } if(nwritten != sizeof(x)){ printf("Error writing counter %s handle %d, x[0] %u x[1] %u/n", name, inh, x[0], x[1]); FatalError(); } *val = x[0]; printf("##/n" "## Set counter %s to %u/n" "##/n", name,x[0]);}
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:50,
示例4: fill_empty_files_testvoid fill_empty_files_test(const char *mountpt){ int i; yaffs_StartUp(); char name[100]; int result = 0; int d,f; for(i = 0; i < 5; i++) { yaffs_mount(mountpt); for(d = 0; result >= 0 && d < 1000; d++){ sprintf(name,"%s/%d",mountpt,d); result= yaffs_mkdir(name,0); printf("creating directory %s result %d/n",name,result); for(f = 0; result >= 0 && f < 100; f++){ sprintf(name,"%s/%d/%d",mountpt,d,f); result= yaffs_open(name,O_CREAT, 0); yaffs_close(result); printf("creating file %s result %d/n",name,result); } } yaffs_unmount(mountpt); } }
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:28,
示例5: dump_file_dataint dump_file_data(char *fn){ int h; int i = 0; int ok = 1; unsigned char b; h = yaffs_open(fn, O_RDWR,0); printf("%s/n",fn); while(yaffs_read(h,&b,1)> 0) { printf("%02x",b); i++; if(i > 32) { printf("/n"); i = 0;; } } printf("/n"); yaffs_close(h); return ok;}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:25,
示例6: overwrite_testint overwrite_test(const char *path){ char aname[100]; char bname[100]; int i; int j; int a; int b; yaffs_StartUp(); yaffs_mount(path); sprintf(aname,"%s%s",path,"/a"); sprintf(bname,"%s%s",path,"/b"); b = yaffs_open(bname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); for(j= 0; j < 500; j++){ yaffs_write(b,bname,100); a = yaffs_open(aname, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); for(i = 0; i < rand() % 20000; i++) yaffs_write(a,&a,sizeof(a)); yaffs_close(a); } return 0; }
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:27,
示例7: read_a_filevoid read_a_file(char *fn){ int h; int i = 0; unsigned char b; h = yaffs_open(fn, O_RDWR,0); if(h<0) { printf("File not found/n"); return; } while(yaffs_read(h,&b,1)> 0) { printf("%02x ",b); i++; if(i > 32) { printf("/n"); i = 0;; } } printf("/n"); yaffs_close(h);}
开发者ID:Aorjoa,项目名称:bootloader,代码行数:26,
示例8: test_yaffs_chmod_EROFSint test_yaffs_chmod_EROFS(void){ int error=0; int output; if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file/n",1); return -1; } EROFS_setup(); output = yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE); if (output<0){ error=yaffs_get_error(); if (abs(error)==EROFS){ return 1; } else { print_message("different error than expected/n",2); return -1; } } else { print_message("chmoded with EROFS setup (which is a bad thing)/n",2); return -1; }}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:26,
示例9: test_yaffs_rename_file_to_dirint test_yaffs_rename_file_to_dir(void){ int output=0; if (0 != yaffs_access(FILE_PATH,0)) { output = test_yaffs_open(); if (output < 0) { print_message("failed to create file/n",2); return -1; } else { output = yaffs_close(output); if (output < 0) { print_message("failed to close file/n",2); return -1; } } } output = yaffs_rename( "/yaffs2/foo" , RENAME_DIR_PATH); if (output<0) { print_message("failed to rename a file over an empty directory/n",2); return -1; } else { return 1; }}
开发者ID:hanfeng,项目名称:rtems-yaffs2,代码行数:26,
示例10: test_yaffs_rename_ENOTEMPTYint test_yaffs_rename_ENOTEMPTY(void){ int output=0; int error_code =0; if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){ print_message("failed to create dir/n",1); return -1; } if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){ print_message("failed to create dir2/n",1); return -1; } if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file/n",1); return -1; } output = yaffs_rename( DIR_PATH,DIR_PATH2 ); if (output<0){ error_code=yaffs_get_error(); if (abs(error_code)==ENOTEMPTY){ return 1; } else { print_message("different error than expected/n",2); return -1; } print_message("could not rename a directory over a nonempty directory (which is a bad thing)/n",2); return -1; } return 1;}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:34,
示例11: test_yaffs_rename_full_dir_over_dirint test_yaffs_rename_full_dir_over_dir(void){ int output=0; int error_code =0; if (yaffs_mkdir(DIR_PATH,O_CREAT | O_RDWR)==-1){ print_message("failed to create dir/n",1); return -1; } if (yaffs_mkdir(DIR_PATH2,O_CREAT | O_RDWR)==-1){ print_message("failed to create dir2/n",1); return -1; } if (yaffs_close(yaffs_open(DIR_PATH2_FILE,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file/n",1); return -1; } output = yaffs_rename( DIR_PATH2,DIR_PATH ); if (output<0){ print_message("could not rename a directory over a empty directory (which is a bad thing)/n",2); return -1; } return 1;}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:27,
示例12: test_yaffs_fsync_EROFSint test_yaffs_fsync_EROFS(void){ int output = 0; int error_code = 0; if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file/n",1); return -1; } EROFS_setup(); handle = yaffs_open(FILE_PATH,O_CREAT ,S_IREAD ); if (handle<0){ print_message("failed to open file/n",2); return -1; } output = yaffs_fsync(handle); if (output==-1){ error_code=yaffs_get_error(); if (abs(error_code)==EROFS){ return 1; } else { print_message("different error than expected/n",2); return -1; } } else { print_message("file synced with EROFS set.(which is a bad thing)/n",2); return -1; }}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:29,
示例13: handle_testvoid handle_test(const char *mountpt){ int i; int h; int cycle; char a[100]; sprintf(a,"%s/aaa",mountpt); yaffs_StartUp(); yaffs_mount(mountpt); for(cycle = 0; cycle < 5; cycle++){ printf("Start cycle %d/n",cycle); i = 0; do { h = yaffs_open(a, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); printf("%d handle %d/n",i,h); i++; } while(h >= 0); while(i >= -1) { yaffs_close(i); i--; } } yaffs_unmount(mountpt);}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:30,
示例14: write_200k_filevoid write_200k_file(const char *fn, const char *fdel, const char *fdel1){ int h1; int i; int offs; h1 = yaffs_open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); for(i = 0; i < 100000; i+= 10000) { write_10k(h1); } offs = yaffs_lseek(h1,0,SEEK_CUR); if( offs != 100000) { printf("Could not write file/n"); } yaffs_unlink(fdel); for(i = 0; i < 100000; i+= 10000) { write_10k(h1); } offs = yaffs_lseek(h1,0,SEEK_CUR); if( offs != 200000) { printf("Could not write file/n"); } yaffs_close(h1); yaffs_unlink(fdel1); }
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:35,
示例15: test_yaffs_rmdir_ENOTDIRint test_yaffs_rmdir_ENOTDIR(void){ int output=0; int error_code =0; if (yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))==-1){ print_message("failed to create file/n",1); return -1; } if (0 != yaffs_access(DIR_PATH,0)) { output = yaffs_mkdir(DIR_PATH,S_IWRITE | S_IREAD); if (output < 0) { print_message("failed to create directory/n",2); return -1; } } output = yaffs_rmdir("/yaffs2/test_dir/foo/dir/"); if (output<0){ error_code=yaffs_get_error(); if (abs(error_code)==ENOTDIR){ return 1; } else { print_message("returned error does not match the the expected error/n",2); return -1; } } else{ print_message("removed /yaffs2/ directory (which is a bad thing)/n",2); return -1; } }
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:29,
示例16: make_a_filevoid make_a_file(char *yaffsName, char bval, int sizeOfFile){ int outh; int i; unsigned char buffer[100]; outh = yaffs_open(yaffsName, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); if (outh < 0) { printf("Error opening file: %d. %s/n", outh, yaffs_error_str()); return; } memset(buffer, bval, 100); do { i = sizeOfFile; if (i > 100) i = 100; sizeOfFile -= i; yaffs_write(outh, buffer, i); } while (sizeOfFile > 0); yaffs_close(outh);}
开发者ID:0s4l,项目名称:u-boot-xlnx,代码行数:29,
示例17: test_yaffs_open_EACCESint test_yaffs_open_EACCES(void){ int error_code=0; int output =-1; if (yaffs_access(FILE_PATH,0)!=0){ output=yaffs_close(test_yaffs_open()); if (output<0){ print_message("failed to open file/n",2); return -1; } } output=yaffs_chmod(FILE_PATH,S_IREAD); if (output<0){ print_message("failed to chmod file/n",2); return -1; } handle=yaffs_open(FILE_PATH, O_TRUNC| O_RDWR,FILE_MODE ); if (handle <0){ error_code=yaffs_get_error(); if (abs(error_code)==EACCES){ return 1; } else { print_message("different error than expected/n",2); return -1; } } else { print_message("file opened with read and write permissions, chmoded to read only.(which is a bad thing)/n",2); return -1; }}
开发者ID:Blackrose,项目名称:yaffs2,代码行数:33,
示例18: fill_diskvoid fill_disk(const char *path,int nfiles){ int h; int n; int result; int f; static char xx[600]; char str[50]; for(n = 0; n < nfiles; n++) { sprintf(str,"%s/%d",path,n); h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); printf("writing file %s handle %d ",str, h); while ((result = yaffs_write(h,xx,600)) == 600) { f = yaffs_freespace(path); } result = yaffs_close(h); printf(" close %d/n",result); }}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:26,
示例19: cat/*============================================================================== * - cat() * * - print a file context */int cat(int argc, char *argv[]){ int fd; int read_byte; char file_context[1024]; char path_name[PATH_LEN_MAX]; CHECK_ARG_NUM(2, "please type file name"); _make_abs_path(path_name, argv[1]); /* * open file */ fd = yaffs_open(path_name, O_RDONLY, 0); if ( fd == -1) { serial_printf("cannot open file '%s'", path_name); return CMD_ERROR; } /* * read and print file context */ read_byte = yaffs_read(fd, file_context, 1023); while (read_byte > 0) { file_context[read_byte] = '/0'; serial_printf(file_context); read_byte = yaffs_read(fd, file_context, 1023); } yaffs_close(fd); return CMD_OK;}
开发者ID:WangDongfang,项目名称:DfewOS,代码行数:39,
示例20: check_pattern_fileint check_pattern_file(char *fn){ int h; int marker; int i; int size; int ok = 1; h = yaffs_open(fn, O_RDWR,0); size = yaffs_lseek(h,0,SEEK_END); for(i = 0; i < size; i+=256) { yaffs_lseek(h,i,SEEK_SET); yaffs_read(h,&marker,sizeof(marker)); ok = (marker == ~i); if(!ok) { printf("pattern check failed on file %s, size %d at position %d. Got %x instead of %x/n", fn,size,i,marker,~i); } } yaffs_close(h); return ok;}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:25,
示例21: create_resized_file_of_sizevoid create_resized_file_of_size(const char *fn,int syze1,int reSyze, int syze2){ int h; int iterations; h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); iterations = (syze1 + strlen(fn) -1)/ strlen(fn); while (iterations > 0) { yaffs_write(h,fn,strlen(fn)); iterations--; } yaffs_ftruncate(h,reSyze); yaffs_lseek(h,0,SEEK_SET); iterations = (syze2 + strlen(fn) -1)/ strlen(fn); while (iterations > 0) { yaffs_write(h,fn,strlen(fn)); iterations--; } yaffs_close (h);}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:27,
示例22: verify_file_of_sizevoid verify_file_of_size(const char *fn,int syze){ int h; int result; char xx[200]; char yy[200]; int l; int iterations = (syze + strlen(fn) -1)/ strlen(fn); h = yaffs_open(fn, O_RDONLY, S_IREAD | S_IWRITE); while (iterations > 0) { sprintf(xx,"%s %8d",fn,iterations); l = strlen(xx); result = yaffs_read(h,yy,l); yy[l] = 0; if(strcmp(xx,yy)){ printf("=====>>>>> verification of file %s failed near position %lld/n",fn,(long long)yaffs_lseek(h,0,SEEK_CUR)); } iterations--; } yaffs_close (h);}
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:28,
示例23: verify_200k_filevoid verify_200k_file(const char *fn){ int h1; int i; char x[11]; const char *s="0123456789"; int errCount = 0; h1 = yaffs_open(fn, O_RDONLY, 0); for(i = 0; i < 200000 && errCount < 10; i+= 10) { yaffs_read(h1,x,10); if(strncmp(x,s,10) != 0) { printf("File %s verification failed at %d/n",fn,i); errCount++; } } if(errCount >= 10) printf("Too many errors... aborted/n"); yaffs_close(h1); }
开发者ID:003900107,项目名称:realboard-lpc4088,代码行数:25,
示例24: test_yaffs_fchmod_EROFS_cleanint test_yaffs_fchmod_EROFS_clean(void){ int output =-1; if (handle >= 0) { output= yaffs_close(handle); } return (EROFS_clean() && output);}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:8,
示例25: test_yaffs_open_EEXIST_cleanint test_yaffs_open_EEXIST_clean(void){ if (handle >=0){ return yaffs_close(handle); } else { return 1; /* the file failed to open so there is no need to close it*/ }}
开发者ID:cargabsj175,项目名称:yaffs2,代码行数:8,
示例26: cp/*============================================================================== * - cp() * * - copy a file form here to there */int cp(int argc, char *argv[]){ int fd_in, fd_out; int read_byte, write_byte; char file_context[1024]; char old_path_name[PATH_LEN_MAX]; char new_path_name[PATH_LEN_MAX]; CHECK_ARG_NUM(3, "too few argument"); _make_abs_path(old_path_name, argv[1]); fd_in = yaffs_open(old_path_name, O_RDONLY, 0); CHECK_YAFFS_RETVAL(fd_in, "can't open file '%s'%s/n", old_path_name, ""); _make_abs_path(new_path_name, argv[2]); fd_out = yaffs_open(new_path_name, O_CREAT|O_RDWR|O_TRUNC, S_IREAD|S_IWRITE); if (fd_out == -1) { yaffs_close(fd_in); serial_printf("can't create file '%s'", new_path_name); return CMD_ERROR; } /* * read from fd_in and write to fd_out */ read_byte = yaffs_read(fd_in, file_context, 1024); while (read_byte > 0) { write_byte = yaffs_write(fd_out, file_context, read_byte); if (write_byte != read_byte) { serial_printf("copy file failed!"); break; } read_byte = yaffs_read(fd_in, file_context, 1024); } yaffs_close(fd_in); yaffs_close(fd_out); if (read_byte > 0) { return CMD_ERROR; } else { return CMD_OK; }}
开发者ID:WangDongfang,项目名称:DfewOS,代码行数:51,
示例27: test_yaffs_ftruncate_EROFS_cleanint test_yaffs_ftruncate_EROFS_clean(void){ int output=1; if (handle >= 0) { output= yaffs_close(handle); } return (EROFS_clean() && output);}
开发者ID:Blackrose,项目名称:yaffs2,代码行数:8,
示例28: V5M_SaveImageFilevoid V5M_SaveImageFile(char *str, char *buf, UINT32 len){ int h; yaffs_unlink(str); h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); yaffs_write(h, buf, (unsigned int)len); yaffs_close(h);}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:9,
示例29: SaveImageFilevoid SaveImageFile(char *str, char *buf, int len){ int h; yaffs_unlink(str); h = yaffs_open(str, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE); yaffs_write(h, buf, len); yaffs_close(h);}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:9,
示例30: test_yaffs_accessint test_yaffs_access(void){ if (-1==yaffs_close(yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE))) { print_message("failed to create file/n",1); return -1; } return yaffs_access(FILE_PATH,0);}
开发者ID:daydaygit,项目名称:smdk6410_version2fl,代码行数:9,
注:本文中的yaffs_close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ yaffs_dev_to_mtd函数代码示例 C++ yLeaveCriticalSection函数代码示例 |