diff options
author | Havoc Pennington <hp@redhat.com> | 2002-08-04 18:16:52 +0000 |
---|---|---|
committer | Havoc Pennington <hp@pobox.com> | 2002-08-04 18:16:52 +0000 |
commit | cfd78005708d5bebd2f00be5176ec2eb8ffbecdd (patch) | |
tree | 914ae788ba51746f74e19fcb0e03f06c7a78ba87 | |
parent | 0a4715e8a7371b1bdda57c558f158cee34ccf0f6 (diff) |
create target directory if it doesn't exist.DESKTOP_FILE_UTILS_0_3
2002-08-04 Havoc Pennington <hp@redhat.com>
* src/install.c (main): create target directory if it doesn't
exist.
* configure.in: 0.3
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | INSTALL | 0 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/install.c | 35 |
4 files changed, 43 insertions, 1 deletions
@@ -1,3 +1,10 @@ +2002-08-04 Havoc Pennington <hp@redhat.com> + + * src/install.c (main): create target directory if it doesn't + exist. + + * configure.in: 0.3 + 2002-08-01 Havoc Pennington <hp@redhat.com> * src/vfolder-query.c (add_or_free_desktop_file): when complaining diff --git a/configure.in b/configure.in index 6cb53e6..7e6b2de 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ AC_INIT(src/desktop_file.h) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(desktop-file-utils, 0.2) +AM_INIT_AUTOMAKE(desktop-file-utils, 0.3) # Honor aclocal flags ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS" diff --git a/src/install.c b/src/install.c index a0108e7..09ae30f 100644 --- a/src/install.c +++ b/src/install.c @@ -452,6 +452,27 @@ parse_options_callback (poptContext ctx, } } +static void +mkdir_and_parents (const char *dirname, + mode_t mode) +{ + char *parent; + char *slash; + + parent = g_strdup (dirname); + slash = NULL; + if (*parent != '\0') + slash = strrchr (parent, '/'); + if (slash != NULL) + { + *slash = '\0'; + mkdir_and_parents (parent, mode); + } + g_free (parent); + + mkdir (dirname, mode); +} + int main (int argc, char **argv) { @@ -460,6 +481,7 @@ main (int argc, char **argv) GError* err = NULL; const char** args; int i; + mode_t dir_permissions; setlocale (LC_ALL, ""); @@ -499,6 +521,19 @@ main (int argc, char **argv) if (target_dir == NULL) target_dir = g_build_filename (DATADIR, "applications", NULL); + + /* Create the target directory */ + dir_permissions = permissions; + + /* Add search bit when the target file is readable */ + if (permissions & 0400) + dir_permissions |= 0100; + if (permissions & 0040) + dir_permissions |= 0010; + if (permissions & 0004) + dir_permissions |= 0001; + + mkdir_and_parents (target_dir, dir_permissions); args = poptGetArgs (ctx); |