コード例 #1
0
ファイル: cert_util.c プロジェクト: bzed/pkg-open-vm-tools
gboolean
CertUtil_RemoveDir(const gchar *dirToRemove)
{
   gboolean ret = FALSE;
   GDir *dir = NULL;
   const gchar *file;
   GError *error = NULL;
   gchar *fname = NULL;

   if ((dir = g_dir_open(dirToRemove, 0, &error)) == NULL) {
      Error("Failed to open %s: %s.\n", dirToRemove, error->message);
      goto exit;
   }

   while ((file = g_dir_read_name(dir)) != NULL) {
      g_free(fname);
      fname = g_build_filename(dirToRemove, file, NULL);

      if (g_file_test(fname, G_FILE_TEST_IS_DIR)) {
         if (!CertUtil_RemoveDir(fname)) {
            Error("Couldn't remove the directory '%s'.\n", fname);
            goto exit;
         }
      } else if (g_remove(fname) < 0) {
         Error("Couldn't remove the file '%s'.\n", fname);
         goto exit;
      }
   }

   g_dir_close(dir);
   dir = NULL;

   if (g_rmdir(dirToRemove) < 0) {
      Error("Couldn't remove the directory '%s'.\n", dirToRemove);
      goto exit;
   }

   ret = TRUE;

exit:
   g_free(fname);
   g_clear_error(&error);
   if (dir) {
      g_dir_close(dir);
   }

   return ret;
}
コード例 #2
0
static gboolean
EraseProxyData(void)
{
   gboolean ret = FALSE;

   if (!CheckRootPriv()) {
      goto exit;
   }

   if (g_file_test(guestProxyDir, G_FILE_TEST_IS_DIR)) {
      if (!CertUtil_RemoveDir(guestProxyDir)) {
         Error("Fail to remove the directory '%s'.\n", guestProxyDir);
         goto exit;
      }
   }

   ret = TRUE;

exit:
   return ret;
}