- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 - 70
 - 71
 - 72
 - 73
 - 74
 - 75
 - 76
 - 77
 - 78
 - 79
 - 80
 - 81
 - 82
 - 83
 - 84
 - 85
 - 86
 - 87
 - 88
 - 89
 - 90
 - 91
 - 92
 
                        #include "unpacker.h"
Unpacker::Unpacker(char *name) {
    _splitString = new char*[16];
    _ctx = SDL_RWFromFile(name, "rb");
}
Unpacker::~Unpacker() {
    delete _splitString;
    SDL_RWclose(_ctx);
    SDL_FreeRW(_ctx);
}
Dir *Unpacker::getDir(char *path) {;
    int index = 1;
    char pth[256];
    char name[80];
    char *str = "";
    if (!path)
        return NULL;
    _split(path);
    SDL_RWseek(_ctx, 2, SEEK_SET);
    pth[0] = '/'; pth[1] = '\0';
    while (_splitString[index]) {    
        Uint16 count;
        Uint32 hash;
        str = _splitString[index];
        hash = _hash(str);
        count = SDL_ReadLE16(_ctx);
        for (int i=0; i<count; i++) {
            Uint32 h;
            Uint32 offset;
            h = SDL_ReadLE32(_ctx);
            offset = SDL_ReadLE32(_ctx);
            if (hash == h) {
                Uint8 size;
                Uint32 curPos = SDL_RWtell(_ctx);
                SDL_RWseek(_ctx, offset, SEEK_SET);
                SDL_RWread(_ctx, &size, 1, 1);
                SDL_RWread(_ctx, name, size, 1);
                name[size] = '\0';
                if (!strcmp(str, name)) {
                    if (_splitString[index+1]) {
                         strcat(pth, str);
                         strcat(pth, "/");
                    }
                    break;
                } else {
                    if (i == count-1)
                        return NULL;
                    SDL_RWseek(_ctx, curPos, SEEK_SET);
                }
            }
        }
        index++;
    }
    Dir *dir = new Dir;
    strcpy(dir->name,  str);
    strcpy(dir->path, pth);
    dir->dirsCount = SDL_ReadLE16(_ctx);
    dir->dirsOffset = SDL_RWtell(_ctx);
    SDL_RWseek(_ctx, dir->dirsCount*8, SEEK_CUR);
    dir->filesCount = SDL_ReadLE16(_ctx);;
    dir->filesOffset = SDL_RWtell(_ctx);
    return dir;
}
File *Unpacker::getFile(char *path) {
    char pth[256];
    char nm[80];
    int index = 2;
    _split(path);
    if (!_splitString[1])
        return NULL;
    if (_splitString[2]) {
        strcpy(pth, "/");
        strcpy(pth, _splitString[1]);
        strcat(pth, "/");
    } else {
        Dir *dir = getDir("/");
        return getFile(dir, _splitString[1]);
    }
    while (1) {
        if (_splitString[index+1]) {;
            strcat(pth, _splitString[index]);
            strcat(pth, "/");
        } else {
            strcpy(nm, _splitString[index]);
            break;
        }
        index++;
    }
                                 
        
            Нашел у себя на диске - старое творенье, когда я был мал и глуп... Распаковщик архива на своего формата на основе zlib.
        
        
>>Как и на жабе
Душит она тебя, да?
http://www.manera.su/workdir/photos/1_09FolBW1_01.jpg
с уважением, Ваш кэп
http://i022.radikal.ru/1307/5f/abe3eccd3da4.jpg
...
Нет, я конечно понимаю, что если нихрена не знаешь, то все языки похожи как 2 капли, но все же...
]