Issue#1: a command option has been added.
This commit is contained in:
parent
8fd9643875
commit
0caca3fdf5
@ -37,8 +37,9 @@
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
EDT_MODIFY = 0,
|
||||
EDT_MODIFY_FO = 0,
|
||||
EDT_DISPLAY = 1,
|
||||
EDT_MODIFY_ED = 2,
|
||||
} edt_mode_t;
|
||||
|
||||
static void display_help(FILE *o, const char *exec_name)
|
||||
@ -52,6 +53,8 @@ static void display_help(FILE *o, const char *exec_name)
|
||||
fprintf(o, "\nOptions:\n");
|
||||
fprintf(o, "\t%-36s Display date and time from exif data only, don't update file creation date.\n",
|
||||
"-d | --display-date");
|
||||
fprintf(o, "\t%-36s Fix/create EXIF creation date based on the file creation date.\n",
|
||||
"-e | --exif-date-fix");
|
||||
fprintf(o, "\t%-36s Display help.\n", "-h | --help");
|
||||
fprintf(o, "\t%-36s Display version information.\n\n", "-v | --version");
|
||||
|
||||
@ -113,7 +116,7 @@ static time_t exifdt_tm(const char *dtbuf)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int opt, fargs = 0, i = 0;
|
||||
edt_mode_t mode = EDT_MODIFY;
|
||||
edt_mode_t mode = EDT_MODIFY_FO;
|
||||
char **fn_name = NULL;
|
||||
ExifData *ef;
|
||||
ExifEntry *entry;
|
||||
@ -126,18 +129,22 @@ int main(int argc, char **argv)
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"display-date", no_argument, NULL, 'd'},
|
||||
{"exif-date-fix", no_argument, NULL, 'e'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{NULL, 0, NULL, 0},
|
||||
};
|
||||
|
||||
if((opt = getopt_long(argc, argv, "dhv", long_options, &option_index)) == -1)
|
||||
if((opt = getopt_long(argc, argv, "dehv", long_options, &option_index)) == -1)
|
||||
break;
|
||||
|
||||
switch(opt) {
|
||||
case 'd':
|
||||
mode = EDT_DISPLAY;
|
||||
break;
|
||||
case 'e':
|
||||
mode = EDT_MODIFY_ED;
|
||||
break;
|
||||
case 'h':
|
||||
display_help(stdout, argv[0]);
|
||||
return 0;
|
||||
@ -189,7 +196,7 @@ int main(int argc, char **argv)
|
||||
case EDT_DISPLAY:
|
||||
fprintf(stdout, "%s date and time: %s\n",fn_name[i], dtbuf);
|
||||
break;
|
||||
case EDT_MODIFY:
|
||||
case EDT_MODIFY_FO:
|
||||
/* convert exif format to timeval */
|
||||
exif_dt = exifdt_tm(dtbuf);
|
||||
if(exif_dt == (time_t) -1)
|
||||
@ -200,6 +207,8 @@ int main(int argc, char **argv)
|
||||
utime(fn_name[i], &ntimes);
|
||||
}
|
||||
break;
|
||||
case EDT_MODIFY_ED:
|
||||
break;
|
||||
}
|
||||
} else fprintf(stdout, "%s: No date and time information exists in exif.\n",
|
||||
fn_name[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user