コード例 #1
0
ファイル: main.c プロジェクト: GNOME/gimp-pspi
static void
scan_search_path (void)
{
  GList *path_list;
  GList *list; 

  /* Scan search_path looking for PS plug-ins */
  path_list = gimp_path_parse (search_path, 99, TRUE, NULL);

  list = path_list;
  while (list != NULL)
    {
      gchar *path = list->data;
      list = list->next;

      my_ftw (path, scan_filter);
    }
}
コード例 #2
0
ファイル: 4-7.c プロジェクト: njuguoyi/APUE3
int main(int argc, const char *argv[])
{
	int ret;
	if (argc != 2)
		err_quit("usage: a.out <starting-pathname>");

	ret = my_ftw(argv[1], my_count);
	ntot = nreg + ndir + nblk + nchr + nfifo + nslink + nsock;
	if (ntot == 0)
		ntot = 1;
	printf("regular files 	= %7ld, %5.2f %%\n", nreg, nreg*100.0/ntot);
	printf("directories	= %7ld, %5.2f %%\n", ndir, ndir*100.0/ntot);
	printf("block special	= %7ld, %5.2f %%\n", nblk, nblk*100.0/ntot);
	printf("char special	= %7ld, %5.2f %%\n", nchr, nchr*100.0/ntot);
	printf("FIFO		= %7ld, %5.2f %%\n", nfifo, nfifo*100.0/ntot);
	printf("symbolic links	= %7ld, %5.2f %%\n", nslink, nslink*100.0/ntot);
	printf("sockets		= %7ld, %5.2f %%\n", nsock, nsock*100.0/ntot);
	return ret;
}
コード例 #3
0
ファイル: main.c プロジェクト: GNOME/gimp-pspi
static gint
my_ftw (const gchar *path,
	gint       (*function) (const gchar       *filename,
				const struct stat *statp))
{
  DIR *dir;
  struct dirent *dir_ent;

  dir = opendir (path);

  if (dir == NULL)
    {
      PSPI_DEBUG (PSPIRC, g_print ("opendir(%s) failed: %s\n", path, g_strerror (errno))); 
      if (errno == EACCES)
	return 0;
      return -1;
    }

  while ((dir_ent = readdir (dir)) != NULL)
    {
      gchar *file;
      struct stat s;

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

      file = g_strconcat (path, G_DIR_SEPARATOR_S,  dir_ent->d_name, NULL);

      if (stat (file, &s) == 0)
	{
	  gint retval;

	  retval = (*function) (file, &s);
	  if (retval == 0 && (s.st_mode & S_IFDIR))
	    retval = my_ftw (file, function);

	  if (retval != 0)
	    {
	      int saved_errno = errno;
	      g_free (file);
	      closedir (dir);
	      errno = saved_errno;
	      return retval;
	    }
	}
      else
	{
	  PSPI_DEBUG (PSPIRC, g_print ("stat(%s) failed: %s\n", file, g_strerror (errno)));
	  if (errno != EACCES)
	    {
	      int saved_errno = errno;
	      g_free (file);
	      closedir (dir);
	      errno = saved_errno;
	      return -1;
	    }
	}
      g_free (file);
    }
  closedir (dir);
  return 0;
}