forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Difference betweein FIO_S_ and FIO_SO_

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Nov 08, 2004 4:43 am    Post subject: Difference betweein FIO_S_ and FIO_SO_ Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Nov 08, 2004 5:45 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Nov 08, 2004 3:12 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Mon Nov 08, 2004 7:22 pm    Post subject: Reply with quote

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:
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;   
}
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Mon Nov 08, 2004 7:36 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
pukko



Joined: 17 Jan 2004
Posts: 17

PostPosted: Tue Nov 09, 2004 6:13 am    Post subject: Reply with quote

Quote:
int fsize=FileLseek(&in, 0, SEEK_END);


Think you need to rewind the tape..
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Tue Nov 09, 2004 6:17 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Tue Nov 09, 2004 2:27 pm    Post subject: Reply with quote

Thank you, thank you. I would NEVER have noticed that :-)
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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