Now I have a weird fioRemove issue

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:

Now I have a weird fioRemove issue

Post by KaylaKaze »

Okay, here's my recursive delete function

Code: Select all

int fioRecursiveDelete(u8* folder)
{
	int ret;
	fio_dirent_t dirbuf;
	u8 path[1025];
	int fd, rv;
	printf("fioRecursiveDelete %s\n", folder);
	if &#40;&#40;fd= fioDopen&#40;folder&#41;&#41; < 0&#41; return fd;
	while&#40;&#40;rv=fioDread&#40;fd, &dirbuf&#41;&#41;&#41;
		&#123;
			strcpy&#40;path,folder&#41;;
			strcat&#40;path,"/"&#41;;
			strcat&#40;path,&#40;char *&#41;&dirbuf.name&#41;;
			printf&#40;"File&#58; %s Attr&#58;%04x\n", path, dirbuf.stat.mode&#41;;
			if&#40;dirbuf.stat.mode & FIO_SO_IFREG&#41; &#123;printf&#40;"Deleteing %s\n", path&#41;;ret = fioRemove&#40;path&#41;;&#125;
			else if&#40;&#40;dirbuf.stat.mode & FIO_SO_IFDIR&#41; && &#40;strncmp&#40;&#40;char *&#41;&dirbuf.name,".",1&#41;&#41;&#41;
			&#123;
				if &#40;&#40;ret = fioRecursiveDelete&#40;path&#41; < 0&#41;&#41; goto error1;
				if &#40;&#40;ret = FileRmdir&#40;path&#41;&#41; < 0&#41; goto error1;
				&#125;
			&#125;
		ret = 0;
error1&#58;
		fioDclose&#40;fd&#41;;
		FileRmdir&#40;folder&#41;;
	return ret;
&#125;

And here's some sample output:

Code: Select all

fioRecursiveDelete mc0&#58;/BASLUS-20827MANHUNT
dopen name mc0&#58;/BASLUS-20827MANHUNT 
dopen fd = 2
File&#58; mc0&#58;/BASLUS-20827MANHUNT/. Attr&#58;0027
File&#58; mc0&#58;/BASLUS-20827MANHUNT/.. Attr&#58;0027
File&#58; mc0&#58;/BASLUS-20827MANHUNT/icon.sys Attr&#58;0017
Deleteing mc0&#58;/BASLUS-20827MANHUNT/icon.sys
remove file mc0&#58;/BASLUS-20827MANHUNT/icon.sys 
mkdir name mc0&#58;/BASLUS-20827MANHUNT/icon.sys 
File&#58; mc0&#58;/BASLUS-20827MANHUNT/PS2VIEW.ICO Attr&#58;0017
Deleteing mc0&#58;/BASLUS-20827MANHUNT/PS2VIEW.ICO
remove file mc0&#58;/BASLUS-20827MANHUNT/PS2VIEW.ICO 
mkdir name mc0&#58;/BASLUS-20827MANHUNT/PS2VIEW.ICO 
File&#58; mc0&#58;/BASLUS-20827MANHUNT/BASLUS-20827MANHUNT Attr&#58;0017
Deleteing mc0&#58;/BASLUS-20827MANHUNT/BASLUS-20827MANHUNT
remove file mc0&#58;/BASLUS-20827MANHUNT/BASLUS-20827MANHUNT 
File&#58; mc0&#58;/BASLUS-20827MANHUNT/MANHUNT0.SAV Attr&#58;0017
Deleteing mc0&#58;/BASLUS-20827MANHUNT/MANHUNT0.SAV
remove file mc0&#58;/BASLUS-20827MANHUNT/MANHUNT0.SAV 
mkdir name mc0&#58;/BASLUS-20827MANHUNT/MANHUNT0.SAV 
rmdir name mc0&#58;/BASLUS-20827MANHUNT 
So... why is this thing making directories of the same name as the files it's deleting?

Once I get this basic stuff done, it shouldn't be long before I can release the program. And, once I finish this thing, I can start work on a PS2 HD based game.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

I seem to remember this being a bug in the rom mc drivers. Something along the lines of switch statement that handles what command is being done missing a break at the end of delete, which causes it to go on to mkdir...

Don't quote me on this but I seem to remember this was the case.
Shoot Pixels Not People!
Makeshift Development
KaylaKaze
Posts: 75
Joined: Wed May 05, 2004 3:25 pm
Location: NC, USA
Contact:

Post by KaylaKaze »

Well, I added an Rmdir(path) command after the Remove(path) so it's at least coming out the way it should.
Herben
Posts: 107
Joined: Sun Jan 25, 2004 10:25 am

Post by Herben »

it's a bug in the ROM FILEIO/XFILEIO drivers. the writer of the modules forgot a "break;" at the end of the case for fioRemove in the RPC server switch, so it continues on to the next case, which happens to be mkdir. So your solution of following any removes with a rmdir is the best thing to do to resolve it.
Post Reply