diff options
author | Martin Szulecki | 2010-03-13 19:56:00 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-03-13 19:56:00 +0100 |
commit | b6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a (patch) | |
tree | 6fbbc0f162994c35d2a8c252f424becf2baf895a | |
parent | 1ab0490c9db82f8aa05956b53a799f73d422d52f (diff) | |
download | libimobiledevice-b6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a.tar.gz libimobiledevice-b6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a.tar.bz2 |
Use current date and time in filename of screenshot tool
-rw-r--r-- | tools/idevicescreenshot.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c index ca4454c..1604198 100644 --- a/tools/idevicescreenshot.c +++ b/tools/idevicescreenshot.c @@ -2,6 +2,7 @@ #include <string.h> #include <stdlib.h> #include <errno.h> +#include <time.h> #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> @@ -68,19 +69,22 @@ int main(int argc, char **argv) printf("Could not connect to screenshotr!\n"); } else { char *imgdata = NULL; + char filename[36]; uint64_t imgsize = 0; + time_t now = time(NULL); + strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now)); if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) { - FILE *f = fopen("screenshot.tiff", "w"); + FILE *f = fopen(filename, "w"); if (f) { if (fwrite(imgdata, 1, (size_t)imgsize, f) == (size_t)imgsize) { - printf("Screenshot saved to screenshot.tiff\n"); + printf("Screenshot saved to %s\n", filename); result = 0; } else { - printf("Could not save screenshot to file!\n"); + printf("Could not save screenshot to file %s!\n", filename); } fclose(f); } else { - printf("Could not open screenshot.tiff for writing: %s\n", strerror(errno)); + printf("Could not open %s for writing: %s\n", filename, strerror(errno)); } } else { printf("Could not get screenshot!\n"); @@ -102,8 +106,9 @@ void print_usage(int argc, char **argv) name = strrchr(argv[0], '/'); printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); printf("Gets a screenshot from the connected iPhone/iPod Touch.\n"); - printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); - printf(" the screenshotr service is not available.\n\n"); + printf("The screenshot is saved as a TIFF image in the current directory.\n"); + printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); + printf("the screenshotr service is not available.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); printf(" -h, --help\t\tprints usage information\n"); |