- /* creating directory */
- if(path[0] == '/') {
- apath = g_strdup(path);
- } else if(path[0] == '~') {
- if(path[1] == '/') {
- apath = g_strconcat(g_get_home_dir(), &path[1], NULL);
+ dname = g_path_get_dirname(path);
+ bname = g_path_get_basename(path);
+
+ bpath = buildpath(dname);
+ g_free(dname);
+
+ fpath = g_build_filename(bpath, bname, NULL);
+ g_free(bname);
+
+
+ if(!(f = fopen(fpath, "a")))
+ die("Could not open file: %s\n", fpath);
+
+ g_chmod(fpath, 0600); /* always */
+ fclose(f);
+
+ return fpath;
+}
+
+static char *
+buildpath(const char *path) {
+ struct passwd *pw;
+ char *apath, *name, *p, *fpath;
+
+ if(path[0] == '~') {
+ if(path[1] == '/' || path[1] == '\0') {
+ p = (char *)&path[1];
+ pw = getpwuid(getuid());