[AD] [ alleg-Patches-1213854 ] add capability to determine length of '#' special packfiles

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


Patches item #1213854, was opened at 2005-06-02 22:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305665&aid=1213854&group_id=5665

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: lsantil (lsantil)
Assigned to: Nobody/Anonymous (nobody)
Summary: add capability to determine length of '#' special packfiles

Initial Comment:
--- allegro-cvs-20050528/src/file.c	2005-05-06
20:05:56.000000000 -0700
+++ allegro-cvs-20050528-lsantil/src/file.c	2005-06-02
15:44:18.319386896 -0700
@@ -1406,7 +1406,46 @@
    }
 }
 
+/* get_executable_dat_length:
+ *  If the executable had a packfile appended by
exedat ('#'), it tries to
+ *  deteremine the length of that special packfile.
+ */
+long get_executable_dat_length( void )
+{
+   PACKFILE *f;
+   char exe_name[1024];
+   long size;
+
+   /* open the file */
+   get_executable_name(exe_name, sizeof(exe_name));
+
+   if (!ugetc(get_filename(exe_name))) {
+      *allegro_errno = ENOENT;
+      return -1;
+   }
+
+   f = pack_fopen(exe_name, F_READ);
+   if (!f)
+      return -1;
 
+   ASSERT(f->is_normal_packfile);
+
+   /* seek to the end and check for the magic number */
+   pack_fseek(f, f->normal.todo-8);
+
+   if (pack_mgetl(f) != F_EXE_MAGIC) {
+      pack_fclose(f);
+      *allegro_errno = ENOTDIR;
+      return -1;
+   }
+
+   size = pack_mgetl(f);
+   size -= 8;
+
+   pack_fclose( f );
+
+   return( size );
+}
 
 /* packfile_password:
  *  Sets the password to be used by all future
read/write operations.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305665&aid=1213854&group_id=5665




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