• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_directory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: clean_temp_dirs

static void
clean_temp_dirs () {
  bool err= false;
  array<string> a= read_directory (main_tmp_dir, err);
#ifndef __MINGW32__
  for (int i=0; i<N(a); i++)
    if (is_int (a[i]))
      if (!process_running (as_int (a[i])))
        if (a[i] != as_string ((int) getpid ()))
          system ("rm -rf", url (main_tmp_dir) * url (a[i]));
#else
  /* delete the directories after 7 days */
  time_t ts = as_int (basename (url_temp_dir_sub ())) - (3600 * 24 * 7 );
  for (int i=0; i<N(a); i++)     
    if (is_int (a[i])) {
      time_t td= as_int (a[i]);
      if (td < ts) {
        url cur = url (main_tmp_dir) * url (a[i]);
        array<string> f= read_directory (cur, err);
        for (int j=0; j<N(f); j++) remove (cur * url (f[j]));
        _rmdir (as_charp (as_string (cur)));
      }
    }
#endif
}
开发者ID:xywei,项目名称:texmacs,代码行数:25,代码来源:init_texmacs.cpp


示例2: read_directory_sx

sexpr read_directory_sx (sexpr rx)
{
    sexpr r = sx_end_of_list;

    if (graphp (rx)) {
        r = read_directory_rx (".", rx);
    } else if (stringp (rx)) {
        r = read_directory (sx_string (rx));
    } else if (symbolp (rx)) {
        r = read_directory (sx_symbol (rx));
    }

    return r;
}
开发者ID:fywtat,项目名称:curie,代码行数:14,代码来源:directory-common.c


示例3: indir

camera_directory<Tdata>::camera_directory(const char *dir,
                                          int height_, int width_,
                                          bool randomize_, uint npasses_,
                                          std::ostream &o, std::ostream &e,
                                          const char *pattern,
                                          const std::list<std::string> *files)
    : camera<Tdata>(height_, width_, o, e), indir(dir),
    randomize(randomize_), npasses(npasses_), file_pattern(pattern)
{
    if (npasses == 0)
        eblerror("number of passes must be >= 1");
    out << "Initializing directory camera from: " << dir << std::endl;
    fl = NULL;
    if (files && files->size() > 0)   // file names specified by hand
    { // build list and check each file exists
        fl = new files_list;
        for (std::list<std::string>::const_iterator i = files->begin();
             i != files->end(); ++i)
        {
            std::string fullname;
            fullname << dir << "/" << *i;
            if (file_exists(fullname))
            {
                fl->push_back(stringpair(std::string(dir), *i));
            }
            else
                e << "warning: file not found: " << fullname << std::endl;
        }

        if (fl->size() == 0)
        {
            err << "warning: No images in image list were found: "
                << *files << std::endl;
            err << "Looking for other images..." << std::endl;
            if (!read_directory(dir)) eblerror("No images found in " << dir);
        }
    }
    else     // search all files matching pattern
    {
        if (!read_directory(dir)) eblerror("No images found in " << dir);
    }
    std::cout << "Found " << fl->size() << " images in " << indir << std::endl;
    if (randomize)
        out << "Image list is randomized." << std::endl;
    if (npasses > 1)
        out << "Image list will be used " << npasses << " times." << std::endl;
    flsize = fl->size() * npasses;
    fli = fl->begin(); // initialize iterator to beginning
}
开发者ID:1292765944,项目名称:MobileDemo,代码行数:49,代码来源:camera_directory.hpp


示例4: plugin_list

scheme_tree
plugin_list () {
  bool flag;
  array<string> a= read_directory ("$TEXMACS_PATH/plugins", flag);
  a << read_directory ("/etc/TeXmacs/plugins", flag);
  a << read_directory ("$TEXMACS_HOME_PATH/plugins", flag);
  a << read_directory ("/usr/share/TeXmacs/plugins", flag);
  merge_sort (a);
  int i, n= N(a);
  tree t (TUPLE);
  for (i=0; i<n; i++)
    if ((a[i] != ".") && (a[i] != "..") && ((i==0) || (a[i] != a[i-1])))
      t << a[i];
  return t;
}
开发者ID:xywei,项目名称:texmacs,代码行数:15,代码来源:init_texmacs.cpp


示例5: fill_directory

static void fill_directory(struct dir_struct *dir, const char **pathspec,
		int ignored_too)
{
	const char *path, *base;
	int baselen;

	/* Set up the default git porcelain excludes */
	memset(dir, 0, sizeof(*dir));
	if (!ignored_too) {
		dir->collect_ignored = 1;
		setup_standard_excludes(dir);
	}

	/*
	 * Calculate common prefix for the pathspec, and
	 * use that to optimize the directory walk
	 */
	baselen = common_prefix(pathspec);
	path = ".";
	base = "";
	if (baselen)
		path = base = xmemdupz(*pathspec, baselen);

	/* Read the directory and prune it */
	read_directory(dir, path, base, baselen, pathspec);
	if (pathspec)
		prune_directory(dir, pathspec, baselen);
}
开发者ID:emk,项目名称:git,代码行数:28,代码来源:builtin-add.c


示例6: NOPH_Display_getDisplay

char *cibyl_select_game(char *base_dir)
{
        NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get());
        NOPH_Displayable_t cur = NOPH_Display_getCurrent(display);
        NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance();
        char **p;

        all_games = read_directory(get_current_directory());
        if (!all_games)
                return NULL;

        game_list = NOPH_List_new("Select game", NOPH_Choice_IMPLICIT);

        for (p = all_games; *p; p++)
        {
                NOPH_List_append(game_list, *p, 0);
        }
        NOPH_Display_setCurrent(display, game_list);

        printf("Setting list\n");

        NOPH_CommandMgr_setList(cm, game_list, select_game_callback, NULL);

        while(selected_game == NULL)
        {
                NOPH_Thread_sleep(250);
        }
        free(all_games);

        NOPH_Display_setCurrent(display, cur);
        NOPH_delete(game_list);
        game_list = 0;

        return get_game_directory(selected_game);
}
开发者ID:SimonKagstrom,项目名称:frodo,代码行数:35,代码来源:cibyl-menus.cpp


示例7: wt_status_print_untracked

static void wt_status_print_untracked(struct wt_status *s)
{
    struct dir_struct dir;
    int i;
    int shown_header = 0;
    struct strbuf buf = STRBUF_INIT;

    memset(&dir, 0, sizeof(dir));

    if (!s->untracked) {
        dir.show_other_directories = 1;
        dir.hide_empty_directories = 1;
    }
    setup_standard_excludes(&dir);

    read_directory(&dir, ".", "", 0, NULL);
    for(i = 0; i < dir.nr; i++) {
        struct dir_entry *ent = dir.entries[i];
        if (!cache_name_is_other(ent->name, ent->len))
            continue;
        if (!shown_header) {
            s->workdir_untracked = 1;
            wt_status_print_untracked_header(s);
            shown_header = 1;
        }
        color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
        color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s",
                         quote_path(ent->name, ent->len,
                                    &buf, s->prefix));
    }
    strbuf_release(&buf);
}
开发者ID:certik,项目名称:git,代码行数:32,代码来源:wt-status.c


示例8: cd

euint8 cd(euint8* FolderName)
{
	SDfile File2[200];
	SDfolder Folder2[200];
	if(FolderName == "." )
		return 0;
	if(FolderName=="..")
	{
		return -1;
	}
	read_directory(File2,Folder2,currDir);
	euint8* search = (euint8*)malloc(strlen(FolderName) - LastIndexOf('/',FolderName));
	strCopyLen(FolderName,search,LastIndexOf('/',FolderName));
	euint16 counter=0;
	while(!(Folder2[counter].startH ==0 && Folder2[counter].startL==0)&&counter<20)
	{
		if(strcompare2(Folder2[counter].name,search)==0)
		{
			//we have found our folder
			//now we need to update our pointers
			currDir = Folder2[counter];
			//free(search);
			return 0;
		}
		++counter;
	}
	free(search);
	return -1;
}
开发者ID:JesseNolan,项目名称:FAT32_Filesystem,代码行数:29,代码来源:FAT.c


示例9: play_file

alt_8 play_file(char no_args, char* arg_strings[])
{
	//first we need to open the file
	if(no_args!=1)
	{
		UART_write("This needs a file name\r\n");
		return -1;
	}
	euint8 FFound=0;
	SDfile File[200];
	SDfolder Folder[200];
	read_directory(File,Folder,currDir);
	euint16 i=0;
	for(i=0;i<20;i++)
	{
		if(File[i].valid==1)
		{
			euint8 fname[15];
			euint8 x=0,y=0;
			for(x=0;x<8;x++)
			{
				if(File[i].name[x]!=0x20 && File[i].name[x]!=0x00)
				{//if char is not null and is not space
					fname[y] = File[i].name[x];
					++y;
				}
				else
					x=12;
			}
			fname[y]='.';
			++y;
			for(x=0;x<3;x++)
			{
				if(File[i].extension[x]!=0x20 && File[i].extension[x]!=0x00)
				{//if char is not null and is not space
					fname[y] = File[i].extension[x];
					++y;
				}
				else
					x=12;
			}
			//file is a valid file
			fname[y]=0;//add null terminator
			if(strcompare2(fname,arg_strings[0])==0)
			{
				FFound=1;
				open_wav(File[i]);
			}
		}
	}
	/*
	euint8 buffer[512];
	read_file_chunk(File[6],buffer,512,0);
	*/
	if(FFound==0)
	{
		UART_write("That File cannot be found, check spelling and try again\r\n");
	}
	FFound=0;
}
开发者ID:JesseNolan,项目名称:FAT32_Filesystem,代码行数:60,代码来源:FAT.c


示例10: main

/* 
 * Every sector of of the FAT holds 128 of these 32 bit integers, so looking up the next 
 * cluster of a file is relatively easy. Bits 7-31 of the current cluster tell you which sectors to read from the FAT, and bits 
 * 0-6 tell you which of the 128 integers in that sector contain is the number of the next cluster of your file (or if all ones, that the current cluster is the last).
 */
int main() {
	uint8_t *buf = NULL;
	int ret = 0;

	if ((fp = fopen("/dev/sdb", "rb")) != NULL) {
		if ((buf = malloc(MBR_SECTOR_SIZE)) != NULL) {
			struct mbr_entry *mbr = NULL;
			struct fat_info fti;
			
			/* read the mbr */
			if ((ret = read_sectors(0, 1, buf)) == 0) {
				mbr = (struct mbr_entry *)(buf + MBR_OFFSET);
				
				if ((ret = gen_fat_info(&fti, *mbr)) == 0) {
					if ((ret = read_directory(fti)) != 0) {
						printf("read_directory() failed with %i\n", ret);
					}
				} else {
					printf("gen_fat_info() failed with %i\n", ret);
				}
			} else {
				printf("read_sectors() failed with %i\n", ret);
			}
		} else {
			printf("Unable to allocate %i bytes!\n", MBR_SECTOR_SIZE);
		}
	} else {
		printf("Unable to open file!\n");
	}

	fclose(fp);
	free(buf);
	return 0;
}
开发者ID:xxambivalentxx,项目名称:fattest,代码行数:39,代码来源:test.c


示例11: main

int main(int argc, char *argv[]){
	int file;
	int read_dir;

	if (argc != 2){
		fprintf(stderr, "Usage: %s dir_name\n", argv[0]);
		exit(1);
	}

	open("files.txt",O_TRUNC );
	file = open("files.txt",O_WRONLY | O_APPEND | O_CREAT , S_IRWXG | S_IRWXU | S_IROTH);

	if(file == -1){
		perror("file ERROR");
		close(file);
		exit(1);
	}

	read_dir = read_directory(argv[1],file);

	if(read_dir == 1){
		perror(argv[1]);
		close(file);
		exit(2);
	}else if(read_dir == 2){
		perror("lstat ERROR");
		close(file);
		exit(3);
	}

	close(file);
	execlp("sort", "sort", FILE_NAME,"-no", FILE_NAME, (char*)NULL);

	exit(0);
}
开发者ID:nunomiguel1995,项目名称:SOPE,代码行数:35,代码来源:lsdir.c


示例12: wt_status_collect_untracked

void wt_status_collect_untracked(struct index_state *index,
                                 GList **results,
                                 const char *worktree,
                                 IgnoreFunc ignore_func)
{
    int i;
    struct dir_struct dir;
    DiffEntry *de;

    memset(&dir, 0, sizeof(dir));

    read_directory(&dir, worktree, index);
    for (i = 0; i < dir.nr; i++) {
        struct dir_entry *ent = dir.entries[i];

        if (!ignore_func(ent->name, NULL)) {
            unsigned char sha1[20] = { 0 };
            de = diff_entry_new (DIFF_TYPE_WORKTREE, DIFF_STATUS_ADDED, sha1, ent->name);
            *results = g_list_prepend (*results, de);
        }
        free(ent);
    }

    free(dir.entries);
}
开发者ID:sheyong,项目名称:seafile,代码行数:25,代码来源:status.c


示例13: do_delete_file

static void do_delete_file(UNUSED void *data)
{
	int old_top_file, old_current_file;
	char *ptr;

	if (current_file < 0 || current_file >= flist.num_files)
		return;

	ptr = flist.files[current_file]->path;

	/* would be neat to send it to the trash can if there is one */
	unlink(ptr);

	/* remember the list positions */
	old_top_file = top_file;
	old_current_file = current_file;

	read_directory();

	/* put the list positions back */
	top_file = old_top_file;
	current_file = old_current_file;
	/* edge case: if this was the last file, move the cursor up */
	if (current_file >= flist.num_files)
		current_file = flist.num_files - 1;
	file_list_reposition();
}
开发者ID:HybridDog,项目名称:schismtracker,代码行数:27,代码来源:page_loadinst.c


示例14: putty_ls

euint8 putty_ls()
{
	SDfile File[20];
	SDfolder Folder[20];
	read_directory(File,Folder,currDir);
	ls(File,Folder);
	return 0;
}
开发者ID:JesseNolan,项目名称:FAT32_Filesystem,代码行数:8,代码来源:FAT.c


示例15: showHiddenCB

void 
showHiddenCB(Widget widget, XtPointer ignore,
	     XmToggleButtonCallbackStruct *callback_data)
{
  showHidden = callback_data -> set;

  read_directory((Widget) NULL, ".");
}
开发者ID:CPFDSoftware-Tony,项目名称:gmv,代码行数:8,代码来源:actions.c


示例16: Open_Tiff

Stack *Read_LSM_Stack(char *file_name)
{
  Stack *stack;

  TIFF  *tif;
  int    depth, width, height, kind;

  tif = Open_Tiff(file_name,"r");
  if (!tif) return 0; //070805, bu Hanchuan Peng
	
  depth = 1;
  while (TIFFReadDirectory(tif))
    depth += 1;
  TIFFClose(tif);
  depth = depth / 2;		/* half the dirs are thumbnails */

  tif = Open_Tiff(file_name,"r");
  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);

  kind  = determine_kind(tif);
  stack = new_stack(depth*height*width*kind,"Read_Stack");

  stack->width  = width;
  stack->height = height;
  stack->depth  = depth;
  stack->kind   = kind;

  printf("test1 done\n");

  int d;

  d = 0;
  /* read every other directory (real data, the in between are thumbnails */
  while (1)
  {
	  read_directory(tif,Select_Plane(stack,d),"Read_Stack");
	  
	  d += 1;
	  if (!TIFFReadDirectory(tif)) break;
	  /* skip the one we just read, it's a thumbnail  */

	  if (!TIFFReadDirectory(tif)) break;
	  
	  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
	  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
	  if (width != stack->width || height != stack->height)
          error("Images of stack are not of the same dimensions!",NULL);
	  
	  kind = determine_kind(tif);
	  if (kind != stack->kind)
          error("Images of stack are not of the same type (GREY, GREY16, or COLOR)!",NULL);
  }
  
  TIFFClose(tif);

  return (stack);
}
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:58,代码来源:mg_image_lib11.cpp


示例17: while

Stack *Read_Stack_Planes(char *prefix, int num_width, int first_num)
{ Stack *stack;

  char  sname[1000];
  int   width, height, depth, kind;
  TIFF *tif;

  depth = 0;
  while (1)
    { FILE *fd;

      sprintf(sname,"%s%0*d.tif",prefix,num_width,first_num+depth);
      if ((fd = fopen(sname,"r")) == NULL)
        break;
      fclose(fd);

      depth += 1;
    }

  sprintf(sname,"%s%0*d.tif",prefix,num_width,first_num);
  tif = Open_Tiff(sname,"r");
  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);

  kind  = determine_kind(tif);
  stack = new_stack(depth*height*width*kind,"Read_Stack_Planes");

  stack->width  = width;
  stack->height = height;
  stack->depth  = depth;
  stack->kind   = kind;

  { int d;

    d = 0;
    while (1)
      { read_directory(tif,Select_Plane(stack,d),"Read_Stack_Planes");
        TIFFClose(tif);

        d += 1;
        if (d >= depth) break;

        sprintf(sname,"%s%0*d.tif",prefix,num_width,first_num+d);
        tif = Open_Tiff(sname,"r");
        TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
        TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height);
        if (width != stack->width || height != stack->height)
          error("Images of stack are not of the same dimensions!",NULL);

        kind = determine_kind(tif);
        if (kind != stack->kind)
          error("Images of stack are not of the same type (GREY, GREY16, or COLOR)!",NULL);
      }
  }

  return (stack);
}
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:57,代码来源:mg_image_lib11.cpp


示例18: CONTEXT

void ShellDirectory::smart_scan(int scan_flags)
{
	CONTEXT("ShellEntry::smart_scan()");

	if (!_scanned) {
		free_subentries();
		read_directory(SORT_NAME, scan_flags);	// we could use IShellFolder2::GetDefaultColumn to determine sort order
	}
}
开发者ID:svn2github,项目名称:ros-explorer,代码行数:9,代码来源:entries.cpp


示例19: notes_merge_commit

int notes_merge_commit(struct notes_merge_options *o,
		       struct notes_tree *partial_tree,
		       struct commit *partial_commit,
		       unsigned char *result_sha1)
{
	/*
	 * Iterate through files in .git/NOTES_MERGE_WORKTREE and add all
	 * found notes to 'partial_tree'. Write the updates notes tree to
	 * the DB, and commit the resulting tree object while reusing the
	 * commit message and parents from 'partial_commit'.
	 * Finally store the new commit object SHA1 into 'result_sha1'.
	 */
	struct dir_struct dir;
	char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/"));
	int path_len = strlen(path), i;
	const char *msg = strstr(partial_commit->buffer, "\n\n");

	OUTPUT(o, 3, "Committing notes in notes merge worktree at %.*s",
	       path_len - 1, path);

	if (!msg || msg[2] == '\0')
		die("partial notes commit has empty message");
	msg += 2;

	memset(&dir, 0, sizeof(dir));
	read_directory(&dir, path, path_len, NULL);
	for (i = 0; i < dir.nr; i++) {
		struct dir_entry *ent = dir.entries[i];
		struct stat st;
		const char *relpath = ent->name + path_len;
		unsigned char obj_sha1[20], blob_sha1[20];

		if (ent->len - path_len != 40 || get_sha1_hex(relpath, obj_sha1)) {
			OUTPUT(o, 3, "Skipping non-SHA1 entry '%s'", ent->name);
			continue;
		}

		/* write file as blob, and add to partial_tree */
		if (stat(ent->name, &st))
			die_errno("Failed to stat '%s'", ent->name);
		if (index_path(blob_sha1, ent->name, &st, HASH_WRITE_OBJECT))
			die("Failed to write blob object from '%s'", ent->name);
		if (add_note(partial_tree, obj_sha1, blob_sha1, NULL))
			die("Failed to add resolved note '%s' to notes tree",
			    ent->name);
		OUTPUT(o, 4, "Added resolved note for object %s: %s",
		       sha1_to_hex(obj_sha1), sha1_to_hex(blob_sha1));
	}

	create_notes_commit(partial_tree, partial_commit->parents, msg,
			    result_sha1);
	OUTPUT(o, 4, "Finalized notes merge commit: %s",
	       sha1_to_hex(result_sha1));
	free(path);
	return 0;
}
开发者ID:GunioRobot,项目名称:git,代码行数:56,代码来源:notes-merge.c


示例20: open_directory

void open_directory(GNode *directory)
{
	if (FILE(directory)->read == FALSE && read_directory(directory) == FALSE)
		return;

	FILE(directory)->open = TRUE;
	add_directory_content(directory);
	update_last_line();
	print_lines(g_list_next(FILE(directory)->line), last_line, TRUE);
}
开发者ID:Harvie,项目名称:Programs,代码行数:10,代码来源:ui.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_double函数代码示例发布时间:2022-05-30
下一篇:
C++ read_dir函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap