Re: [AD] Relative paths in the grabber

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Patch attached. I've also added a relative path switch to the dat utility
> (bound to -r) that forces relative filename to be generated.

grabber.c:
@@ -2283,6 +2308,12 @@
    if (file_select_ex(buf, name, ext, sizeof(name), 0, 0)) {
       fix_filename_case(name);
 
+      /* And this is where we convert the path to a relative path if wanted 
*/
+      if (opt_menu[MENU_RELP].flags & D_SELECTED) {
+         make_relative_filename(relpath, data_file, name, FILENAME_LENGTH);
+         strcpy(name, relpath);
+      }
+      
       set_busy_mouse(TRUE);
 
       strcpy(grabber_import_file, name);

dat.c:
@@ -398,8 +400,14 @@
    int c;
    DATAFILE *d;
 
-   strcpy(fname, filename);
+   /* Make filename relative? */
+   if (opt_relp)     /* Yes */
+      make_relative_filename(fname, opt_datafilename, filename, 256);
+   else              /* No */
+      strcpy(fname, filename);
+      
    fix_filename_case(fname);
+   
 
    strcpy(name, get_filename(fname));
 

This approach has a big limitation: since you relativify the filenames you 
pass to the datedit code based on the location of the datafile, the current 
directory must be that of the datafile otherwise the file is not found.

The right approach is to keep manipulating absolute filenames throughout the 
whole code and to convert them to relative only when writing/reading the 
DAT_ORIG property.

-- 
Eric Botcazou




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/