Skip to main content
GameDev.net gamedev.net
🔒 Locked

Exporting From .dat Resource Files?

Started by CDTMD May 20, 2010 at 2:37 PM 3 replies 1.2k views
Original Post
CDTMD
CDTMD
If I were to create a .dat file using this method http://gpwiki.org/index.php/C:Custom_Resource_Files and loaded one up with pictures. Could I create a program that could take one selected picture save it to the desktop and open it? For windows I could use ShellExecute() to open it right? What about for Mac?
GeirGrusom
GeirGrusom
If you write it in cross-platform C++ you can make a program that runs both on Windows, *nix and Mac. You could also use Java, which would make the job somewhat easier.

To get ShellExecute to work with your program, is a registry setting in Windows. in *nix and Mac OS I have no idea how it is done, but it's probably not very complicated.
But I know next to nothing about Unix development, and nothing at all about Mac OS development.
So here's what I do know: Windows uses registry to determine what programs opens what files. The best documentation here is windows registry itself. Open regedit and find HKEY_CLASSES_ROOT. Handlers for all filetypes are registered here, and lots of other stuff for some reason.
ShellExecute() may be called system(), but if you use Java, there are classes that take care of this for you. For C++ there may also be libraries written to make this easier.
CDTMD
CDTMD
Now I know how to open it. But what about saving it in the first place?

From the resource creator tutorial I see this code is most important

Quote:

int fd_read = open(filename, O_RDONLY);
char *buffer = (char *) malloc(filesize);
read(fd_read, buffer, filesize);
write(fd, buffer, filesize);


Could I use the same code to save the file from the resource?
way2lazy2care
way2lazy2care
what do you mean by save?

When you're messing with the file in your code it will be changed and shouldn't really need to "saved" because it is already "saved". kind of.

CDTMD
CDTMD
It will be in the resource file, yes.

But the creation of it and what I am doing are separate. Sort of...

I will use the code in said tutorial to create the resource file.

But then in my program I want the ability to take a file saved in the resource and save it to the desktop, as the original image not part of a resource file.

How would I do that?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.