Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » how to extract all file in *.dat to disk

This thread is locked; no one can reply to it. rss feed Print
how to extract all file in *.dat to disk
stonecold
August 2006

if its possible to extract all file in *.dat to disk
???

LennyLen
Member #5,313
December 2004
avatar

Yes, use the "-e *" option of the dat tool, or use the grabber.

edit: the command will look like this: dat -e yourdat.dat *

stonecold
August 2006

sorry,add that i mean in program

CursedTyrant
Member #7,080
April 2006
avatar

system("dat -e yourdat.dat *")

? :P

I know, there surely is a better way, but it should still work :P

---------
Signature.
----
[My Website] | [My YouTube Channel]

Tobias Dammers
Member #2,604
August 2002
avatar

system("dat -e yourdat.dat *");

But what for?
A datafile is meant to be used like this:
1. Create the datafile with either grabber or dat.
2. Distribute the datafile along with your executable.
3a. In your code, load the datafile and use the resulting DATAFILE* pointer to access the data. load_datafile() produces allegro-useable data structures directly, there's no need to call load_bitmap() or any other loading function on them.
3b. Alternatively, you can treat the datafile as a sort of "magic" folder, and access files by the following filename convention:
yourdat.dat#FOO_BMP
For example, you could do:

BITMAP* my_bmp = load_bitmap("yourdat.dat#FOO_BMP", NULL);

For this to work, you DON'T need to load the entire datafile.

And please (re-)read the manual, section "datafile routines".

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Thomas Fjellstrom
Member #476
June 2000
avatar

Tobias said:

BITMAP* my_bmp = load_bitmap("yourdat.dat#FOO_BMP", NULL);

Or even:

DATAFILE *dat_object = load_datafile_object("your.dat", "foo");
BITMAP *bmp = (BITMAP *)(dat_object->dat);

Which ever.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Kitty Cat
Member #2,815
October 2002
avatar

Quote:

Quote:

BITMAP* my_bmp = load_bitmap("yourdat.dat#FOO_BMP", NULL);

Or even:
DATAFILE *dat_object = load_datafile_object("your.dat", "foo");

The former needs the bitmap stored as a binary chunk. The latter needs to be stored as a bitmap object. Just an FYI.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

stonecold
August 2006

because i use audiere lib to play ogg
and i wanna packed ogg in DAT and use it
but i don't know any good method

Tobias Dammers
Member #2,604
August 2002
avatar

You may be better off using something like alogg, which integrates better with allegro. Otherwise, simply don't put ogg files into a datafile. It won't compress much anyway, and datafiles won't do much to protect your content, so there isn't really a great reason for putting an ogg file into a datafile.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

so there isn't really a great reason for putting an ogg file into a datafile.

... especially since your original question was how to get it out of the data file.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Tobias Dammers
Member #2,604
August 2002
avatar

Yes, that was the original question.
But it makes me wonder how the ogg file got into the datafile in the first place. Either the OP put it there himself, which makes my question very valid; or someone else did, in which case I'd suggest to just use grabber or dat.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Go to: