看上去蛮简单的。包内每个文件开头都有一个16*n个字节的头。接下去是不加密的文件。文件连续排放。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
struct PkHead
{
unsigned short a;
unsigned short namelen;
char b[8];
unsigned long filelen;
char filename[256];
};
void bulidpath(const char *path)
{
char buf[256], *name, *next, buf2[256], cmd[256];
strncpy(buf, path, 255);
name = strtok(buf, "/\\");
sprintf(buf2, ".", name);
while(name)
{
next = strtok(NULL, "/\\");
if (next == NULL)
break;
FILE *fp;
sprintf(cmd, "%s/%s", buf2, name);
fp = fopen(cmd, "rb");
if (fp == NULL)
{
sprintf(cmd, "md %s\\%s", buf2, name);
system(cmd);
}
else fclose(fp);
strcat(buf2, "\\");
strcat(buf2, name);
assert(strlen(buf2) < 255);
name = next;
}
}
int main(int argc, char *argv[])
{
char filename[256];
if (argc != 3)
{
fprintf(stderr, "Usage: luconv ");
return 0;
}
FILE *fp = fopen(argv[1], "rb");
while(!feof(fp))
{
PkHead head;
if (fread(&head.a, sizeof(unsigned short), 1, fp) != 1)
break;
if (head.a < 2)
break;
if (fread(((char*)&head) + sizeof(unsigned short), head.a - sizeof(unsigned short), 1, fp) != 1)
break;
sprintf(filename, "%s/%s", argv[2], head.filename);
bulidpath(filename);
FILE *f = fopen(filename, "wb");
if (f)
{
int size = head.filelen;
while(size--)
{
fputc(fgetc(fp), f);
}
fclose(f);
}
else fseek(fp, head.filelen, SEEK_CUR);
}
fclose(fp);
return 0;
}
#include <string.h>
#include <stdlib.h>
#include <assert.h>
struct PkHead
{
unsigned short a;
unsigned short namelen;
char b[8];
unsigned long filelen;
char filename[256];
};
void bulidpath(const char *path)
{
char buf[256], *name, *next, buf2[256], cmd[256];
strncpy(buf, path, 255);
name = strtok(buf, "/\\");
sprintf(buf2, ".", name);
while(name)
{
next = strtok(NULL, "/\\");
if (next == NULL)
break;
FILE *fp;
sprintf(cmd, "%s/%s", buf2, name);
fp = fopen(cmd, "rb");
if (fp == NULL)
{
sprintf(cmd, "md %s\\%s", buf2, name);
system(cmd);
}
else fclose(fp);
strcat(buf2, "\\");
strcat(buf2, name);
assert(strlen(buf2) < 255);
name = next;
}
}
int main(int argc, char *argv[])
{
char filename[256];
if (argc != 3)
{
fprintf(stderr, "Usage: luconv
return 0;
}
FILE *fp = fopen(argv[1], "rb");
while(!feof(fp))
{
PkHead head;
if (fread(&head.a, sizeof(unsigned short), 1, fp) != 1)
break;
if (head.a < 2)
break;
if (fread(((char*)&head) + sizeof(unsigned short), head.a - sizeof(unsigned short), 1, fp) != 1)
break;
sprintf(filename, "%s/%s", argv[2], head.filename);
bulidpath(filename);
FILE *f = fopen(filename, "wb");
if (f)
{
int size = head.filelen;
while(size--)
{
fputc(fgetc(fp), f);
}
fclose(f);
}
else fseek(fp, head.filelen, SEEK_CUR);
}
fclose(fp);
return 0;
}