Sign in to follow this  
Yamian

LZMA with SDL

Recommended Posts

Yamian    100
Does anyone know howto or know any links to a way to use LZMA(7-Zip library) with SDL? I would really appreciate it because 7-Zip makes my files tiny compared to the other compression methods out there, and I still need to protect my files from insane user's eyes(muhahaha). PLEASE HELP! If you know it's impossible, please tell me.

Share this post


Link to post
Share on other sites
Kylotan    9978
You can use pretty much any library with SDL. File compression and multimedia are largely independent so the two have little to do with each other. I think you will just have to scrutinise the LZMA docs and experiment.

Share this post


Link to post
Share on other sites
basement    229
look up SDL_RWOps. this is basically some routines for access to in-memory files, so you'd use that after 7-zip decompressing a file into memory.

/* works also with normal files: */
SDL_RWops* rwops = SDL_RWFromFile(filename, "rb");
SDL_Surface* surface = IMG_Load_RW(rwops, 1);

Share this post


Link to post
Share on other sites
Yamian    100
I figured I'd have to use SDL_RWops, just hoping if theer were any specific examples ou there. K, I'll have to disect their samples and configure it to work with RWops, but I don't really know where to start. Should I try to find a same data format between the two? Like SDL_RWFromFP needs a FILE data type, so I should find something that returns a 7z file as a FILE, something like that?

Share this post


Link to post
Share on other sites
Yamian    100
Okay, When looking at the sample for decoding files, I halfway understand it, but I can't find anything in there that involves passwords, which I wish to use for encryption purposes. My Life would be really easy if I just had a

SDL_RWFromLZMA(const char *archieve, const char *file, const char *password, const char *mode)

I'm not trying to leech off anyone to give me that functon, but want help learning how to make one. Please, someone who uses LZMA or wants to learn too and is a better learner. I can't find anything on passwords in there. This seems less documented than other compression libraries, any better suggestions for file encryption/archieving?

[Edited by - Yamian on June 6, 2005 2:08:45 PM]

Share this post


Link to post
Share on other sites
Spudder    385
You would be better of using SDL_RWFromMem(void *buff, int size), you decompress the data into a memory buffer then use this function to create the SDL_RWop*.

Also, do you really need to use LZMA? Have you tried alternatives like bzip2 which has much better compression ratio's than zip files and is dead simple to use in applications for decompressing data.

Share this post


Link to post
Share on other sites
Yamian    100
BZip2 is unencrypted. I'm startin to lean towards making my own encryption, but, I dunno if I'm ready for that. While I wait for some more suggestions(I stilel can't find password stuff for LZMA) then I'll be making my own encrypting program.

Share this post


Link to post
Share on other sites
Yamian    100
I found this( http://gpwiki.org/index.php/C:Custom_Resource_Files ) tutorial on custom resources and I'm adding encryption to it. How can I convert characters to their ascii and hex and all that visa-versa?

Share this post


Link to post
Share on other sites
Yamian    100
okay, now this is my plan. Archieve my files with 7z unencrypted, then custom encrypt it. i just can't figure out how to get a file buffer from a 7z file. Coudl someone help? Now all I need is like a:

char *GetBufferFromSZ(const char *szfilename, const char *resourcename)

and I think LZMA should just have something like that and if they do I'd be embarrassed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this