Option to set default values for file timestamps.

This commit is contained in:
Vreixo Formoso 2008-01-23 19:46:36 +01:00
parent ebcd5883e2
commit d92f8f68d2
8 changed files with 29 additions and 4 deletions

View File

@ -72,6 +72,8 @@ int main(int argc, char **argv)
0, /* file_mode */ 0, /* file_mode */
0, /* uid */ 0, /* uid */
0, /* gid */ 0, /* gid */
0, /* replace_timestamps */
0, /* timestamp */
NULL, /* output charset */ NULL, /* output charset */
0, /* appendable */ 0, /* appendable */
0, /* ms_block */ 0, /* ms_block */

View File

@ -54,6 +54,8 @@ int main(int argc, char **argv)
0, /* file_mode */ 0, /* file_mode */
0, /* uid */ 0, /* uid */
0, /* gid */ 0, /* gid */
0, /* replace_timestamps */
0, /* timestamp */
NULL, /* output charset */ NULL, /* output charset */
0, /* appendable */ 0, /* appendable */
0, /* ms_block */ 0, /* ms_block */

View File

@ -49,6 +49,8 @@ int main(int argc, char **argv)
0, /* file_mode */ 0, /* file_mode */
0, /* uid */ 0, /* uid */
0, /* gid */ 0, /* gid */
0, /* replace_timestamps */
0, /* timestamp */
NULL, /* output charset */ NULL, /* output charset */
0, /* appendable */ 0, /* appendable */
0, /* ms_block */ 0, /* ms_block */

View File

@ -49,6 +49,8 @@ int main(int argc, char **argv)
0, /* file_mode */ 0, /* file_mode */
0, /* uid */ 0, /* uid */
0, /* gid */ 0, /* gid */
0, /* replace_timestamps */
0, /* timestamp */
NULL, /* output charset */ NULL, /* output charset */
0, /* appendable */ 0, /* appendable */
0, /* ms_block */ 0, /* ms_block */

View File

@ -848,7 +848,11 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
target->now = time(NULL); target->now = time(NULL);
target->ms_block = opts->ms_block; target->ms_block = opts->ms_block;
target->appendable = opts->appendable; target->appendable = opts->appendable;
target->replace_timestamps = opts->replace_timestamps ? 1 : 0;
target->timestamp = opts->replace_timestamps == 2 ?
opts->timestamp : target->now;
/* el-torito? */ /* el-torito? */
target->eltorito = (src->bootcat == NULL ? 0 : 1); target->eltorito = (src->bootcat == NULL ? 0 : 1);
target->catalog = src->bootcat; target->catalog = src->bootcat;

View File

@ -58,11 +58,13 @@ struct ecma119_image
unsigned int replace_gid :1; unsigned int replace_gid :1;
unsigned int replace_file_mode :1; unsigned int replace_file_mode :1;
unsigned int replace_dir_mode :1; unsigned int replace_dir_mode :1;
unsigned int replace_timestamps :1;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
mode_t file_mode; mode_t file_mode;
mode_t dir_mode; mode_t dir_mode;
time_t timestamp;
/** /**
* if sort files or not. Sorting is based of the weight of each file * if sort files or not. Sorting is based of the weight of each file

View File

@ -184,6 +184,14 @@ struct ecma119_write_opts {
uid_t uid; /** uid to use when replace_uid == 2. */ uid_t uid; /** uid to use when replace_uid == 2. */
gid_t gid; /** gid to use when replace_gid == 2. */ gid_t gid; /** gid to use when replace_gid == 2. */
/**
* 0 to use IsoNode timestamps, 1 to use recording time, 2 to use
* values from timestamp field. This has only meaning if RR extensions
* are enabled.
*/
unsigned int replace_timestamps :2;
time_t timestamp;
/** /**
* Charset for the RR filenames that will be created. * Charset for the RR filenames that will be created.
* NULL to use default charset, the locale one. * NULL to use default charset, the locale one.

View File

@ -113,6 +113,7 @@ int rrip_add_PX(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
static static
int rrip_add_TF(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp) int rrip_add_TF(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
{ {
IsoNode *iso;
uint8_t *TF = malloc(5 + 3 * 7); uint8_t *TF = malloc(5 + 3 * 7);
if (TF == NULL) { if (TF == NULL) {
return ISO_OUT_OF_MEM; return ISO_OUT_OF_MEM;
@ -123,9 +124,11 @@ int rrip_add_TF(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
TF[2] = 5 + 3 * 7; TF[2] = 5 + 3 * 7;
TF[3] = 1; TF[3] = 1;
TF[4] = (1 << 1) | (1 << 2) | (1 << 3); TF[4] = (1 << 1) | (1 << 2) | (1 << 3);
iso_datetime_7(&TF[5], n->node->mtime);
iso_datetime_7(&TF[12], n->node->atime); iso = n->node;
iso_datetime_7(&TF[19], n->node->ctime); iso_datetime_7(&TF[5], t->replace_timestamps ? t->timestamp : iso->mtime);
iso_datetime_7(&TF[12], t->replace_timestamps ? t->timestamp : iso->atime);
iso_datetime_7(&TF[19], t->replace_timestamps ? t->timestamp : iso->ctime);
return susp_append(t, susp, TF); return susp_append(t, susp, TF);
} }