Browse Source

hard link if possible

David Rose 19 years ago
parent
commit
3339395d5b

+ 3 - 3
pandaapp/src/indexify/indexImage.cxx

@@ -442,7 +442,7 @@ copy_reduced(const Filename &archive_dir) {
   for (pi = _photos.begin(); pi != _photos.end(); ++pi) {
   for (pi = _photos.begin(); pi != _photos.end(); ++pi) {
     const PhotoInfo &pinfo = (*pi);
     const PhotoInfo &pinfo = (*pi);
     int photo_index = pinfo._photo_index;
     int photo_index = pinfo._photo_index;
-    Photo *photo = _dir->get_photo(pinfo._photo_index);
+    Photo *photo = _dir->get_photo(photo_index);
 
 
     // Make sure we have a "reduced" image.
     // Make sure we have a "reduced" image.
     PNMImage reduced_image;
     PNMImage reduced_image;
@@ -655,7 +655,7 @@ generate_reduced_html(ostream &html, Photo *photo, int photo_index, int pi,
     static const streampos MB = 1024 * 1024;
     static const streampos MB = 1024 * 1024;
     static const streampos GB = 1024 * 1024 * 1024;
     static const streampos GB = 1024 * 1024 * 1024;
     string size_units;
     string size_units;
-    double size_float;
+    double size_float = size;
 
 
     if (size > GB) {
     if (size > GB) {
       size_units = "GB";
       size_units = "GB";
@@ -699,7 +699,7 @@ generate_reduced_html(ostream &html, Photo *photo, int photo_index, int pi,
     static const streampos MB = 1024 * 1024;
     static const streampos MB = 1024 * 1024;
     static const streampos GB = 1024 * 1024 * 1024;
     static const streampos GB = 1024 * 1024 * 1024;
     string size_units;
     string size_units;
-    double size_float;
+    double size_float = size;
 
 
     if (size > GB) {
     if (size > GB) {
       size_units = "GB";
       size_units = "GB";

+ 15 - 10
pandaapp/src/indexify/indexParameters.cxx

@@ -19,24 +19,19 @@
 #include "indexParameters.h"
 #include "indexParameters.h"
 
 
 // User parameters
 // User parameters
-int max_index_width = 700;
-int max_index_height = 700;
-
-int thumb_width = 150;
-int thumb_height = 150;
+int max_index_size_array[2] = { 700, 700 };
+int thumb_size_array[2] = { 150, 150 };
 
 
 int thumb_caption_height = 12;
 int thumb_caption_height = 12;
 int caption_font_size = 12;
 int caption_font_size = 12;
 
 
-int thumb_x_space = 12;
-int thumb_y_space = 12;
+int thumb_space_array[2] = { 12, 12 };
 
 
 double frame_reduction_factor = 0.75;
 double frame_reduction_factor = 0.75;
 int frame_outer_bevel = 2;
 int frame_outer_bevel = 2;
 int frame_inner_bevel = 1;
 int frame_inner_bevel = 1;
 
 
-int reduced_width = 800;
-int reduced_height = 700;
+int reduced_size_array[2] = { 800, 700 };
 
 
 Filename archive_dir;
 Filename archive_dir;
 
 
@@ -126,7 +121,7 @@ finalize_parameters() {
     (max_index_width - thumb_x_space) / (thumb_width + thumb_x_space);
     (max_index_width - thumb_x_space) / (thumb_width + thumb_x_space);
   thumb_count_y = 
   thumb_count_y = 
     (max_index_height - thumb_y_space) / (thumb_height + thumb_caption_height + thumb_y_space);
     (max_index_height - thumb_y_space) / (thumb_height + thumb_caption_height + thumb_y_space);
-  
+
   max_thumbs = thumb_count_x * thumb_count_y;
   max_thumbs = thumb_count_x * thumb_count_y;
   
   
   actual_index_width = thumb_x_space + thumb_count_x * (thumb_width + thumb_x_space);
   actual_index_width = thumb_x_space + thumb_count_x * (thumb_width + thumb_x_space);
@@ -272,6 +267,16 @@ copy_file(const Filename &source_file, const Filename &dest_dir) {
     return false;
     return false;
   }
   }
 
 
+#if defined(HAVE_UNISTD_H) && !defined(WIN32)
+  // Try to make a hard link.
+  string os_source_file = source_file.to_os_specific();
+  string os_dest_file = dest_file.to_os_specific();
+  if (link(os_source_file.c_str(), os_dest_file.c_str()) == 0) {
+    cerr << "Linked " << source_file << " to " << dest_file << "\n";
+    return true;
+  }
+#endif
+
   ifstream in;
   ifstream in;
   if (!source_file.open_read(in)) {
   if (!source_file.open_read(in)) {
     cerr << "Unable to read " << source_file << "\n";
     cerr << "Unable to read " << source_file << "\n";

+ 12 - 8
pandaapp/src/indexify/indexParameters.h

@@ -32,13 +32,15 @@
 // fit the images it contains, and it will shrink horizontally to fit
 // fit the images it contains, and it will shrink horizontally to fit
 // a complete row of images (even if it does not contain a complete
 // a complete row of images (even if it does not contain a complete
 // row).  It will never be larger than this.
 // row).  It will never be larger than this.
-extern int max_index_width;
-extern int max_index_height;
+extern int max_index_size_array[2];
+#define max_index_width (max_index_size_array[0])
+#define max_index_height (max_index_size_array[0])
 
 
 // The size of the individual thumbnail images, including the frames
 // The size of the individual thumbnail images, including the frames
 // (if present).  Thumbnail images are scaled to fit within this box.
 // (if present).  Thumbnail images are scaled to fit within this box.
-extern int thumb_width;
-extern int thumb_height;
+extern int thumb_size_array[2];
+#define thumb_width (thumb_size_array[0])
+#define thumb_height (thumb_size_array[1])
 
 
 // The total number of pixels reserved for the caption under each
 // The total number of pixels reserved for the caption under each
 // thumbnail image.  This is the caption_font_size plus whatever
 // thumbnail image.  This is the caption_font_size plus whatever
@@ -53,8 +55,9 @@ extern int caption_font_size;
 
 
 // The amount of space, in pixels, between each two neighboring
 // The amount of space, in pixels, between each two neighboring
 // thumbnail images, and around the overall index image.
 // thumbnail images, and around the overall index image.
-extern int thumb_x_space;
-extern int thumb_y_space;
+extern int thumb_space_array[2];
+#define thumb_x_space (thumb_space_array[0])
+#define thumb_y_space (thumb_space_array[1])
 
 
 // The ratio by which the thumbnail images are reduced further when
 // The ratio by which the thumbnail images are reduced further when
 // frames are drawn, to allow room for a frame that resembles a slide
 // frames are drawn, to allow room for a frame that resembles a slide
@@ -68,8 +71,9 @@ extern int frame_inner_bevel;
 
 
 // The size of the reduced images on the individual image pages.  The
 // The size of the reduced images on the individual image pages.  The
 // source image will be scaled to fit within this rectangle.
 // source image will be scaled to fit within this rectangle.
-extern int reduced_width;
-extern int reduced_height;
+extern int reduced_size_array[2];
+#define reduced_width (reduced_size_array[0])
+#define reduced_height (reduced_size_array[1])
 
 
 // The directory at the root of the output hierarchy (or as specified
 // The directory at the root of the output hierarchy (or as specified
 // by -a on the command line).
 // by -a on the command line).