Exemple #1
0
int		main(int argc, char **argv )
{
	ls_type		lst;
	t_list		*tmp;
	name_stat	*namestat;

	lst.arg_files = ft_lstnew(0, 0);
	lst.arg_dir = ft_lstnew(0, 0);
	if (argc == 1)
		argv = 0;
//		ft_display(&sd, &dir);
	else
		ft_ls_type(&lst, argc, argv);
	if (lst.arg_dir->content == NULL && lst.arg_files->content == NULL)
		readdirectory(&lst, ".");
	tmp = lst.arg_dir;
	while (tmp->next != NULL)
	{
		namestat = (name_stat*)tmp->content;
		ft_putendl(namestat->name);
		tmp = tmp->next;
	}
	tmp = lst.arg_files;
	while (tmp->next != NULL)
	{
		namestat = (name_stat*)tmp->content;
		ft_putendl(namestat->name);
		tmp = tmp->next;
	}
	return (1);
}
Exemple #2
0
/*
 *
 *  Add a list of directory entries buttons to a RC widget.
 *
 *
 */ 
int AddButtonsToPanel ( ButtonParentObjectType  *bpo,
		 void		(*func)(), 
		 int		metObjectType,
		 char		*fulldirectorypath )
{

	int			cnt, i, j, count;
	ButtonObject		*bo;
	int			argc; 
	char			**argv;
	int			returnStatus;

	if ( GetVerboseLevel() > VERBOSE_0 )
	    printf("AddButtonsToPanel\n");

/*
 *	Get the sorted directory listing...
 */
	argc = readdirectory ( fulldirectorypath, &argv , NULL, NULL);
	if( argc <= 0 )
		return ( 1 );


	returnStatus = UpdateButtonPanel( bpo, func, metObjectType, 
				fulldirectorypath, argc, argv);

	free ( argv );

	return ( returnStatus );

}
Exemple #3
0
static int
grep_or_recurse(char *filename, BOOL dir_recurse, BOOL show_filenames,
  BOOL only_one_at_top)
{
int rc = 1;
int sep;
FILE *in;

/* If the file is a directory and we are recursing, scan each file within it.
The scanning code is localized so it can be made system-specific. */

if ((sep = isdirectory(filename)) != 0 && dir_recurse)
  {
  char buffer[1024];
  char *nextfile;
  directory_type *dir = opendirectory(filename);

  if (dir == NULL)
    {
    fprintf(stderr, "pcregrep: Failed to open directory %s: %s\n", filename,
      strerror(errno));
    return 2;
    }

  while ((nextfile = readdirectory(dir)) != NULL)
    {
    int frc;
    sprintf(buffer, "%.512s%c%.128s", filename, sep, nextfile);
    frc = grep_or_recurse(buffer, dir_recurse, TRUE, FALSE);
    if (frc == 0 && rc == 1) rc = 0;
    }

  closedirectory(dir);
  return rc;
  }

/* If the file is not a directory, or we are not recursing, scan it. If this is
the first and only argument at top level, we don't show the file name (unless
we are only showing the file name). Otherwise, control is via the
show_filenames variable. */

in = fopen(filename, "r");
if (in == NULL)
  {
  fprintf(stderr, "pcregrep: Failed to open %s: %s\n", filename, strerror(errno));
  return 2;
  }

rc = pcregrep(in, (filenames_only || (show_filenames && !only_one_at_top))?
  filename : NULL);
fclose(in);
return rc;
}
Exemple #4
0
int
GetImageFileList ( int type, char *path, char ***files, int *start, int *count)
{
	int	argc;
	int	newstart, newcnt;
	

/*
 *	Read the directory and time filter 
 */
	argc  = readdirectory(path, files, NULL, NULL);
	FilterProducts( type, argc, path, *files, &newstart, &newcnt );

	*start = newstart;
	*count = newcnt;

	return (argc);

}
Exemple #5
0
static unsigned int protocol_read(struct service_backend *backend, struct service_state *state, unsigned int id, unsigned int current, void *buffer, unsigned int count, unsigned int offset)
{

    struct cpio_header *header = mapheader(backend, state, id);

    if (!header)
        return 0;

    switch (header->mode & 0xF000)
    {

    case 0x8000:
        return readfile(backend, state, buffer, count, offset, id, header);

    case 0x4000:
        return readdirectory(backend, state, buffer, count, offset, current, header);

    }

    return 0;

}
Exemple #6
0
static unsigned int protocol_read(struct service_backend *backend, struct service_state *state, void *buffer, unsigned int count)
{

    struct cpio_header header;

    if (!readheader(backend, &header, state->id))
        return 0;

    switch (header.mode & 0xF000)
    {

    case 0x8000:
        return readfile(backend, buffer, count, state->offset, state->id, &header);

    case 0x4000:
        return readdirectory(backend, buffer, count, state->current, &header);

    }

    return 0;

}
Exemple #7
0
static int
grep_or_recurse(char *pathname, BOOL dir_recurse, BOOL show_filenames,
  BOOL only_one_at_top)
{
int rc = 1;
int sep;
FILE *in;
char *printname;

/* If the file name is "-" we scan stdin */

if (strcmp(pathname, "-") == 0)
  {
  return pcregrep(stdin,
    (filenames_only || filenames_nomatch_only ||
    (show_filenames && !only_one_at_top))?
      stdin_name : NULL);
  }

/* If the file is a directory and we are recursing, scan each file within it,
subject to any include or exclude patterns that were set. The scanning code is
localized so it can be made system-specific. */

if ((sep = isdirectory(pathname)) != 0 && dir_recurse)
  {
  char buffer[1024];
  char *nextfile;
  directory_type *dir = opendirectory(pathname);

  if (dir == NULL)
    {
    if (!silent)
      fprintf(stderr, "pcregrep: Failed to open directory %s: %s\n", pathname,
        strerror(errno));
    return 2;
    }

  while ((nextfile = readdirectory(dir)) != NULL)
    {
    int frc, blen;
    sprintf(buffer, "%.512s%c%.128s", pathname, sep, nextfile);
    blen = strlen(buffer);

    if (exclude_compiled != NULL &&
        pcre_exec(exclude_compiled, NULL, buffer, blen, 0, 0, NULL, 0) >= 0)
      continue;

    if (include_compiled != NULL &&
        pcre_exec(include_compiled, NULL, buffer, blen, 0, 0, NULL, 0) < 0)
      continue;

    frc = grep_or_recurse(buffer, dir_recurse, TRUE, FALSE);
    if (frc > 1) rc = frc;
     else if (frc == 0 && rc == 1) rc = 0;
    }

  closedirectory(dir);
  return rc;
  }

/* If the file is not a directory, or we are not recursing, scan it. If this is
the first and only argument at top level, we don't show the file name (unless
we are only showing the file name). Otherwise, control is via the
show_filenames variable. */

in = fopen(pathname, "r");
if (in == NULL)
  {
  if (!silent)
    fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pathname,
      strerror(errno));
  return 2;
  }

printname =  (filenames_only || filenames_nomatch_only ||
  (show_filenames && !only_one_at_top))? pathname : NULL;

rc = pcregrep(in, printname);

fclose(in);
return rc;
}