English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 23 December 2010, 20:48   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 774
removing xpk headers?

Does anyone have a tool for removing the xpk headers off packed data files? I baiscally need to remove the first $10 bytes off a mass load of files. I was thinking i could load each one up into hrtmon, but that does seem like a massive ball ache.

Any ideas?
h0ffman is offline  
Old 23 December 2010, 21:20   #2
jmmijo
Junior Member
 
jmmijo's Avatar
 
Join Date: Jan 2002
Location: PDX
Age: 62
Posts: 2,396
I thought that these were produced by a file compression utility named XPK.

If I remember correctly you can uncompress said files as well using the same tools.

Here is a Google search on more for XPK on the Amiga

http://www.google.com/search?num=100...=&oq=&gs_rfai=

Last edited by jmmijo; 23 December 2010 at 21:23. Reason: More Info
jmmijo is offline  
Old 23 December 2010, 22:04   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
First idea: just develop in a modern OS and write some Python code to fix the files. AmigaOS is just so inefficient to develop in.

but in case you're using a real Amiga, this will work:

trim file1.bin file2 file3 etc.

It overwrites the existing file so make sure to do copies. If it prints a filename then there was an error.

EDIT: I've attached a compiled AmigaOS exe for you.

Code:
#include <stdio.h>
#include <stdlib.h>


int main(int nargs, char** pargs)
{
  FILE* file;
  void* buf;
  int size;

  while(--nargs)
  {
    file = fopen(pargs[nargs], "rb");

    if(file == NULL)
    {
      printf("%s\n", pargs[nargs]);
      continue;
    }

    fseek(file, 0, SEEK_END);
    size = ftell(file)-16;
    fseek(file, 16, SEEK_SET);
    buf = malloc(size);

    if(buf == NULL)
    {
      printf("%s\n", pargs[nargs]);
      fclose(file);
      continue;
    }

    fread(buf, size, 1, file);
    fclose(file);
    file = fopen(pargs[nargs], "wb");

    if(file == NULL)
    {
      printf("%s\n", pargs[nargs]);
      free(buf);
      continue;
    }

    fwrite(buf, size, 1, file);
    fclose(file);
    free(buf);
  }

  return 0;
}
Attached Files
File Type: zip trim.zip (5.9 KB, 150 views)

Last edited by Leffmann; 23 December 2010 at 22:28.
Leffmann is offline  
Old 23 December 2010, 23:00   #4
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 774
Quote:
Originally Posted by Leffmann View Post
First idea: just develop in a modern OS and write some Python code to fix the files. AmigaOS is just so inefficient to develop in.

but in case you're using a real Amiga, this will work:

trim file1.bin file2 file3 etc.

It overwrites the existing file so make sure to do copies. If it prints a filename then there was an error.

EDIT: I've attached a compiled AmigaOS exe for you.

Code:
#include <stdio.h>
#include <stdlib.h>


int main(int nargs, char** pargs)
{
  FILE* file;
  void* buf;
  int size;

  while(--nargs)
  {
    file = fopen(pargs[nargs], "rb");

    if(file == NULL)
    {
      printf("%s\n", pargs[nargs]);
      continue;
    }

    fseek(file, 0, SEEK_END);
    size = ftell(file)-16;
    fseek(file, 16, SEEK_SET);
    buf = malloc(size);

    if(buf == NULL)
    {
      printf("%s\n", pargs[nargs]);
      fclose(file);
      continue;
    }

    fread(buf, size, 1, file);
    fclose(file);
    file = fopen(pargs[nargs], "wb");

    if(file == NULL)
    {
      printf("%s\n", pargs[nargs]);
      free(buf);
      continue;
    }

    fwrite(buf, size, 1, file);
    fclose(file);
    free(buf);
  }

  return 0;
}
Cheers fella, ur a star
h0ffman is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
A1200 rev1a add clockport headers OverDose support.Hardware 1 04 April 2011 03:24
OS 3.9 Includes headers missing(as installed from NDK3.9) frotzen Coders. General 4 09 July 2007 02:40
EXE headers Asle request.Other 3 29 July 2006 15:11
Please avoid xDMS with files which contain headers andreas project.TOSEC (amiga only) 5 31 March 2006 16:47
XPK decruncher Joe Maroni request.Apps 15 01 May 2005 12:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:11.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10451 seconds with 14 queries