Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
/* 
 * 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;
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
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);
}
Exemplo n.º 13
0
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();
}
Exemplo n.º 14
0
euint8 putty_ls()
{
	SDfile File[20];
	SDfolder Folder[20];
	read_directory(File,Folder,currDir);
	ls(File,Folder);
	return 0;
}
Exemplo n.º 15
0
void 
showHiddenCB(Widget widget, XtPointer ignore,
	     XmToggleButtonCallbackStruct *callback_data)
{
  showHidden = callback_data -> set;

  read_directory((Widget) NULL, ".");
}
Exemplo n.º 16
0
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);
}
Exemplo n.º 17
0
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);
}
Exemplo n.º 18
0
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
	}
}
Exemplo n.º 19
0
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;
}
Exemplo n.º 20
0
Arquivo: ui.c Projeto: Harvie/Programs
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);
}
Exemplo n.º 21
0
bool
is_recursively_up_to_date (url dir) {
  if (!is_up_to_date (dir)) return false;
  bool error_flag;
  array<string> a= read_directory (dir, error_flag);
  for (int i=0; i<N(a); i++)
    if (url (a[i]) != url_here () && url (a[i]) != url_parent ())
      if (is_directory (dir * a[i]))
	if (!is_recursively_up_to_date (dir * a[i]))
	  return false;
  return true;
}
Exemplo n.º 22
0
void				read_through_directory(char *folder_name
											, t_list **directory_list
											, t_list **screw_ups)
{
	DIR				*opened;

	opened = opendir(folder_name);
	ft_list_push_back(directory_list, read_directory(opened));
	if (opened)
		closedir(opened);
	else
		directory_open_failed(folder_name, screw_ups);
}
Exemplo n.º 23
0
Arquivo: dir.c Projeto: B-Rich/git
int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec)
{
	size_t len;

	/*
	 * Calculate common prefix for the pathspec, and
	 * use that to optimize the directory walk
	 */
	len = common_prefix_len(pathspec);

	/* Read the directory and prune it */
	read_directory(dir, pathspec->nr ? pathspec->_raw[0] : "", len, pathspec);
	return len;
}
Exemplo n.º 24
0
Arquivo: dev9.c Projeto: kyuba/dev9
static void ping_for_uevents (const char *dir) {
    sexpr ueventfiles = read_directory (dir);

    for (sexpr x = ueventfiles; consp(x); x = cdr (x))
    {
        sexpr xcar = car(x);
        int f = sys_open (sx_string(xcar), O_WRONLY, 0);

        if (f >= 0) {
            sys_write (f, "add\n", 4);
            sys_close (f);
        }
    }
}
Exemplo n.º 25
0
void edit_sector(int source)
  {
  TSECTOR *p;
  TSTR_LIST l;
  CTL3D b1,b2,b3;

  l=read_directory("c:\\windows\\system\\*.*",DIR_FULL,_A_NORMAL);
  p=&mapa.sectordef[source];
  memcpy(&b1,def_border(1,0),sizeof(CTL3D));
  memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D));
  memcpy(&b3,def_border(3,WINCOLOR),sizeof(CTL3D));
  default_font=vga_font;
  memcpy(f_default,flat_color(0x0000),sizeof(charcolors));
  def_dialoge(100,100,300,200,"String list - test only");
  define(9,10,20,240,170,0,listbox,l,0x1f);c_default(0);
  o_end->autoresizex=1;
  o_end->autoresizey=1;
  define(10,3,42,17,110,1,scroll_bar_v,0,10,1,SCROLLBARCOL);
  property(NULL,NULL,NULL,WINCOLOR);
  o_end->autoresizey=1;
  define(11,1,20,21,17,1,scroll_button,-1,0,"\x1e");
  property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support);
  define(12,1,22,21,17,2,scroll_button,1,10,"\x1f");
  property(NULL,icones,NULL,WINCOLOR);on_change(scroll_support);
  define(20,1,1,10,10,2,resizer);
/*  define(OK_BUTT,100,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);
    on_change(terminate);
  define(CANCEL_BUTT,10,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR);
    on_change(terminate);
  define(-1,5,20,100,12,0,label,"P©ipojen¡:");
  define(10,10,35,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[0]));on_exit(test_int);
  define(20,10,50,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[1]));on_exit(test_int);
  define(30,10,65,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[2]));on_exit(test_int);
  define(40,10,80,50,12,0,input_line,20,0,MAPSIZE-1,"%6d");property(&b2,NULL,NULL,WINCOLOR);
    set_default(strs(p->step_next[3]));on_exit(test_int);
  define(50,70,35,80,12,0,button,"Sever");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(60,70,50,80,12,0,button,"V˜chod");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(70,70,65,80,12,0,button,"Jih");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  define(80,70,80,80,12,0,button,"Z pad");property(&b1,NULL,NULL,WINCOLOR);on_change(edit_side_sup);
  temp_source=source;
  */redraw_window();
  escape();
  close_window(waktual);
  release_list(l);
  }
Exemplo n.º 26
0
// returns list of hashtables of (int -> struct _openslide_tiffdump_item)
GSList *_openslide_tiffdump_create(FILE *f) {
  // read and check magic
  uint16_t magic;
  fseeko(f, 0, SEEK_SET);
  if (fread(&magic, sizeof magic, 1, f) != 1) {
    return NULL;
  }
  if (magic != TIFF_BIGENDIAN && magic != TIFF_LITTLEENDIAN) {
    return NULL;
  }

  //  g_debug("magic: %d", magic);

  int32_t version = read_uint16(f, magic);
  int64_t diroff = read_uint32(f, magic);

  //  g_debug("version: %d", version);

  if (version != TIFF_VERSION) {
    return NULL;
  }

  // initialize loop detector
  GHashTable *loop_detector = g_hash_table_new_full(_openslide_int64_hash,
						    _openslide_int64_equal,
						    _openslide_int64_free,
						    NULL);
  // read all the directories
  GSList *result = NULL;
  while (diroff != 0) {
    // read a directory
    GHashTable *ht = read_directory(f, &diroff, loop_detector, magic);

    // was the directory successfully read?
    if (ht == NULL) {
      // no, so destroy everything
      _openslide_tiffdump_destroy(result);
      result = NULL;
      break;
    }

    // add result to list
    result = g_slist_prepend(result, ht);
  }

  g_hash_table_unref(loop_detector);
  return g_slist_reverse(result);
}
Exemplo n.º 27
0
static void show_files(struct dir_struct *dir, const char *prefix)
{
	int i;

	/* For cached/deleted files we don't need to even do the readdir */
	if (show_others || show_killed) {
		const char *path = ".", *base = "";
		int baselen = prefix_len;

		if (baselen)
			path = base = prefix;
		read_directory(dir, path, base, baselen, pathspec);
		if (show_others)
			show_other_files(dir);
		if (show_killed)
			show_killed_files(dir);
	}
	if (show_cached | show_stage) {
		for (i = 0; i < active_nr; i++) {
			struct cache_entry *ce = active_cache[i];
			int dtype = ce_to_dtype(ce);
			if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
				continue;
			if (show_unmerged && !ce_stage(ce))
				continue;
			if (ce->ce_flags & CE_UPDATE)
				continue;
			show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
		}
	}
	if (show_deleted | show_modified) {
		for (i = 0; i < active_nr; i++) {
			struct cache_entry *ce = active_cache[i];
			struct stat st;
			int err;
			int dtype = ce_to_dtype(ce);
			if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
				continue;
			if (ce->ce_flags & CE_UPDATE)
				continue;
			err = lstat(ce->name, &st);
			if (show_deleted && err)
				show_ce_entry(tag_removed, ce);
			if (show_modified && ce_modified(ce, &st, 0))
				show_ce_entry(tag_modified, ce);
		}
	}
}
Exemplo n.º 28
0
Stack *Read_Stack(char *file_name)
{ Stack *stack;

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

  tif = Open_Tiff(file_name,"r");
  depth = 1;
  while (TIFFReadDirectory(tif))
    depth += 1;
  TIFFClose(tif);

  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;

  { int d;

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

        d += 1;
        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);
}
Exemplo n.º 29
0
int		read_args(t_file *paths, t_command *command)
{
	int		newline;

	if (paths == NULL)
	{
		read_directory(".", command, 0, 0);
		return (1);
	}
	if ((newline = read_args_files(paths, command)) == -1)
		return (-1);
	if (read_arg_dir(paths, command, newline > 0 ? 1 : 0) == -1)
		return (-1);
	delete_command(command);
	return (1);
}
Exemplo n.º 30
0
void
tmfs_import (url prj_dir, url u, string prj) {
  cout << "Process " << (prj_dir * u) << "\n";
  if (is_or (u)) {
    tmfs_import (prj_dir, u[1], prj);
    tmfs_import (prj_dir, u[2], prj);
  }
  else if (is_directory (prj_dir * u)) {
    bool flag;
    array<string> a= read_directory (prj_dir * u, flag);
    if (flag) return;
    for (int i=0; i<N(a); i++)
      if (!is_cruft (a[i]) && a[i] != "." && a[i] != "..")
	tmfs_import (prj_dir, u * a[i], prj);
  }
  else if (is_regular (prj_dir * u)) {
    string loc= as_string (u);
    properties ps;
    ps << seq ("mirror", "?file", prj, loc) << seq ("in", "?file", prj);
    collection files= tmfs_query (ps, "?file");
    if (N (files) == 0) {
      properties xps; xps << seq ("mirror", "self", prj, loc);
      string val = load_string (prj_dir * u);
      string name= create_name (as_string (tail (u)), val);
      string file= tmfs_create_file (name, val, prj, xps);
      cout << "Import " << u << " -> " << file << "\n";
    }
    else {
      string file= first (files);
      string val1= tmfs_load_file (file);
      string val2= load_string (prj_dir * u);
      if (val1 == val2) return;
      tmfs_save_file (file, val2);
      cout << "Update " << u << " -> " << file << "\n";
    }
  }

  properties ps= tmfs_list_heads_inside (u, prj);
  for (int i=0; i<N(ps); i++) {
    url    v = ps[i][0];
    string file= ps[i][1];
    if (!exists (prj_dir * v)) {
      tmfs_reset_head (file);
      cout << "Remove " << v << " -> " << file << "\n";
    }
  }
}