Die immediately if the output file is a directory.

Thu Nov  9 16:01:47 2006  Søren Sandmann  <sandmann@redhat.com>

        * sysprof-text.c (main): Die immediately if the output file is a
        directory.

        * autogen.sh (DIE): Also work when automake-1.9 is installed.
This commit is contained in:
Søren Sandmann
2006-11-09 21:02:31 +00:00
committed by Søren Sandmann Pedersen
parent 0513ed87e8
commit 442a9b4f3c
4 changed files with 31 additions and 5 deletions

View File

@ -86,6 +86,14 @@ usage_msg (const char *name)
name);
}
static gboolean
file_exists_and_is_dir (const char *name)
{
return
g_file_test (name, G_FILE_TEST_EXISTS) &&
g_file_test (name, G_FILE_TEST_IS_DIR);
}
static void
die (const char *err_msg)
{
@ -119,6 +127,13 @@ main (int argc,
if (!signal_set_handler (SIGINT, signal_handler, app, &err))
die (err->message);
if (file_exists_and_is_dir (app->outfile))
{
char *msg = g_strdup_printf ("Can't write to %s: is a directory\n",
app->outfile);
die (msg);
}
g_main_loop_run (app->main_loop);