Enlightenment CVS committal
Author : gilbertt
Project : misc
Module : camE
Dir : misc/camE
Modified Files:
AUTHORS example.camErc example.camErc.ssh webcam.c
Log Message:
Patch from Birger Nissen <[EMAIL PROTECTED]> to archive shots into dated
subdirectories.
===================================================================
RCS file: /cvsroot/enlightenment/misc/camE/AUTHORS,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- AUTHORS 28 Feb 2002 19:35:44 -0000 1.7
+++ AUTHORS 7 Feb 2003 12:33:06 -0000 1.8
@@ -17,3 +17,6 @@
missen <[EMAIL PROTECTED]>
ftp keepalive
+
+Birger Nissen <[EMAIL PROTECTED]>
+ archive subdirs
===================================================================
RCS file: /cvsroot/enlightenment/misc/camE/example.camErc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- example.camErc 28 Feb 2002 19:35:24 -0000 1.21
+++ example.camErc 7 Feb 2003 12:33:07 -0000 1.22
@@ -80,6 +80,9 @@
infofile = /home/gilbertt/.caminfo
# directory to archive pics in. They are datestamped and saved in here.
archive = /opt/images/webcam
+# archive pics in datestamped subdirs
+# (1 == with subdirs, 0 == without subdirs)
+archive_subdirs = 0
# extension (determines type) of archived images.
archive_ext = jpg
# determines how many shots are taken before a pic is archived
===================================================================
RCS file: /cvsroot/enlightenment/misc/camE/example.camErc.ssh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- example.camErc.ssh 27 Feb 2002 19:23:38 -0000 1.7
+++ example.camErc.ssh 7 Feb 2003 12:33:07 -0000 1.8
@@ -61,6 +61,9 @@
infofile = /home/gilbertt/.caminfo
# directory to archive pics in. They are datestamped and saved in here.
archive = /opt/images/webcam
+# archive pics in datestamped subdirs
+# (1 == with subdirs, 0 == without subdirs)
+archive_subdirs = 0
# extension (determines type) of archived images.
archive_ext = jpg
# jpeg quality (you can save as png etc too, but then quality does squat)
===================================================================
RCS file: /cvsroot/enlightenment/misc/camE/webcam.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -3 -r1.56 -r1.57
--- webcam.c 28 Feb 2002 19:35:24 -0000 1.56
+++ webcam.c 7 Feb 2003 12:33:07 -0000 1.57
@@ -93,6 +93,8 @@
char *ttf_dir = "/usr/X11R6/lib/X11/fonts/TrueType";
char *archive_ext = "jpg";
char *grab_archive = NULL;
+int archive_subdirs = 0; /* default to archive without */
+ /* subdirs */
int archive_shot_every = 1; /* default to archive every shot */
char *archive_thumbnails_dir = NULL;
int archive_thumbnails_create = 0; /* default is not to create archive thumbnails
*/
@@ -636,9 +638,12 @@
void
archive_jpeg(Imlib_Image im)
{
- char buffer[1028];
- char thumbnail_buffer[1028];
+ char buffer[PATH_MAX];
+ char thumbnail_buffer[PATH_MAX];
char date[128];
+ char year[5];
+ char month[3];
+ char day[3];
time_t t;
struct tm *tm;
static int shot_counter = 0;
@@ -650,10 +655,40 @@
&& shot_counter >= archive_shot_every) {
time(&t);
tm = localtime(&t);
- strftime(date, 127, "%Y-%m-%d_%H%M%S", tm);
- snprintf(buffer, sizeof(buffer), "%s/webcam_%s.%s", grab_archive, date,
- archive_ext);
+ if (archive_subdirs) {
+ strftime(date, 128, "%H%M%S", tm);
+ strftime(year, 5, "%Y", tm);
+ strftime(month, 3, "%m", tm);
+ strftime(day, 3, "%d", tm);
+
+ snprintf(buffer, sizeof(buffer), "%s/%s", grab_archive, year);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Create new subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s", grab_archive, year,
+ month);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Created new archive subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s", grab_archive, year,
+ month, day);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Created new archive subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s/%s.%s", grab_archive,
+ year, month, day, date, archive_ext);
+ } else {
+ strftime(date, 127, "%Y-%m-%d_%H%M%S", tm);
+ snprintf(buffer, sizeof(buffer), "%s/webcam_%s.%s", grab_archive, date,
+ archive_ext);
+ }
save_image(im, buffer);
shot_counter = 0;
/*
@@ -663,8 +698,33 @@
*/
if (archive_thumbnails_create && archive_thumbnails_width
&& archive_thumbnails_height) {
- snprintf(thumbnail_buffer, sizeof(buffer), "%s/webcam_%s.%s",
- archive_thumbnails_dir, date, archive_ext);
+ if (archive_subdirs) {
+ snprintf(buffer, sizeof(buffer), "%s/%s", archive_thumbnails_dir, year);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Create new subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s", archive_thumbnails_dir,
+ year, month);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Created new archive subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s",
+ archive_thumbnails_dir, year, month, day);
+ if (access(buffer, F_OK) == -1) {
+ mkdir(buffer, 0777);
+ log("Created new archive subdir %s\n", buffer);
+ }
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s/%s.%s",
+ archive_thumbnails_dir, year, month, day, date, archive_ext);
+ } else {
+ snprintf(thumbnail_buffer, sizeof(buffer), "%s/webcam_%s.%s",
+ archive_thumbnails_dir, date, archive_ext);
+ }
thumbnail_image =
gib_imlib_create_cropped_scaled_image(im, 0, 0,
gib_imlib_image_get_width(im),
@@ -1308,6 +1368,8 @@
scale_height = i;
if (-1 != (i = cfg_get_int("grab", "archive_shot_every")))
archive_shot_every = i;
+ if (-1 != (i = cfg_get_int("grab", "archive_subdirs")))
+ archive_subdirs = i;
if (-1 != (i = cfg_get_int("grab", "archive_thumbnails_create")))
archive_thumbnails_create = i;
if (-1 != (i = cfg_get_int("grab", "archive_thumbnails_width")))
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs