OUTSTANDING! I didn't expect you to do it in such a short time.
So, now you have complete understanding of this part of code, right?
Code: [Select]
Code:
struct toc_entry { char name[20]; unsigned int offset; unsigned char unknown1; unsigned short conflict; __attribute__((__packed__)); struct file_header { char name[20]; unsigned int size; } __attribute__((__packed__)); struct lookup_table_entry { unsigned short toc_offset; unsigned short num_files; } __attribute__((__packed__)); struct conflict_entry { char name[128]; unsigned short toc_index; } __attribute__((__packed__));
Especially, you do know what does __attribute__((__packed__)) actually do, right?
Good, now let's start with building classes. At first, I advise you to initially build an application that only extracts files from LGP, then expand it to one that also archives files into LGP. But a precaution: I know C# and Delphi very well but I don't remember anything about VB.NET anymore. But I'm going to assume VB.NET is only grammatically different from C#. (At least for our purpose.) If it isn't, let me know and we'll try to resolve any conflict.
(I don't know why my eyes hurts...)
Start by building a test program that opens LGP archive, counts the number of files in it and announces the count in a message box. Then, you'll expand it into a full-fledged LGP extractor. For now, download
lgp.c,
unlgp.c,
lgp.h and MinGW. (You'll need some of MinGW source codes, such as
stat.h.) Also, start a Visual Basic project (Windows Form) and put a Menu Bar on it with just a File menu and an Open command. Put an Open Dialog Box into the form and set its properties, so it can open "LGP Archive (*.LGP)" and "All files (*.*)".
Create a DeLGP class. (Are classes case-sensitive in VB.NET too? In C#, they are. In Delphi, they aren't.) Class constructor gets one parameter: the whole path to the LGP file. The constructor checks whether the file exists, whether NTFS permissions on it allows read-only access and opens the file as read-only. (Don't implement the opening of the file yet.)
Then, the main job: Build a LGPStream class as a Structured Storage class and add a File Stream plus the structs in LGP.h to it. You are not going to have the benefit of using packed structs, so prepare for extra job when reading and writing structs. There is a reason for that: The precious Unicode! You are going to read non-unicode strings from archive but write Unicode strings to disk, and vice versa. (Aali's LGP Tools read non-unicode and write non-unicode. You don't do this.)
Once you are done, let me see how you've done this critical part. Meanwhile, I'll be downloading a Visual Basic 2008 Express, just in case.