Enable writing ODT files with correct metadata
This commit is contained in:
@@ -35,7 +35,8 @@
|
||||
|
||||
int odttemplate(const char* template_fn, const char* output_fn, struct dict* substitutions_dict) {
|
||||
|
||||
struct archive* arch_in = archive_read_new();
|
||||
struct archive* arch_in = archive_read_new(),
|
||||
*arch_out = archive_write_new();
|
||||
struct archive_entry* ent;
|
||||
struct dict_iter* i;
|
||||
char ftype;
|
||||
@@ -43,41 +44,24 @@ int odttemplate(const char* template_fn, const char* output_fn, struct dict* sub
|
||||
if (archive_read_support_format_zip(arch_in) != ARCHIVE_OK) {
|
||||
return ODTTEMPLATE_FATAL;
|
||||
}
|
||||
if (archive_write_set_format_zip(arch_out) != ARCHIVE_OK) {
|
||||
return ODTTEMPLATE_FATAL;
|
||||
}
|
||||
if (archive_write_zip_set_compression_deflate(arch_out) != ARCHIVE_OK) {
|
||||
return ODTTEMPLATE_FATAL;
|
||||
}
|
||||
if (archive_read_open_filename(arch_in, template_fn, ODTTEMPLATE_BLOCK_SIZE) != ARCHIVE_OK) {
|
||||
return ODTTEMPLATE_FATAL;
|
||||
}
|
||||
if (archive_write_open_filename(arch_out, output_fn) != ARCHIVE_OK) {
|
||||
return ODTTEMPLATE_FATAL;
|
||||
}
|
||||
while (archive_read_next_header(arch_in, &ent) != ARCHIVE_EOF) {
|
||||
switch (archive_entry_filetype(ent)) {
|
||||
case AE_IFREG:
|
||||
ftype = 'F';
|
||||
break;
|
||||
case AE_IFLNK:
|
||||
ftype = 'L';
|
||||
break;
|
||||
case AE_IFSOCK:
|
||||
ftype = 'S';
|
||||
break;
|
||||
case AE_IFCHR:
|
||||
ftype = 'C';
|
||||
break;
|
||||
case AE_IFBLK:
|
||||
ftype = 'B';
|
||||
break;
|
||||
case AE_IFDIR:
|
||||
ftype = 'D';
|
||||
break;
|
||||
case AE_IFIFO:
|
||||
ftype = 'P';
|
||||
break;
|
||||
default:
|
||||
ftype = '?';
|
||||
if ((archive_entry_filetype(ent) == AE_IFREG) &&
|
||||
(dict_find(substitutions_dict, archive_entry_pathname(ent), NULL)
|
||||
== DICT_OK)) {
|
||||
} else {
|
||||
}
|
||||
fn = archive_entry_pathname(ent);
|
||||
printf("%s [%c]", fn, ftype);
|
||||
if (substitutions_dict && (dict_find(substitutions_dict, fn, NULL) == DICT_OK)) {
|
||||
printf(" - in dictionary, skip");
|
||||
}
|
||||
printf("\n");
|
||||
archive_read_data_skip(arch_in);
|
||||
}
|
||||
archive_read_close(arch_in);
|
||||
|
||||
Reference in New Issue
Block a user