Example #1
0
/*
 * Depends on d.qid.vers being highest numbered message in dir.
 */
void
acmetimer(Article *m, Window *w)
{
	Biobuf *b;
	Dir *d;

	assert(m==nil && w==root);

	if((d = dirstat(dir))==nil | hi==d->qid.vers){
		free(d);
		return;
	}

	if(w->data < 0)
		w->data = winopenfile(w, "data");
	if(winsetaddr(w, "0", 0))
		write(w->data, "", 0);

	b = emalloc(sizeof(*b));
	Binit(b, w->data, OWRITE);
	adddir(b, d->qid.vers, hi+1, d->qid.vers);
	hi = d->qid.vers;
	Bterm(b);
	free(b);
	free(d);
	winselect(w, "0,.", 0);
}
Sprite2DView::Sprite2DView()
  : sc(),
    directory(),
    shuffle_directory(),
    mode(),
    zoom(),
    pos(),
    width(),
    height(),
    aspect(),
    index(),
    sprite(),
    new_sprite(),
    fadein(),
    scale(),
    offset(),
    display_time(),
    show_thumbnail(),
    ignore_delta(),
    shuffle(),
    auto_scroll()
{
  auto_scroll = false;
  index = 0;

  for(std::vector<std::string>::iterator i = arg_files.begin(); i != arg_files.end(); ++i)
  {
    if (boost::filesystem::is_directory(i->c_str()))
    { 
      adddir(Pathname(*i, Pathname::kSysPath));
    }
    else
    {
      directory.push_back(Pathname(*i, Pathname::kSysPath));
    }
  }
  
  shuffle_directory = directory;
  shuffle = false;

  //std::sort(shuffle_directory.begin(), shuffle_directory.end());
  //std::random_shuffle(shuffle_directory.begin(), shuffle_directory.end());

  offset = 0.0f;

  if (directory.size() > 1)
    mode = SLIDESHOW;
  else
    mode = SLIDESHOW; 

  zoom = 1.0f;
  pos  = Vector2f(0,0);
  display_time = 0.0f;
  show_thumbnail = false;
  ignore_delta = false;

  next_image(0);
  sprite = new_sprite;
  new_sprite = Sprite();
}
Example #3
0
int npk_add_dir(lua_State* L)
{
    npkg* pkg  = _npkg::_pkgs[lua_tointeger(L, -2)];
    const char* dir = lua_tostring(L, -1);

    if(isDirectory(dir) && pkg && dir)
	adddir(pkg, dir, dir); 

    return 0;
}
Example #4
0
static void
addglobdir (const char *bp, int mandatory) {
	const char *dir;

	while (whitespace(*bp))
		bp++;

	dir = bp;
	if (index(dir, '*') || index(dir, '?') || index(dir, '[')) {
		char **dp = glob_filename (dir);

		if (dp && dp != (char **) -1) {
			while (*dp)
				adddir(*dp++, mandatory);
			return;
		}
	}
	adddir(dir, mandatory);
}
Example #5
0
/* 
 * Show the first nshow messages in the window.
 * This depends on nntpfs presenting contiguously
 * numbered directories, and on the qid version being
 * the topmost numbered directory.
 */
void
dirwindow(Window *w)
{
	if((hi=gethi()) < 0)
		return;

	if(w->data < 0)
		w->data = winopenfile(w, "data");

	fprint(w->ctl, "dirty\n");
	
	winopenbody(w, OWRITE);
	lo = adddir(w->body, hi, 0, nshow);
	winclean(w);
}
void
Sprite2DView::adddir(const Pathname& dirname)
{
  Directory::List lst = Directory::read(dirname);

  for (Directory::List::iterator i = lst.begin(); i != lst.end(); ++i)
  {
    if (boost::filesystem::is_directory(i->get_sys_path()))
    {
      adddir(*i);
    }
    else
    {
      directory.push_back(*i);
    }
  }
}
Example #7
0
void adddir(npkg* pkg, const char* _dir, const char* root)
{
    DIR* dir = opendir(_dir);
    NPK_ENTITY entity;
    struct dirent* ent;
    if(dir == NULL)
	return;
    while((ent = readdir(dir)) != NULL)
    {
	if(strcmp(ent->d_name, ".") == 0 ||
	   strcmp(ent->d_name, "..") == 0)
	    continue;
	char src[0xff];
	snprintf(src, 0xff, "%s/%s", _dir, ent->d_name);
	const char* dest = src;
	if(strstr(dest, root) == dest)
	    dest = dest + strlen(root);
	while(*dest == '/') dest++;
	if(isDirectory(src))
	    adddir(pkg, src, root);
	else
	    npk_package_add_file(pkg->pkg, src, dest, &entity);
    }
}
Example #8
0
/*
 *	Descend through the directories, starting at "name".
 *	Call dofile() for each directory entry.
 *	Save each directory name, and process at the end.
 */
static void
dodir(char *name)
{
	size_t dn_mark, dn_next;
	char *prev_base;
	int seg_stat_err;
	int num_segs;

	strcpy(base_name, name);

	/*
	 * Change to the new directory.
	 * Extend the full path.
	 */
	if ((dir_fd = open(name, O_RDONLY)) == -1) {
		error(0, errno,
		    catgets(catfd, SET, 3088, "Cannot open directory %s"),
		    fullpath);
		if (exit_status < ES_Path) exit_status = ES_Path;
		return;
	}
	getdent_s.offset = 0;
	dir_buf_count = 0;
	if (chdir(name) == -1 && chdir(fullpath) == -1) {
		error(0, errno,
		    catgets(catfd, SET, 3038, "cannot chdir to %s"),
		    fullpath);
		(void) close(dir_fd);
		if (exit_status < ES_Path) exit_status = ES_Path;
		return;
	}
	prev_base = base_name;
	base_name += strlen(name);
	if (base_name[-1] != '/') {
		*base_name++ = '/';
	}
	*base_name = '\0';

	/*
	 * Mark the directory name stack.
	 */
	dn_mark = dn_next = dn_size;

	while (getdent() > 0) {
		/* ignore dot and dot-dot */
		if (strcmp((const char *) dir->d_name, ".") == 0 ||
		    strcmp((const char *) dir->d_name, "..") == 0)
			continue;

		/*
		 * check to assure that construction of the full path name does
		 * not exceed the limit before doing the idstat call
		 */

		if ((int)(strlen(fullpath) + dir->d_namlen + 1) > MAXPATHLEN) {
			error(0, errno,
			    catgets(catfd, SET, 268,
			    "%s: Pathname too long"), fullpath);
			if (exit_status < ES_File) exit_status = ES_File;
			continue;
		}

		strcpy(base_name, (const char *) dir->d_name);
		idstat.id = dir->d_id;
		seg_num = 0;

		if (ioctl(fs_fd, F_IDSTAT, &idstat) < 0) {
			error(0, errno,
			    catgets(catfd, SET, 1090,
			    "Ioctl call to stat %s (%d, %d) failed."),
			    fullpath, (int)idstat.id.ino, idstat.id.gen);
			if (exit_status < ES_IDstat) exit_status = ES_IDstat;
			continue;
		}
		if (S_ISREQ(inode.di.mode)) {
			/*
			 * Try to eliminate removable media files which don't
			 * actually represent space on tape.  These are those
			 * for the archiver and stager, and those created by
			 * users for disaster recovery.
			 * For newly created filesystems, those for the
			 * archiver and stager will have parent inode
			 * SAM_ARCH_INO (5) and SAM_STAGE_INO (7) respectively.
			 * For legacy file systems we don't have a clue.
			 * Those created by users for reading
			 * (disaster recovery) which haven't been referenced
			 * will have size of MAXOFFSET_T, so throw these out too
			 * (in CheckRmStatus() ).
			 */
			if ((inode.di.parent_id.ino != SAM_ARCH_INO) &&
			    (inode.di.parent_id.ino != SAM_STAGE_INO)) {
				CheckRmStatus();
			}
		} else {
			CheckArchiveStatus();
		}

		if (S_ISSEGI(&inode.di)) {
			/*
			 * Inode is an index inode, perform archive_audit of
			 * any archive copies of the file's data segments.
			 */
			seg_stat_err = seg_stat_path(&num_segs);

			if (seg_stat_err) {
				continue;
			}

			for (seg_num = 1; seg_num <= num_segs; seg_num++) {
				idstat.id.ino =
				    (sam_ino_t)seg_stat_buf[seg_num - 1].st_ino;
				idstat.id.gen =
				    (int32_t)seg_stat_buf[seg_num - 1].gen;

				if (ioctl(fs_fd, F_IDSTAT, &idstat) < 0) {
					error(0, errno,
					    catgets(catfd, SET, 1091,
					    "Ioctl call to stat %s, "
					    "segment %d (%d, %d) failed."),
					    fullpath, seg_num,
					    (int)idstat.id.ino, idstat.id.gen);

					if (exit_status < ES_IDstat)
						exit_status = ES_IDstat;
					continue;
				}

				CheckArchiveStatus();
			}
		}

		if (S_ISDIR(inode.di.mode))  adddir((char *)dir->d_name);
	}

	if (close(dir_fd) < 0) {
		error(0, errno,
		    catgets(catfd, SET, 3040,
		    "cannot close directory %s"), fullpath);
		if (exit_status < ES_CloseFile) exit_status = ES_CloseFile;
	}

	/*
	 * Process all the directories found.
	 */
	while (dn_next < dn_size) {
		char *name;

		name = &dir_names[dn_next];
		dn_next += strlen(name) + 1;
		dodir(name);
	}
	dn_size = dn_mark;

	base_name = prev_base;
	*base_name = '\0';
	if (chdir("..") < 0 && chdir(fullpath) < 0) {
		error(0, errno,
		    catgets(catfd, SET, 572,
		    "cannot chdir to \"..\" %s"), fullpath);
		if (exit_status < ES_Path) exit_status = ES_Path;
	}
}
Example #9
0
void
read_config_file (const char *cf) {
     char *bp;
     char *p;
     char buf[BUFSIZE];
     FILE *config = NULL;

     if (cf) {
	  /* User explicitly specified a config file */
	  if ((config = fopen (cf, "r")) == NULL) {
	       perror (cf);
	       gripe (CONFIG_OPEN_ERROR, cf);
	       return;
	  }
     } else {
	  /* Try some things - unfortunately we cannot lookup
	     the config file to use in the config file :-). */
	  int i;

	  for(i=0; i < SIZE(default_config_files); i++) {
	       cf = default_config_files[i];
	       if ((config = fopen (cf, "r")) != NULL)
		    break;
	  }

	  if (config == NULL) {
	       gripe (CONFIG_OPEN_ERROR, CONFIG_FILE);
	       return;
	  }
     }

     if (debug)
	  fprintf(stderr, "Reading config file %s\n", cf);
     configuration_file = cf;

     while ((bp = fgets (buf, BUFSIZE, config)) != NULL) {
	  while (whitespace(*bp))
	       bp++;

	  for (p = bp; *p && *p != '#' && *p != '\n'; p++) ;
	  if (!*p) {
	       gripe (LINE_TOO_LONG);
	       gripe (BAD_CONFIG_FILE, cf);
	       return;
	  }
	  while (p > bp && whitespace(p[-1]))
	       p--;
	  *p = 0;
      
	  if (*bp == 0)
	       continue;

	  if (!strncmp ("MANPATH_MAP", bp, 11))
	       adddir (bp+11, 0);
	  else if (!strncmp ("MANPATH", bp, 7))
	       addglobdir (bp+7, 1);
	  else if(!strncmp ("MANDATORY_MANPATH", bp, 17))/* backwards compatible */
	       adddir (bp+17, 1);
	  else if (!strncmp ("FHS", bp, 3))
	       fhs = 1;
	  else if (!strncmp ("FSSTND", bp, 6))
	       fsstnd = 1;
	  else if (!strncmp ("NOAUTOPATH", bp, 10))
		  noautopath = 1;
	  else if (!strncmp ("NOCACHE", bp, 7))
		  nocache = 1;
	  else if (*bp == '.')
	       addext (bp);
	  else
	       addval (bp);
     }
}
Example #10
0
int
acmecmd(Article *m, Window *w, char *s)
{
	int n;
	Biobuf *b;

//fprint(2, "cmd %s\n", s);

	s = skip(s, "");

	if(iscmd(s, "Del")){
		if(m == nil){	/* don't close dir until messages close */
			if(mlist != nil){
				ctlprint(mlist->w->ctl, "show\n");
				return 1;
			}
			if(windel(w, 0))
				threadexitsall(nil);
			return 1;
		}else{
			if(windel(w, 0))
				m->dead = 1;
			return 1;
		}
	}
	if(m==nil && iscmd(s, "More")){
		s = skip(s, "More");
		if(n = atoi(s))
			nshow = n;

		if(w->data < 0)
			w->data = winopenfile(w, "data");
		winsetaddr(w, "$", 1);
	
		fprint(w->ctl, "dirty\n");

		b = emalloc(sizeof(*b));
		Binit(b, w->data, OWRITE);
		lo = adddir(b, lo, 0, nshow);
		Bterm(b);
		free(b);		
		winclean(w);
		winsetaddr(w, ".,", 0);
	}
	if(m!=nil && !m->ispost && iscmd(s, "Headers")){
		m->headers = !m->headers;
		fillmesgwindow(-1, m);
		return 1;
	}
	if(iscmd(s, "Newpost")){
		m = newpost();
		winopenbody(m->w, OWRITE);
		Bprint(m->w->body, "%s\nsubject: \n\n", group);
		winclean(m->w);
		winselect(m->w, "$", 0);
		return 1;
	}
	if(m!=nil && !m->ispost && iscmd(s, "Reply")){
		replywindow(m);
		return 1;
	}
//	if(m!=nil && iscmd(s, "Replymail")){
//		fprint(2, "no replymail yet\n");
//		return 1;
//	}
	if(iscmd(s, "Post")){
		mesgpost(m);
		return 1;
	}
	return 0;
}