Re: [AD] dat

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


> sorry just notice a small error on my part.. its fixed now.. promise! :)

Thanks.  Looks good.  A few remarks:

@@ -111,6 +112,7 @@
    printf("\t'-v' selects verbose mode\n");
    printf("\t'-w' always updates the entire contents of the datafile\n");
    printf("\t'-007 password' sets the file encryption key\n");
+   printf("\t'-+' recursively add folders as if they are datafiles\n");
    printf("\t'PROP=value' sets object properties\n");
 }

Congratulations!  You just won the worst-option-name award of the month :-)  
I know that the field is a bit crowded, but you'll have to come up with a 
better name (too bad I recently added -r for relative filenames).


@@ -391,8 +393,57 @@
       }
    }
 }
+typedef struct {DATAFILE *parent; DATAFILE *dat;} dataarg_t;
 
Bad type name IMHO.  It should describe the purpose of the type, not how it 
is used.

+dataarg_t* make_folder(dataarg_t *param,char *prop_value_string)
+{
+   DATAFILE *v=NULL;
+   long size = 0;
+   DATAFILE *parent=param->parent;
+   DATAFILE *dat=param->dat;
+   DATAFILE *d;
+   int replace=0;
+   int c;
+   dataarg_t *tmp=malloc(sizeof(dataarg_t));
+   
+   for (c=0; dat[c].type != DAT_END; c++) { // check it already exists and 
it is a datafile

We don't like C++ comments.

+      if (dat[c].type==DAT_FILE&&stricmp(prop_value_string, 
get_datafile_property(dat+c, DAT_NAME)) == 0) {
+         tmp->parent=tmp->dat;
+         tmp->dat= (DATAFILE *)dat[c].dat;
+         return tmp;
+      }
+   }

Since the function can "open" an already existing folder, I'd suggest to 
change its name.


@@ -415,6 +473,30 @@
 	    name[c] = '_';
    }
 
+   if(opt_recurse&&(attrib&FA_DIREC)) { // hunt with in it... 
+
+     printf("Inserting %s -> %s\n", fname, name);
+
+     da=make_folder(param,name);
+
+     if(!da) {
+        fprintf(stderr, "Error: failed to create sub datafile %s.\n",name);
+        err=1;
+	return 1;
+     }
+
+     append_filename(fname, fname, "*", sizeof(fname));
+
+     if (for_each_file_ex(fname, 0, 0, do_add_file, da) <= 0) {
+	fprintf(stderr, "Error: %s not found\n", fname);
+        free(da);
+	err=1;
+	return 1;
+     }

Why don't you pass the same arguments to for_each_file_ex as the master call?


-- 
Eric Botcazou




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