Any sort of EFS-like system?

Hey, I was looking at PALib, which is a library for the DS, and one of the features is an EFS-an embedded filesystem. Basically, it acts like a filesystem, but it's all inside the executable. Is there any sort of library any of you have heard of that's free and open source, and that copies this functionality?
What do you have in mind when you speak of such a library?
The point of EFS is to take a filesystem and store it into the executable itself. By embedding images and data, the entire project is reduced into a single file without losing functionality. It can be accessed similarly to "real" files, and is an external file before being built.
This isn't exactly easy to do. At least not portably.

On Windows, you can use resource files (.rc) to embed files into the executable. You can then access them from the program as arrays.
I've read about ways of doing this for UNIX, but to be honest, I've never gotten it to work.
One way of doing it that works everywhere is to take the file and convert it to a source file. For example:
uchar some_file[]={0x00,0xA0,0x25,/*...*/};
This is pretty cumbersome for even small files, however.

I've seen a program that could actually embed files into itself after compilation. It probably involved some sort of hack which I wouldn't recommend. Possibly something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
char *my_size="<<my size>>:_unset_"; //(The terminator is the most significant byte.)

int main(int argc,char **argv){
	if (my_size_is_unset(*argv)){
		int64_t size=get_my_size(*argv); //(If 64-bit integers aren't available, just use 32-bit.)
		write_my_size(*argv,size);
		return 0;
	}
	int64_t original_size=get_my_size(),
		current_size=get_my_size(*argv);
	if (current_size>original_size){
		//There are embedded files at the end.
	}
}

This method in particular requires that the OS doesn't lock for writing the executable image of a program while the program is running. If it does, the first if can be moved to a separate program.
In order for this to work at all, the executable format must not rely on the size of the executable to work.
Hmm...alright, thanks. I was just wondering.
Could someone link me to a decent tutorial that explains how accessing them like that might work?
Actually, I'd even find an explaination of .rc files in general helpful...why they can't be used in *nix, and how to set the dang thing up to have a custom icon in Windows Explorer.
Topic archived. No new replies allowed.