File -> Edit Box Thing

Started by
0 comments, last by zackriggle 21 years, 8 months ago
I have been developing a text editor for my program, and when it saves, it encrypts the data so it can be read by the game (with the option of simple, unencrypted, ASCII output). I can save fine, encrypted or unencrypted, but I have a problem: what good is an editor without the ability to load a file? How can I, using char*''s so that I can easily knock the value back by 14 characters, load an ENTIRE ascii file, get it into a char* or some other easily-changeable data structure, and then write the whole thing out to a multi-line edit control??? Just so everyone knows, the program tells the difference between an encrypted and unencrypted file by this string at the very first line of all encrypted files: "mq_cryptedit_zriggle". Then a newline char, then the actual file. So I need to be able to: 1.) Load the first line of text to check to see if the file is encrypted... 2.) Either way, load the rest of the file (including the first line if the file is not encrypted) into a char* or similar buffer... 3.) If needed, unencrypt the data 4.) Write the stuff to a win32 edit control... Why don''''t we just kill the guys who write annoying, useless warning messages. It''''d make our lives a hell of a lot easier
Advertisement
quote:Original post by zackriggle
1.) Load the first line of text to check to see if the file is encrypted...

do a fopen(), then fgets() to read the first line. note that gets() will put \n into the string, so you may want to remove it right away.
quote:
2.) Either way, load the rest of the file (including the first line if the file is not encrypted) into a char* or similar buffer...

do a fseek() to the end then ftell() to get the file size. allocate a buffer with new or malloc to hold the entire file. you may want to allocate an additional character for the terminating \0. then fseek() to the beginning if the file is unencrypted or to the beginning+sizeof of the indicator string, and read the file into the allocated memory.
quote:
3.) If needed, unencrypt the data

you can now decrypt data from the allocated memory.
quote:
4.) Write the stuff to a win32 edit control...

wm_settext or setwindowtext should work, or take a look at em_replacesel if they don''t.

This topic is closed to new replies.

Advertisement