44670 / p7zip-wasm

https://44z.me
GNU Affero General Public License v3.0
115 stars 11 forks source link

wasm #5

Open merco opened 1 day ago

merco commented 1 day ago

Hi . HOw can i compile "wasm-port" with em++ ? I would like to add passowrd extraction support, and build a different 7za.wasm.

Currently I'm using zip whit this simple code:

`

include "CMakeProject1.h"

include

include "zip.h"

using namespace std;

int main() { cout << "Hello CMake." << endl; return 0; }

extern "C" { struct zip_t gloablZip; unsigned char ZipBuf = NULL; size_t ZipBuf_size = 0;

int zipO(const char* zip_file) {
    gloablZip = zip_open(zip_file, 0, 'r');
    return 0;
}

int zipG(const char* zip_file_name, unsigned char* ZipBuf2) {
    int v1=zip_entry_opencasesensitive(gloablZip, zip_file_name);
    //cout << v1 << endl;
    zip_entry_read(gloablZip, (void**)&ZipBuf2, &ZipBuf_size);
    //cout << ZipBuf2 << endl;
        //cout << ZipBuf_size << endl;
        zip_entry_close(gloablZip);
    return 0;
}
uint8_t* zipArr(int n) {
    return ZipBuf;
}
int zipFill(const char* zip_file_name) {
    int v1 = zip_entry_opencasesensitive(gloablZip, zip_file_name);
    //cout << v1 << endl;
    zip_entry_read(gloablZip, (void**)&ZipBuf, &ZipBuf_size);
    // << ZipBuf << endl;
    //cout << ZipBuf_size << endl;
    zip_entry_close(gloablZip);
    return ZipBuf_size;
}

int zipC() {
    zip_close(gloablZip);
    return 0;
}
int unzip_file(const char* zip_file, const char* output_dir) {

    struct zip_t* zip = zip_open(zip_file, 0, 'r');
    int i, n = zip_entries_total(zip);
    for (i = 0; i < n; ++i) {
        zip_entry_openbyindex(zip, i);
        {
            const char* name = zip_entry_name(zip);

            //cout << name << endl;
            int isdir = zip_entry_isdir(zip);
            unsigned long long size = zip_entry_size(zip);
            unsigned int crc32 = zip_entry_crc32(zip);
        }
        zip_entry_close(zip);
    }
    zip_close(zip);
    return 0;
}

double* testdouble_array(double* doubleVector) {

    doubleVector[0] = 1.5f;
    doubleVector[1] = -0.059f;
    doubleVector[2] = 2.99f;
    return doubleVector;

}
int print_file(char* file_path) {

    FILE* file = fopen(file_path, "r");
    if (!file) {
        printf("cannot open file\n");
        return 1;
    }
    while (!feof(file)) {
        char c = fgetc(file);
        if (c != EOF) {
            putchar(c);
        }
    }

    return 0;
}

}`

44670 commented 1 day ago

I have uploaded the cmake file and you may want to compile it with emcmake

https://github.com/44670/p7zip-wasm/commit/017ad27c145d88579e50e7254399b491c60a1617

merco commented 1 day ago

thank you. I get an error here:

immagine