 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Mak0
Joined: 27 Jan 2005 Posts: 36
|
Posted: Mon May 16, 2005 8:18 am Post subject: problem with simple file copy code |
|
|
bascially im trying to write a simple tool to copy TITLE.DB from my memory card to my pc but it seems to crash right after it accesses mc0:/BADATA-SYSTEM/TITLE.DB. im probably making some trivial mistake that hopefully someone more experienced can point out. here's my code:
| Code: | #include <tamtypes.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <fileio.h>
#include <malloc.h>
#include <libmc.h>
#include <string.h>
#include <modload.h>
#define TYPE_XMC
void LoadModules(void);
int main() {
SifInitRpc(0);
LoadModules();
int inF, ouF;
char line[512];
int bytes;
if((inF = fioOpen("mc0:/BADATA-SYSTEM/TITLE.DB", O_RDONLY)) < 0) {
scr_printf("error opening <mc0:/BADATA-SYSTEM/TITLE.DB>!");
exit(-1);
}
if((ouF = fioOpen("host:TITLE.DB", O_WRONLY | O_CREAT)) < 0) {
scr_printf("error writing <host:TITLE.DB>!");
exit(-1);
}
while((bytes = fioRead(inF, line, sizeof(line))) > 0)
fioWrite(ouF, line, bytes);
fioClose(inF);
fioClose(ouF);
SifExitRpc();
SleepThread();
return 0;
}
void LoadModules(void)
{
int ret;
#ifdef TYPE_MC
ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: SIO2MAN");
SleepThread();
}
ret = SifLoadModule("rom0:MCMAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCMAN");
SleepThread();
}
ret = SifLoadModule("rom0:MCSERV", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCSERV");
SleepThread();
}
#else
ret = SifLoadModule("rom0:XSIO2MAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: SIO2MAN");
SleepThread();
}
ret = SifLoadModule("rom0:XMCMAN", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCMAN");
SleepThread();
}
ret = SifLoadModule("rom0:XMCSERV", 0, NULL);
if (ret < 0) {
printf("Failed to load module: MCSERV");
SleepThread();
}
#endif
}
|
|
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Mon May 16, 2005 10:15 am Post subject: |
|
|
Crashing how ? _________________ pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department. |
|
| Back to top |
|
 |
Mak0
Joined: 27 Jan 2005 Posts: 36
|
Posted: Mon May 16, 2005 10:21 am Post subject: |
|
|
It just seems to hang after accessing mc0:/ and no file is created on host:/ even though fioOpen returns 0.
I have no idea as to why. |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Mon May 16, 2005 12:34 pm Post subject: |
|
|
If all you want is a copy of the file, do you really need to write a whole elf just to do that?
Try | Code: | | ps2client copyfrom mc0:/BADATA-SYSTEM/TITLE.DB host:TITLE.DB |
Thats how i get stuff off/on a mc. I'm not at my dev machine right now, but im pretty sure thats right.
PS: you may need a slightly older version of ps2client..i've heard rumours the netfs functions were pulled out recently?? i dunno.
PPS: you have to load ps2netfs.irx from ps2sdk first...
EDIT: Now recent ckeckouts of ps2client also come with a program fsclient that takes this functionality off ps2client _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|