return data;
}
+void bundle_util_file_insert(const void *data,gsize data_length,const gchar *basename)
+{
+guint8 *buffer;
+
+ g_return_if_fail(data!=NULL);
+ g_return_if_fail(basename!=NULL);
+
+ if (optarg_verbose)
+ g_message(_("Internally storing autogenerated: %s"),basename);
+ udpgate_newn(buffer,sizeof(guint32)+data_length);
+ *((guint32 *)buffer)=GUINT32_TO_BE(data_length);
+ g_assert(data_length==GUINT32_FROM_BE(*(guint32 *)buffer));
+ memcpy(buffer+sizeof(data_length),data,data_length);
+ /* FIXME: Missing duplicity check! */
+ /* FIXME: Missing g_free() on the element removal! */
+ g_hash_table_insert(bundle_hash_new(),g_strdup(basename),buffer);
+}
+
/* Returns TRUE if it safe to overwrite/unlink the file.
*/
static gboolean bundle_util_file_backup_conditional(const gchar *pathname,const gchar *basename)
if (flags&BUNDLE_UTIL_TEMPORARY_MASK) {
struct dir_stack **mkdirs_tail_pointer;
-struct file_stack *file_stack;
/* Stack current 'mkdirs' in front of the current: bundle_util_file_write_atexit_dir_stack_head
* to remove them in the reverse order than created.
*mkdirs_tail_pointer=bundle_util_file_write_atexit_dir_stack_head;
bundle_util_file_write_atexit_dir_stack_head=mkdirs;
mkdirs=NULL;
+ }
+ /* Currently just unsupported: */
+ g_assert(!mkdirs);
+
+ if (-1==(fd=open(pathname,O_WRONLY|O_CREAT|O_TRUNC,pathname_mode))) {
+ if (errno!=EACCES)
+ g_warning(_("Error opening the file \"%s\" for rewrite: %m"),pathname);
+ return FALSE;
+ }
+ /* Register the file only if it got already created.
+ * Do not atempt to remove files which are not ours!
+ */
+ if (flags&BUNDLE_UTIL_TEMPORARY_MASK) {
+struct file_stack *file_stack;
/* Register also the file itself. */
udpgate_new(file_stack);
file_stack->next=bundle_util_file_write_atexit_file_stack_head;
bundle_util_file_write_atexit_file_stack_head=file_stack;
}
- /* Currently just unsupported: */
- g_assert(!mkdirs);
- if (-1==(fd=open(pathname,O_WRONLY|O_CREAT|O_TRUNC,pathname_mode))) {
- if (errno!=EPERM)
- g_warning(_("Error opening the file \"%s\" for rewrite: %m"),pathname);
- return FALSE;
- }
if ((int)data_length!=write(fd,data,data_length)) {
g_warning(_("Error writing the data of the file \"%s\" being overwritten: %m"),pathname);
close(fd); /* errors ignored */