Difference betweein FIO_S_ and FIO_SO_

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Difference betweein FIO_S_ and FIO_SO_

Post by KaylaKaze »

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.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

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.
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Post by KaylaKaze »

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.
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Post by KaylaKaze »

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 &#40;&#40;in.id<0&#41; || &#40;out.id<0&#41;&#41;
	&#123;
		printf&#40;"Error opening file\n"&#41;;
	&#125;
	int fsize=FileLseek&#40;&in, 0, SEEK_END&#41;;
	int csize;
	printf&#40;"Copying %d bytes from %s to %s.\n", fsize, infile, outfile&#41;;
	buffer=malloc&#40;fsize&#41;;
	sprintf&#40;buffer,"testing\0"&#41;;
	csize=fsize;
	if &#40;buffer==NULL&#41;
		&#123;
			printf&#40;"File too big. Copying in 32K chunks\n"&#41;;
			buffer=malloc&#40;32768&#41;;
			csize=32768;
			if &#40;buffer==NULL&#41;
				&#123;
					printf&#40;"Unable to allocate 32K.\n"&#41;;
					FileClose&#40;&in&#41;;FileClose&#40;&out&#41;;return&#40;0&#41;;
				&#125;
		&#125;
	while &#40;csize<=fsize&#41;
	&#123;
		bytesread=FileRead&#40;&in, buffer, csize&#41;;
		printf&#40;"%d bytes read\n",bytesread&#41;;
		//printf&#40;"%s\n",buffer&#41;;
		printf&#40;"%d bytes written\n",FileWrite&#40;&out, buffer, bytesread&#41;&#41;;
		fsize-=csize;
	&#125;
	
	if &#40;fsize>0&#41;
	&#123;
		FileRead&#40;&in, buffer, fsize&#41;;
		FileWrite&#40;&out, buffer, fsize&#41;;
	&#125;
	free&#40;buffer&#41;;
	FileClose&#40;&in&#41;;
	FileClose&#40;&out&#41;;
	
	return 1;	
&#125;
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

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.
pukko
Posts: 17
Joined: Sat Jan 17, 2004 10:13 pm

Post by pukko »

int fsize=FileLseek(&in, 0, SEEK_END);
Think you need to rewind the tape..
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Mh, right :)
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.
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Post by KaylaKaze »

Thank you, thank you. I would NEVER have noticed that :-)
Post Reply