Help Creating a library for a virtual disk

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Help Creating a library for a virtual disk

Post by coolkehon »

i wanna create a virtual hard drive / database i guess that has a folder struct and holds files and i can access them by folder how would i go about doing this got any suggestions
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

To do so, you will need to load the files from the ram.

Take a look at dosbox, for example.

struct is short for structure. Its use do store data. Im not really sure if you want one for the psp or pc.
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

You can use my library(ATL - http://forums.ps2dev.org/viewtopic.php?t=11390 -) , it does what you want , plus many more.

Here's an example how to pack/stream entries:

__

Code: Select all

void pack() // used by the packer application
{
	//init
	atlInit(ATL_ENABLE_LOGGING|ATL_ENABLE_OPTIMIZED_VFPU_MEMCPY);

	//packing
	atlAddEntryFromExternalSource("data\\hero.tga","data\\hero.tga");
	atlAddEntryFromExternalSource("data\\hero1.tga","data\\hero1.tga");
	atlAddEntryFromExternalSource("data\\hero2.tga","data\\hero2.tga");

	//creating the package
	atlSaveMemoryToFile("memory.bin");

	//cya
	atlShutdown();
}
Loading whole package:

Code: Select all

	atlLoadMemoryFromFile("memory.bin");
Or loading(streaming) specific entry:

Code: Select all

	atlLoadSpecificEntryFromMemoryFile("memory.bin","data\\hero.tga");
Usage:

Code: Select all

	ATL_NODE* node = atlFindEntry("data\\hero.tga");

	SomeImage* img = someFunctionThatTakesAsParamABuffer(node->type,node->type_size);
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Nice library.
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

so can this pull one data from the .bin file instead of all because i dont want to load all of the data just what i need to conserve memory i saw the function but that is what it does right

edit:
what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

so can this pull one data from the .bin file instead of all because i dont want to load all of the data just what i need to conserve memory i saw the function but that is what it does right
Yes,it is possible...
See my previous post(@ "loading(streaming) specific entry").
edit:
what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files
I don't quite get your question , but , if you're asking if its possible
to modify a package , then the answer is "YES".

You can replace/add/delete an entry & then rebuild the package...
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

He asking will a large size overload the memory.

It really shouldnt, but it might go slow when reading the data.

My library that packs, and unpack read as :

header
custom hash/checksum
size[of each file]
blocks of data[of each file]
total size
encrypted sha1 hash

The total size that can be hold is 512 mb. It reads at a 512kbps(on psp slim) and can hold 500 files or more

Now, PosX has a much better lib. Nice job again.
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

what if i want to add some data or modify data without accessing pulling / opening the entire memory.bin to memory will that work like if i want to add

dummy.bin (5000kb) + dummy2.bin(10000kb) + dummy3.bin (25mb) that will overload the memory so does it load all of them to memory then write or stream it to memory from the existing files
No , currently there is no way to pack a new file(in existing package) without loading the whole package(i might add this feature soon though).

Anyway , if you want to stream a specific entry , just use this :

Code: Select all

atlLoadSpecificEntryFromMemoryFile( package source  , entry name )
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package
PosX100
Posts: 98
Joined: Wed Aug 15, 2007 1:02 am

Post by PosX100 »

coolkehon wrote:cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package
cool thanks for the update now one more thing can i also remove entries from an existing package and add just a variable / void * data to package
No , you can not remove an entry without re-compiling the whole package(or , loading it back in memory,remove/replace an entry , then rebuild the package) ,
because it requires full-rebuilding of the entire
package structure :).

Just create more than 1 package for everything that you really need.

Eg :

For SFX , create a package named "sfx.bin" , For gfx , "gfx.bin" ,or
create "session" packages , eg :"gameplay_lvl0_p0_.bin" and load only what
you really need.

Now , you're asking how to import a native packed type
into an existing package , well , yes , it is possible(a hack-ish way):

Code: Select all


add entry   nat_type
extract entry @nat_type , some_filename.some_ext
import source some_filename.some_ext, some_package.some_ext
remove extracted file some_filename.some_ext
or (non-"Hack"-ish way) if the package is small in size:

Code: Select all


load memory
modify entries
save memory
.

In some later release , i might add full entry streaming support(using a pre-compiled static stream table).
Post Reply