|
|
@ -37,8 +37,9 @@
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
typedef enum {
|
|
|
|
EDT_MODIFY = 0,
|
|
|
|
EDT_MODIFY_FO = 0,
|
|
|
|
EDT_DISPLAY = 1,
|
|
|
|
EDT_DISPLAY = 1,
|
|
|
|
|
|
|
|
EDT_MODIFY_ED = 2,
|
|
|
|
} edt_mode_t;
|
|
|
|
} edt_mode_t;
|
|
|
|
|
|
|
|
|
|
|
|
static void display_help(FILE *o, const char *exec_name)
|
|
|
|
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, "\nOptions:\n");
|
|
|
|
fprintf(o, "\t%-36s Display date and time from exif data only, don't update file creation date.\n",
|
|
|
|
fprintf(o, "\t%-36s Display date and time from exif data only, don't update file creation date.\n",
|
|
|
|
"-d | --display-date");
|
|
|
|
"-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 help.\n", "-h | --help");
|
|
|
|
fprintf(o, "\t%-36s Display version information.\n\n", "-v | --version");
|
|
|
|
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 main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int opt, fargs = 0, i = 0;
|
|
|
|
int opt, fargs = 0, i = 0;
|
|
|
|
edt_mode_t mode = EDT_MODIFY;
|
|
|
|
edt_mode_t mode = EDT_MODIFY_FO;
|
|
|
|
char **fn_name = NULL;
|
|
|
|
char **fn_name = NULL;
|
|
|
|
ExifData *ef;
|
|
|
|
ExifData *ef;
|
|
|
|
ExifEntry *entry;
|
|
|
|
ExifEntry *entry;
|
|
|
@ -126,18 +129,22 @@ int main(int argc, char **argv)
|
|
|
|
static struct option long_options[] =
|
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{"display-date", no_argument, NULL, 'd'},
|
|
|
|
{"display-date", no_argument, NULL, 'd'},
|
|
|
|
|
|
|
|
{"exif-date-fix", no_argument, NULL, 'e'},
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"version", no_argument, NULL, 'v'},
|
|
|
|
{"version", no_argument, NULL, 'v'},
|
|
|
|
{NULL, 0, NULL, 0},
|
|
|
|
{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;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
switch(opt) {
|
|
|
|
switch(opt) {
|
|
|
|
case 'd':
|
|
|
|
case 'd':
|
|
|
|
mode = EDT_DISPLAY;
|
|
|
|
mode = EDT_DISPLAY;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
|
|
|
|
mode = EDT_MODIFY_ED;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
display_help(stdout, argv[0]);
|
|
|
|
display_help(stdout, argv[0]);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -189,7 +196,7 @@ int main(int argc, char **argv)
|
|
|
|
case EDT_DISPLAY:
|
|
|
|
case EDT_DISPLAY:
|
|
|
|
fprintf(stdout, "%s date and time: %s\n",fn_name[i], dtbuf);
|
|
|
|
fprintf(stdout, "%s date and time: %s\n",fn_name[i], dtbuf);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case EDT_MODIFY:
|
|
|
|
case EDT_MODIFY_FO:
|
|
|
|
/* convert exif format to timeval */
|
|
|
|
/* convert exif format to timeval */
|
|
|
|
exif_dt = exifdt_tm(dtbuf);
|
|
|
|
exif_dt = exifdt_tm(dtbuf);
|
|
|
|
if(exif_dt == (time_t) -1)
|
|
|
|
if(exif_dt == (time_t) -1)
|
|
|
@ -200,6 +207,8 @@ int main(int argc, char **argv)
|
|
|
|
utime(fn_name[i], &ntimes);
|
|
|
|
utime(fn_name[i], &ntimes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EDT_MODIFY_ED:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else fprintf(stdout, "%s: No date and time information exists in exif.\n",
|
|
|
|
} else fprintf(stdout, "%s: No date and time information exists in exif.\n",
|
|
|
|
fn_name[i]);
|
|
|
|
fn_name[i]);
|
|
|
|