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

C++ read_dir函数代码示例

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

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



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

示例1: hashtable_install

void hashtable_install( obj table, obj hash, obj key, obj value )
{
  obj vec, bucket;
  UINT_32 i;

  inserting_one( table );
  vec = gvec_read( table, HASHTABLE_DIRECTORY );
    
  for (bucket = read_dir(vec,hash);
       !EQ(bucket,FALSE_OBJ);
       bucket = gvec_read( bucket, BUCKET_OVERFLOW ))
    {
      for (i=SLOT(2); i<SLOT(2+BUCKET_CAPACITY); i+=sizeof(obj))
	{
	  if (EQ(read_bucket_hash(bucket,i),FALSE_OBJ))
	    {
	      write_bucket_hash( bucket, i, hash );
	      write_bucket_key( bucket, i, key );
	      write_bucket_value( bucket, i, value );
	      return;
	    }
	}
    }

  /* grow things... */
    
  split_bucket( table, read_dir( vec, hash ), hash, key, value );
}
开发者ID:bitwize,项目名称:rscheme,代码行数:28,代码来源:hashmain.c


示例2: load_images

void * load_images(void * arg) {
	const char * directory = (const char *)arg;
	read_dir(directory, count_images);

	if (total_images_count > 0) {
		images_info = safe_malloc((total_images_count) * sizeof(image_info));
		images = safe_malloc((total_images_count) * sizeof(bmp));
		read_dir(directory, load_image);
	}

	return NULL;
}
开发者ID:ogail,项目名称:tcss422-homework-solutions,代码行数:12,代码来源:analyzer.c


示例3: try_dir_lookup

bool try_dir_lookup(inode* dir, std::string const& name, uint32_t& ino)
{
	if (!dir)
		throw std::invalid_argument("dir_lookup  null arg: dir");

	// If our path resolution code works as expected, the filename
	// of any path will never be 0 bytes in length. So an assert is fine.
	assert(name.size() > 0);

	if (name.size() > MAX_FILENAME_LEN)
		throw fs_error(ERROR_NAMETOOLONG);

	inode_guard lock(dir->lock);

	auto entries = read_dir(dir);
	for (auto& j : entries) {
		if (!compare_dirent_name(j, name))
			continue;

		ino = j.f_ino;
		return true;
	}

	return false;
}
开发者ID:peredin,项目名称:streams,代码行数:25,代码来源:dir.cpp


示例4: MAIN

int MAIN(ls, int argc, char** argv) {

  if(getcwd(path, sizeof(path)) == 0) {
    printf("errors in getcwd\n");
    return 1;
  }

  int fd = open(path, 0);
  if(fd < 0) {
    printf("cannot open file or directory\n");
    return 1;
  }
  
  char buffer[256];
  fnode_t *dir;
  while((dir = read_dir(fd, buffer, sizeof(buffer)))) {
    if(dir->flags & DIRENT_DIR)
      printf("\e[01;34m");
    printf("%s", buffer);
    printf("\e[00m\n");
    free(dir);
  } 
  
  close(fd);

  return 0;
}
开发者ID:mmikulicic,项目名称:mikucos,代码行数:27,代码来源:ls.c


示例5: dir_unlink

void dir_unlink(inode* inode, std::string const& name)
{
	if (!inode)
		throw std::invalid_argument("dir_unlink  null arg: inode");

	// If our path resolution code works as expected, the filename
	// of any path will never be 0 bytes in length. So an assert is fine.
	assert(name.size() > 0);

	if (name.size() > MAX_FILENAME_LEN)
		throw fs_error(ERROR_NAMETOOLONG);

	inode_guard lock(inode->lock);

	auto entries = read_dir(inode);

	for (auto it = entries.begin(); it != entries.end(); ++it) {
		if (!compare_dirent_name(*it, name))
			continue;

		entries.erase(it);
		write_dir(inode, entries);
		return;
	}

	throw fs_error(ERROR_NOENTRY);
}
开发者ID:peredin,项目名称:streams,代码行数:27,代码来源:dir.cpp


示例6: main

int			main(int argc, char** argv)
{
  SDL_Surface*		screen = NULL;

  if (!fatInitDefault())
    {
      fprintf(stderr, "fatInitDefault failure: terminating\n");
      exit(EXIT_FAILURE);
    }
  read_dir();
  srand(time(NULL));
  if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
      fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
      exit(EXIT_FAILURE);
    }
  fontmap_init();
  WPAD_Init();
  SDL_WM_SetCaption("304pacman", NULL);
  atexit(SDL_Quit);
  SDL_ShowCursor(SDL_DISABLE);
  screen = SDL_SetVideoMode(640, 480, 8, SDL_HWSURFACE);
  if (!screen)
    {
      fprintf(stderr, "Unable to set video: %s\n", SDL_GetError());
      exit(EXIT_FAILURE);
    }
  play(screen);
  SDL_Quit();
  return (EXIT_SUCCESS);
}
开发者ID:payet-s,项目名称:304pacman,代码行数:31,代码来源:main.cpp


示例7: opendir

JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
  (JNIEnv *env, jobject mbean)
{
    DIR *dirp;
    struct dirent dbuf;
    struct dirent* dentp;
    jlong fds = 0;

    dirp = opendir("/proc/self/fd");
    if (dirp == NULL) {
        throw_internal_error(env, "Unable to open directory /proc/self/fd");
        return -1;
    }

    // iterate through directory entries, skipping '.' and '..'
    // each entry represents an open file descriptor.
    while ((dentp = read_dir(dirp, &dbuf)) != NULL) {
        if (isdigit(dentp->d_name[0])) {
            fds++;
        }
    }

    closedir(dirp);
    // subtract by 1 which was the fd open for this implementation
    return (fds - 1);
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:27,代码来源:UnixOperatingSystem_md.c


示例8: dir_link

void dir_link(inode* inode, std::string const& name, uint32_t ino)
{
	assert(inode);
	// If our path resolution code works as expected, the filename
	// of any path will never be 0 bytes in length. So an assert is fine.
	assert(name.size() > 0);

	if (name.size() > MAX_FILENAME_LEN)
		throw fs_error(ERROR_NAMETOOLONG);

	dir_entry ent;
	ent.f_ino = ino;
	if (0 < name.size()) {
		ent.f_namelen = (uint8_t) name.size();
		std::memcpy(ent.f_name, name.c_str(), name.size());
	}

	inode_guard lock(inode->lock);

	auto entries = read_dir(inode);

	for (auto& j : entries) {
		if (!compare_dirent_name(j, name))
			continue;

		throw fs_error(ERROR_EXIST);
	}

	entries.emplace_back(ent);
	write_dir(inode, entries);
}
开发者ID:peredin,项目名称:streams,代码行数:31,代码来源:dir.cpp


示例9: get_lo_la_min_max

/* Auslesen der Minimal- und Maximalwerte der in den Trajektoriendateien
 * enthaltenen Aufpunkte in Laengen- und Breitengrad (lo_min, la_min,
 * lo_max, la_max) 
 */
void 
get_lo_la_min_max(struct state* state) { 

	int i;

	/* Initialisieren */
	state->lo_min = 2; 
	state->la_min = 2;
	state->lo_max = -2;
	state->la_max = -2;
	
	/* Auslesen der Dateinamen der im angegebenen Verzeichnis enthaltenen 
	 * Dateien und Speicherung in einer Dateinamenliste (list) 
	 */
	read_dir(get_string(INPUTDIR), state->list, state->list_max);
	
	/* Durchsuchen der in der Liste enthaltenen Trajektoriendateien nach
	 * den groessten und kleinsten Koordinaten (lo_min, la_min, lo_max,
	 * la_max)
	 */
	for (i = 0; i < state->list_max; i++)
		file_la_lo_min_max(state->list[i], &state->lo_min, 
		    &state->la_min, &state->lo_max, &state->la_max);
	
	/* Umrechnen der Minimal- und Maximalkoordinaten von Rad in Grad */
	state->lo_min = rad2deg(state->lo_min);
	state->la_min = rad2deg(state->la_min);
	state->lo_max = rad2deg(state->lo_max);
	state->la_max = rad2deg(state->la_max);
}
开发者ID:rfinkelnburg,项目名称:Trajectory,代码行数:34,代码来源:frequency.c


示例10: filedialog

CL_FileDialog_Generic::CL_FileDialog_Generic(
	CL_FileDialog *self,
	const std::string &title,
	const std::string &file,
	const std::string &filter)
	: filedialog(self)
{
	behavior = CL_FileDialog::quit_always;
	button = CL_FileDialog::button_none;
	// TODO: Calculate proper size
	int width = 400;
	int height = 315;
	int x = (CL_Display::get_width() - width) / 2;
	int y = (CL_Display::get_height() - height) / 2;
	filedialog->set_position(CL_Rect(x, y, x + width, y + height));
	filedialog->set_title(title);

	CL_Component *client_area = filedialog->get_client_area();

	width = client_area->get_width();

	label_dir = new CL_Label(CL_Point(10, 12), "Directory:", client_area);
	input_dir = new CL_InputBox(CL_Rect(65, 10, width - 120, 30), client_area);
	input_dir->enable(false);

	button_parent = new CL_Button(CL_Rect(width - 115, 9, width - 65, 28), "Parent", client_area);
	button_createdir = new CL_Button(CL_Rect(width - 60, 9, width - 10, 28), "New", client_area);

	treeview_files = new CL_TreeView(CL_Rect(10, 32, width - 10, 197), client_area);
	treeview_files->add_column("Filename", 200);
	treeview_files->add_column("Size", 80);
	treeview_files->add_column("Type", 100);
	treeview_files->show_root_decoration(false);

	label_file = new CL_Label(CL_Point(10, 207), "Filename:", client_area);
	input_file = new CL_InputBox(CL_Rect(65, 205, width - 10, 225), client_area);

	label_filter = new CL_Label(CL_Point(10, 232), "Filter:", client_area);
	input_filter = new CL_InputBox(CL_Rect(65, 230, width - 10, 250), client_area);

	button_ok = new CL_Button(CL_Rect(10, 260, 100, 280), "OK", client_area);
	button_cancel = new CL_Button(CL_Rect(width - 110, 260, width - 10, 280), "Cancel", client_area);

	slots.connect(self->sig_set_options(), this, &CL_FileDialog_Generic::on_set_options);
	slots.connect(treeview_files->sig_selection_changed(), this, &CL_FileDialog_Generic::on_file_activated);
	slots.connect(button_ok->sig_clicked(), this, &CL_FileDialog_Generic::on_button_quit, true);
	slots.connect(button_cancel->sig_clicked(), this, &CL_FileDialog_Generic::on_button_quit, false);
	slots.connect(button_parent->sig_clicked(), this, &CL_FileDialog_Generic::on_button_parent);
	slots.connect(button_createdir->sig_clicked(), this, &CL_FileDialog_Generic::on_button_createdir);
	slots.connect(input_file->sig_return_pressed(), this, &CL_FileDialog_Generic::on_edit_file);
	slots.connect(input_filter->sig_return_pressed(), this, &CL_FileDialog_Generic::on_edit_filter);
	slots.connect(input_dir->sig_return_pressed(), this, &CL_FileDialog_Generic::on_edit_dir);
	
	set_file(file, false);
	set_filter(filter, false);
	show_hidden = false;

	read_dir();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:59,代码来源:filedialog_generic.cpp


示例11: listdir

void listdir(char *d, FILE *fp)
{
	char path[512], rpath[512];
#if 0
	long pathsize = 0;
#endif
	struct _info **dir, **sav;
	int n, i;
	char *s;
	static char *igdir[] = {
		"/nfs", "/dev", "/proc", "/opt", "/tmp", "/etc",
		 "nfs",  "dev",  "proc",  "opt",  "tmp",  "etc",
		NULL
	};

	sav = dir = read_dir(d, &n);
	if (!dir && n) Err("Dir read");
	if (!n) {
		free_dir(sav);
		return;
	}

	qsort(dir, n, sizeof(struct _info *), cmpfunc);

	for(i = 0;i < n;++i) {
#if 0
		if (sizeof(char) * (strlen(d)+strlen(dir[i]->name) + 2) > pathsize)
			path = xrealloc(path,pathsize=(sizeof(char) * (strlen(d)+strlen(dir[i]->name) + 1024)));
#endif
		if (!strncmp(d, "/", 1)) s = d + 1;
		else if (!strncmp(d, "./", 2)) s = d + 2;
		else s = d;
		sprintf(path,"%s/%s", s, dir[i]->name);

		sprintf(rpath,"%s/%s", d, dir[i]->name);

		if (dir[i]->isdir) {
			int j;
			int flg = 1;

			for(j = 0;igdir[j] != NULL;++j) {
				if (!strcmp(path, igdir[j])) {
					flg = 0;
					break;
				}
			}
//			if (flg) listdir(rpath, fp);
		}
		else {
			if (dir[i]->lnk == NULL) {
//				printf("delete %s\n", rpath);
				crstrip(rpath);
			}
		}
	}
//	free(path);
	free_dir(sav);

}
开发者ID:Ntools,项目名称:EnigmaEnc,代码行数:59,代码来源:CRstrip.c


示例12: list_files

void list_files(AMDeviceRef device)
{
    service_conn_t houseFd = start_house_arrest_service(device);

    afc_connection afc_conn;
    afc_connection* afc_conn_p = &afc_conn;
    AFCConnectionOpen(houseFd, 0, &afc_conn_p);

    read_dir(houseFd, afc_conn_p, "/");
}
开发者ID:hkivela,项目名称:fruitstrap,代码行数:10,代码来源:fruitstrap.c


示例13: is_dir_empty

bool is_dir_empty(inode* dir)
{
	if (!dir)
		throw std::invalid_argument("is_dir_empty  null arg: dir");

	inode_guard lock(dir->lock);
	auto content = read_dir(dir);

	return content.empty();
}
开发者ID:peredin,项目名称:streams,代码行数:10,代码来源:dir.cpp


示例14: main

int main(int argc, char *argv[])
{
	if (argc!=3) {
		fprintf(stderr,"Usage: %s hostname dir\n",argv[0]);
		exit(0);
	}
	char dir[DIR_SIZE];
	strcpy(dir, argv[2]);
	read_dir(argv[1], dir);
	printf("%s\n", dir);
	exit(0);
}
开发者ID:PredragWang,项目名称:RPC-Examples,代码行数:12,代码来源:rls.c


示例15: run_dbcheck

int run_dbcheck()
{
    int i = 0;

    __counter = 0;
    while (syscheck.dir[i] != NULL) {
        read_dir(syscheck.dir[i], syscheck.opts[i], syscheck.filerestrict[i]);
        i++;
    }

    return (0);
}
开发者ID:wazuh,项目名称:ossec-wazuh,代码行数:12,代码来源:create_db.c


示例16: main

int main(int argc, char *argv[])
{
    char *path;
    if(argc>1){
        path = argv[1];
        // dir = opendir(argv[1]); /*your directory*/
    } else {
        path = ".";
        // dir = opendir("."); /* Default: current path */
    }
    return read_dir(path);
}
开发者ID:ChrisMacNaughton,项目名称:cls,代码行数:12,代码来源:cls.c


示例17: set_file

void CL_FileDialog_Generic::on_set_options(const CL_DomElement &options)
{
	if (options.has_attribute("file"))
		set_file(options.get_attribute("file"), false);

	if (options.has_attribute("filter"))
		set_filter(options.get_attribute("filter"), false);

	if (options.has_attribute("show_hidden"))
		show_hidden = CL_String::to_bool(options.get_attribute("show_hidden"));

	read_dir();
}
开发者ID:BackupTheBerlios,项目名称:flexlay-svn,代码行数:13,代码来源:filedialog_generic.cpp


示例18: PREP

READDIR3res *nfsproc3_readdir_3_svc(READDIR3args * argp,
				    struct svc_req * rqstp)
{
    static READDIR3res result;
    char *path;

    PREP(path, argp->dir);

    result = read_dir(path, argp->cookie, argp->cookieverf, argp->count);
    result.READDIR3res_u.resok.dir_attributes = get_post_stat(path, rqstp);

    return &result;
}
开发者ID:UIKit0,项目名称:unfs3,代码行数:13,代码来源:nfs.c


示例19: iterate_dir

void iterate_dir(inode* dir, void* pdata, iterate_dir_callback cb)
{
	if (!dir)
		throw std::invalid_argument("iterate_dir  invalid arg: dir");

	inode_guard lock(dir->lock);
	auto entries = read_dir(dir);

	for (auto& j : entries) {
		std::string name(j.f_name, j.f_namelen);
		cb(pdata, j.f_ino, name);
	}
}
开发者ID:peredin,项目名称:streams,代码行数:13,代码来源:dir.cpp


示例20: calculate_database_size

/*
 * calculate size of database in all tablespaces
 */
static int64 calculate_database_size(oid_t dbOid)
{
	int64 totalsize;
	DIR *dirdesc;
	struct dirent *direntry;
	char dirpath[MAX_PG_PATH];
	char pathname[MAX_PG_PATH];
	acl_result_e aclresult;

	/* User must have connect privilege for target database */
	aclresult = db_acl_check(dbOid, get_uid(), ACL_CONNECT);
	if (aclresult != ACLCHECK_OK)
		aclcheck_error(aclresult, ACL_KIND_DATABASE, get_db_name(dbOid));

	/* Shared storage in pg_global is not counted */

	/* Include pg_default storage */
	snprintf(pathname, MAX_PG_PATH, "base/%u", dbOid);
	totalsize = db_dir_size(pathname);

	/* scan_pl the non-default tablespaces */
	snprintf(dirpath, MAX_PG_PATH, "pg_tblspc");
	dirdesc = alloc_dir(dirpath);
	if (!dirdesc)
		ereport(ERROR, (errcode_file_access(),
		errmsg("could not open tablespace directory \"%s\": %m", dirpath)));

	while ((direntry = read_dir(dirdesc, dirpath)) != NULL) {
		CHECK_FOR_INTERRUPTS();

		if (strcmp(direntry->d_name, ".") == 0
			|| strcmp(direntry->d_name, "..") == 0)
			continue;

		snprintf(pathname, MAX_PG_PATH, "pg_tblspc/%s/%s/%u", direntry->d_name,
			 TBS_VERSION_DIR, dbOid);
		totalsize += db_dir_size(pathname);
	}

	free_dir(dirdesc);

	/* Complain if we found no trace of the DB at all */
	if (!totalsize)
		ereport(ERROR,
			(E_UNDEFINED_DATABASE,
			 errmsg("database with OID %u does not exist", dbOid)));

	return totalsize;
}
开发者ID:colinet,项目名称:sqlix,代码行数:52,代码来源:dbsize.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ read_directory函数代码示例发布时间:2022-05-30
下一篇:
C++ read_dev_sector函数代码示例发布时间: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