Changeset 5438:8e2438ec5909 for lib.c

Show
Ignore:
Timestamp:
2008-07-01 17:20:02 (5 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

Support displaying application/pgp-keys with GPGME.
This was pretty convoluted because GPGME provides no way to examine a
key block without importing it. This code creates a temporary GPG home
in which to import the key in order to display it.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lib.c

    r5427 r5438  
    4242#include <fcntl.h> 
    4343#include <pwd.h> 
     44#include <dirent.h> 
    4445 
    4546#ifdef HAVE_SYSEXITS_H 
     
    575576  snprintf (newfile, nflen, "%s/%s", newdir, NONULL(basename)); 
    576577  return 0;   
     578} 
     579 
     580/* remove a directory and everything under it */ 
     581int mutt_rmtree (const char* path) 
     582{ 
     583  DIR* dirp; 
     584  struct dirent* de; 
     585  char cur[_POSIX_PATH_MAX]; 
     586  int rc = 0; 
     587 
     588  if (!(dirp = opendir (path))) 
     589  { 
     590    dprint (1, (debugfile, "mutt_rmtree: error opening directory %s\n", path)); 
     591    return -1; 
     592  } 
     593  while ((de = readdir (dirp))) 
     594  { 
     595    if (!strcmp (".", de->d_name) || !strcmp ("..", de->d_name)) 
     596      continue; 
     597 
     598    snprintf (cur, sizeof (cur), "%s/%s", path, de->d_name); 
     599    /* XXX make nonrecursive version */ 
     600    if (de->d_type == DT_DIR) 
     601      rc |= mutt_rmtree (cur); 
     602    else 
     603      rc |= unlink (cur); 
     604  } 
     605  closedir (dirp); 
     606 
     607  rc |= rmdir (path); 
     608 
     609  return rc; 
    577610} 
    578611