~ubuntu-branches/ubuntu/trusty/gnome-keyring/trusty-updates

« back to all changes in this revision

Viewing changes to pkcs11/gkm/gkm-util.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-08-24 10:32:10 UTC
  • mfrom: (1.1.80)
  • Revision ID: package-import@ubuntu.com-20120824103210-g4880o16ruf5dq0y
Tags: 3.5.90-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
#include <glib.h>
62
62
#include <glib-object.h>
 
63
#include <glib/gstdio.h>
63
64
 
 
65
#include <errno.h>
 
66
#include <fcntl.h>
64
67
#include <stdio.h>
65
68
#include <string.h>
66
69
 
135
138
        g_object_run_dispose (G_OBJECT (object));
136
139
        g_object_unref (object);
137
140
}
 
141
 
 
142
gchar *
 
143
gkm_util_locate_keyrings_directory (void)
 
144
{
 
145
        gchar *old_directory;
 
146
        gchar *new_directory;
 
147
        gchar *directory;
 
148
 
 
149
        old_directory = g_build_filename (g_get_home_dir (), ".gnome2", "keyrings", NULL);
 
150
        new_directory = g_build_filename (g_get_user_data_dir (), "keyrings", NULL);
 
151
 
 
152
        /*
 
153
         * If the new XDG directory doesn't exist, and the old one does,
 
154
         * use the old one, otherwise create/use the new XDG location.
 
155
         */
 
156
 
 
157
        if (!g_file_test (new_directory, G_FILE_TEST_IS_DIR) &&
 
158
            g_file_test (old_directory, G_FILE_TEST_IS_DIR)) {
 
159
                directory = old_directory;
 
160
                old_directory = NULL;
 
161
 
 
162
                g_message ("using old keyring directory: %s", directory);
 
163
        } else {
 
164
                directory = new_directory;
 
165
                new_directory = NULL;
 
166
 
 
167
                if (g_mkdir_with_parents (directory, S_IRWXU) < 0)
 
168
                        g_warning ("unable to create keyring dir: %s", directory);
 
169
        }
 
170
 
 
171
        g_free (old_directory);
 
172
        g_free (new_directory);
 
173
        return directory;
 
174
}