Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to read some bytes and write them into separate directory.

Author
Message
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 2nd Dec 2003 15:52
Hello, I created app in C++ that takes all media files and put them into one big file. Now I need in DBP read part of this file and write it into separate file. I found that I can read from file only 1 byte. So now I read 1 byte and write 1 byte and so on, but it is soo slow.
Is it possibile read more bytes at once into memory? I tought that I use read to memblock but it works only if I have writen memblock in file. I'd like make some array in memory and read for example 65000 bytes at once and then write them at once into file.
Can someone help me please?

--------
Beavis
http://www.progress-studio.com
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Dec 2003 15:59
read byte, word, long, dword, string
check the help file, it'll list all the types you can read in.
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 2nd Dec 2003 16:05
Ehh, I readed help file, but there is no solution if you need read some block of data from file. In other languages is normal that I make some array in memory and then I read block of bytes into this array.

--------
Beavis
http://www.progress-studio.com
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Dec 2003 16:15
You can use memblocks to do what you are trying to do.

Load the entire file into a memblock (MAKE MEMBLOCK FROM FILE), copy the data that you require into another memblock (COPY MEMORY for speed), then save the new memblock to a file (MAKE FILE FROM MEMBLOCK).

Let me know how you get on
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 2nd Dec 2003 16:51
That is no solution if I have 200 MB bigfile
I have one big file and one small file with info of :
filename
start offset in bigfile
size in bytes of file

I read small file into array in memory and when i want load some media, I scan array for exact filename and then I need seek in bigfile and read "size in bytes of file" bytes into memory.


For information :
In C++ compilation of files into BigFile is very fast if I use 65kB memory blocks. Compilation of 40 MB media files take 4 seconds.

if I use byte per byte read/write system in DBP its too slow to extract one file.

--------
Beavis
http://www.progress-studio.com
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd Dec 2003 17:09
So, why not create a 64K memblock, and read up to 64K of data into this memblock ? If its more than 64K, continue reading until the file has been finished.


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 2nd Dec 2003 17:14 Edited at: 2nd Dec 2003 17:16
You can not do what you want in DB.
You can flow data to/from memblocks, strings, words, bytes, floats and arrays.

The closest construct that you have are arrays or character strings. You'll need to rewrite your C++ app to use 64KB strings (if DBP allows that) and read those into DB.

The more you see, the more you know.
The more you know, the more you see.
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 2nd Dec 2003 17:32
Quote: "So, why not create a 64K memblock, and read up to 64K of data into this memblock ? If its more than 64K, continue reading until the file has been finished.
"


You cant read from file into memblock if file isn't created from write memblock command.

Quote: "The closest construct that you have are arrays or character strings. You'll need to rewrite your C++ app to use 64KB strings (if DBP allows that) and read those into DB."

I don't know how long strings DBP supports and I think that this solution isn't clear.

--------
Beavis
http://www.progress-studio.com
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Dec 2003 17:55
Ah, you didn't say that they were that big

It sounds like you need a either plug-in or to access the file I/O functions in kernel32.dll
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd Dec 2003 18:36
I should be able to get a plug-in done later on...


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd Dec 2003 20:42 Edited at: 2nd Dec 2003 20:47
Okay, I've got open/closing/writing a text string and block reading up and running now.
I should be able to put a beta of it soon, on my web site.


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
Jaze
22
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 2nd Dec 2003 21:31
Why go through all that - IF you Really WANT everything in one file - why not zip it - and then unzip what you want to a temp file using WinZip's Command Line Utility - You can pass it a bunch of command line stuff to run "quiet" and you can thwart some people by calling your Zip MyZipFile.NotAZipFile hehe

Good Luck. That sound like Overhead Your Adding. One more thing that can break perhaps.

WinZip Extract (and I'm sure others) is very fast at ripping out files (Assuming you don't want a 2k file at the end of a 1 gig zip file of media of course)

Jason

-=/Jaze/=-
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd Dec 2003 21:40
He wants to be able to read blocks of data in...


Mirrors are more fun than television. Well, that was fun, in a not-so-fun sort of way...
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 3rd Dec 2003 08:50
In my previous projects I used rar archives. For small files is all ok, but now I work on project where are many media files and ZIP/UNZIP is not solution. Look on profi games, many of them protects their media in one big file.

The Coding Area > I look on your plugin and tell you if it is what I need.

--------
Beavis
http://www.progress-studio.com

Login to post a reply

Server time is: 2026-07-27 18:40:32
Your offset time is: 2026-07-27 18:40:32