Loading data from 'current directory'

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

Moderators: cheriff, TyRaNiD

Post Reply
Sdw
Posts: 29
Joined: Tue Jul 17, 2007 9:50 am

Loading data from 'current directory'

Post by Sdw »

I'm doing a small demo and I want to load my .mod file (using mikmod).

During development I loaded it from "ms0:/music.mod", that is the root of the memstick. However for a release, I want all my data contained in the same folder as the executable.
So I tested to put the mod-file in the same dir as the EBP (ms0:/PSP/GAME150/mydemo/music.mod) and then loaded it with just "music.mod" as filename. It worked fine for me (using 3.40OE and having my prod in the GAME150 dir).
However, is this the "correct" way to do it (that is, will it work for other firmwares etc.) or is there a situation where the executable will not be able to find it without having a full, absolute path?
Mihawk
Posts: 29
Joined: Tue Apr 03, 2007 2:04 am

Post by Mihawk »

This should work (i.e. just the filename without path). You could also use a sub dir (e.g. "data/file.dat").
One problem I had where it didn't work was in a kernel app where I started a user thread and wanted to load a file in the user thread. Then you need to get the current working directory ("getcwd") in the kernel thread.
Ask and it will be given to you; seek and you will find; knock and the door will be opened to you.
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

Should be fine for executables, but just be aware that it doesn't work for PRXs - although they maintain a record of their current directory, that isn't set to any useful initial value.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Sdw
Posts: 29
Joined: Tue Jul 17, 2007 9:50 am

Post by Sdw »

Alright, looks like I was on the right track then. Thanks for the answers guys!
Post Reply