What's the difference in these file attributes? The code I was originally using in PS2Menu-K worked fine using FIO_S_, but when I copied it over to my new project, I had to change them to FIO_SO_ to get the file attributes from the MC correctly. I'm also having a weird situation when copying a file from MC to HD, it reads only 0s with the fioRead command. For example: fioRead(mc_file, buffer, fsize) gives me fsize 0s when I fileXioWrite(hd_file, buffer, fsize) and I did a printf("%d", buffer[0]) and it printed 0 when it should be 66 so the problem must be in the read.
More info (after more testing):
the fioRead is returning 0. I'm guessing that means 0 bytes read. I filled the buffer with a dummy string before the read and it remained as the dummy string afterwards so I guessing that's the case. It's opened as O_RDONLY so I don't see why it shouldn't be reading.
Difference betweein FIO_S_ and FIO_SO_
people might correct me if I'm wrong, but, FIO_SO_* attributes are for IOMAN only. The FIO_S_* attributes should be used when working with IOMANX.
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.
I'm using IOMANX. Maybe it's the other way around. All the core modules are the same as the ones used in ps2menu. But in the copy function, when I do an attribute check (to see if it's a directory or file for recursive copy) files come back as 0x17 and directories as 0x27 which is the SO values.
The weird thing is I have code to read from the MC (reads the icon.sys files) and that works fine but the code for reading for the copying doesn't.
The weird thing is I have code to read from the MC (reads the icon.sys files) and that works fine but the code for reading for the copying doesn't.
The problem seems to be in my CopyFile function since the FileRead and FileWrite functions work fine (FileRead and FileWrite are part of a set of functions that allow for transparent file handling so you don't have to know whether you nead fileXio or fio commands). Anyone see anything wrong with this copy routine?
Code: Select all
int CopyFile(u8* infile, u8* outfile, int attr)
{
FILE_HANDLE in, out;
u8* buffer;
in=FileOpen(infile, O_RDONLY);
out=FileOpen(outfile, O_CREAT|O_WRONLY);
int bytesread;
if ((in.id<0) || (out.id<0))
{
printf("Error opening file\n");
}
int fsize=FileLseek(&in, 0, SEEK_END);
int csize;
printf("Copying %d bytes from %s to %s.\n", fsize, infile, outfile);
buffer=malloc(fsize);
sprintf(buffer,"testing\0");
csize=fsize;
if (buffer==NULL)
{
printf("File too big. Copying in 32K chunks\n");
buffer=malloc(32768);
csize=32768;
if (buffer==NULL)
{
printf("Unable to allocate 32K.\n");
FileClose(&in);FileClose(&out);return(0);
}
}
while (csize<=fsize)
{
bytesread=FileRead(&in, buffer, csize);
printf("%d bytes read\n",bytesread);
//printf("%s\n",buffer);
printf("%d bytes written\n",FileWrite(&out, buffer, bytesread));
fsize-=csize;
}
if (fsize>0)
{
FileRead(&in, buffer, fsize);
FileWrite(&out, buffer, fsize);
}
free(buffer);
FileClose(&in);
FileClose(&out);
return 1;
}
Maybe you just found out some bug in the ps2sdk. I'll try to look a bit into that problem.
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.