+2006-06-29 Bruno Haible <bruno@clisp.org>
+
+ * clean-temp.h: Include <stdbool.h>.
+ (struct temp_dir): Add cleanup_verbose field.
+ (create_temp_dir): Add parentdir, cleanup_verbose arguments.
+ * clean-temp.c (struct tempdir): Add cleanup_verbose field.
+ (create_temp_dir): Add parentdir, cleanup_verbose arguments.
+ (do_unlink. do_rmdir): New functions.
+ (cleanup_temp_file, cleanup_temp_subdir, cleanup_temp_dir_contents,
+ cleanup_temp_dir): Use them.
+ * javacomp.c (is_envjavac_gcj_14_14_usable,
+ is_envjavac_gcj_14_13_usable, is_envjavac_nongcj_usable,
+ is_gcj_present, is_gcj_14_14_usable, is_gcj_14_13_usable,
+ is_javac_usable): Update.
+
2006-06-28 Bruno Haible <bruno@clisp.org>
Assume <dirent.h> on all Unix platforms. Assume closedir works.
{
/* The absolute pathname of the directory. */
char * volatile dirname;
+ /* Whether errors during explicit cleanup are reported to standard error. */
+ bool cleanup_verbose;
/* Absolute pathnames of subdirectories. */
char * volatile * volatile subdir;
size_t volatile subdir_count;
/* Create a temporary directory.
PREFIX is used as a prefix for the name of the temporary directory. It
should be short and still give an indication about the program.
+ PARENTDIR can be used to specify the parent directory; if NULL, a default
+ parent directory is used (either $TMPDIR or /tmp or similar).
+ CLEANUP_VERBOSE determines whether errors during explicit cleanup are
+ reported to standard error.
Return a fresh 'struct temp_dir' on success. Upon error, an error message
is shown and NULL is returned. */
struct temp_dir *
-create_temp_dir (const char *prefix)
+create_temp_dir (const char *prefix, const char *parentdir,
+ bool cleanup_verbose)
{
struct tempdir * volatile *tmpdirp = NULL;
struct tempdir *tmpdir;
cleanup_list.tempdir_count++;
}
- /* Initialize a 'struct tmpdir'. */
+ /* Initialize a 'struct tempdir'. */
tmpdir = (struct tempdir *) xmalloc (sizeof (struct tempdir));
tmpdir->dirname = NULL;
+ tmpdir->cleanup_verbose = cleanup_verbose;
tmpdir->subdir = NULL;
tmpdir->subdir_count = 0;
tmpdir->subdir_allocated = 0;
/* Create the temporary directory. */
template = (char *) xallocsa (PATH_MAX);
- if (path_search (template, PATH_MAX, NULL, prefix, true))
+ if (path_search (template, PATH_MAX, parentdir, prefix, parentdir == NULL))
{
error (0, errno,
_("cannot find a temporary directory, try setting $TMPDIR"));
}
}
+/* Remove a file, with optional error message. */
+static void
+do_unlink (struct temp_dir *dir, const char *absolute_file_name)
+{
+ if (unlink (absolute_file_name) < 0 && dir->cleanup_verbose
+ && errno != ENOENT)
+ error (0, errno, _("cannot remove temporary file %s"), absolute_file_name);
+}
+
+/* Remove a directory, with optional error message. */
+static void
+do_rmdir (struct temp_dir *dir, const char *absolute_dir_name)
+{
+ if (rmdir (absolute_dir_name) < 0 && dir->cleanup_verbose
+ && errno != ENOENT)
+ error (0, errno,
+ _("cannot remove temporary directory %s"), absolute_dir_name);
+}
+
/* Remove the given ABSOLUTE_FILE_NAME and unregister it. */
void
cleanup_temp_file (struct temp_dir *dir,
const char *absolute_file_name)
{
- unlink (absolute_file_name);
+ do_unlink (dir, absolute_file_name);
dequeue_temp_file (dir, absolute_file_name);
}
cleanup_temp_subdir (struct temp_dir *dir,
const char *absolute_dir_name)
{
- rmdir (absolute_dir_name);
+ do_rmdir (dir, absolute_dir_name);
dequeue_temp_subdir (dir, absolute_dir_name);
}
{
char *file = tmpdir->file[--j];
if (file != NULL)
- unlink (file);
+ do_unlink (dir, file);
tmpdir->file_count = j;
/* Now only we can free file. */
if (file != NULL)
{
char *subdir = tmpdir->subdir[--j];
if (subdir != NULL)
- rmdir (subdir);
+ do_rmdir (dir, subdir);
tmpdir->subdir_count = j;
/* Now only we can free subdir. */
if (subdir != NULL)
size_t i;
cleanup_temp_dir_contents (dir);
- rmdir (tmpdir->dirname);
+ do_rmdir (dir, tmpdir->dirname);
for (i = 0; i < cleanup_list.tempdir_count; i++)
if (cleanup_list.tempdir_list[i] == tmpdir)
#ifndef _CLEAN_TEMP_H
#define _CLEAN_TEMP_H
+#include <stdbool.h>
+
#ifdef __cplusplus
extern "C" {
#endif
{
/* The absolute pathname of the directory. */
const char * const dir_name;
+ /* Whether errors during explicit cleanup are reported to standard error. */
+ bool cleanup_verbose;
/* More fields are present here, but not public. */
};
/* Create a temporary directory.
PREFIX is used as a prefix for the name of the temporary directory. It
should be short and still give an indication about the program.
+ PARENTDIR can be used to specify the parent directory; if NULL, a default
+ parent directory is used (either $TMPDIR or /tmp or similar).
+ CLEANUP_VERBOSE determines whether errors during explicit cleanup are
+ reported to standard error.
Return a fresh 'struct temp_dir' on success. Upon error, an error message
is shown and NULL is returned. */
-extern struct temp_dir * create_temp_dir (const char *prefix);
+extern struct temp_dir * create_temp_dir (const char *prefix,
+ const char *parentdir,
+ bool cleanup_verbose);
/* Register the given ABSOLUTE_FILE_NAME as being a file inside DIR, that
needs to be removed before DIR can be removed.
const char *java_sources[1];
struct stat statbuf;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
char *javac_noassert;
bool javac_noassert_works;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
const char *java_sources[1];
struct stat statbuf;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
/* See if libgcj.jar is well installed. */
struct temp_dir *tmpdir;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
gcj_present = false;
else
const char *java_sources[1];
struct stat statbuf;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
const char *java_sources[1];
struct stat statbuf;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
const char *java_sources[1];
struct stat statbuf;
- tmpdir = create_temp_dir ("java");
+ tmpdir = create_temp_dir ("java", NULL, false);
if (tmpdir == NULL)
return true;
+2006-06-29 Bruno Haible <bruno@clisp.org>
+
+ * write-csharp.c (msgdomain_write_csharp): Update.
+ * write-java.c (msgdomain_write_java): Likewise.
+
2006-06-28 Bruno Haible <bruno@clisp.org>
Assume <dirent.h> on all Unix platforms. Assume closedir works.
tmpnam(), tempnam() present a security risk, and on the other hand the
function mkstemp() doesn't allow to specify a fixed suffix of the file.
It is simpler to create a temporary directory. */
- tmpdir = create_temp_dir ("msg");
+ tmpdir = create_temp_dir ("msg", NULL, false);
if (tmpdir == NULL)
goto quit1;
iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
/* Create a temporary directory where we can put the Java file. */
- tmpdir = create_temp_dir ("msg");
+ tmpdir = create_temp_dir ("msg", NULL, false);
if (tmpdir == NULL)
goto quit1;