Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 04, 2012, 10:02:55 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Welcome to PSP-Programming.com
Home Help Search Shop Login Register
Digg This!
Poll
Question: Was this helpful?  (Voting closed: May 07, 2006, 07:31:42 AM)
Yes - 21 (91.3%)
No - 2 (8.7%)
Total Voters: 23

Pages: 1 [2]
Print
Author Topic: PSP File I/O Functions  (Read 21392 times)
tommydanger
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 45
1090.20 points

View Inventory
Send Money to tommydanger

View Profile
« Reply #15 on: May 07, 2006, 01:03:07 PM »

Quote from: "nathan42100"
I'm pretty sure you could also used the default C File I/O functions. I changed the title to specify that it is file i/o, not gamepad i/o.

are you sure?
that would be pretty sweet, cause i'm a lot more familiar with these, and int sceIoRead(SceUID fd, void *data, SceSize size); cannot be used to read line by line, it ignores the CR
well I think I have to write my one function
Logged


Mianvro
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 21
0.00 points

View Inventory
Send Money to Mianvro


View Profile WWW
« Reply #16 on: May 07, 2006, 01:15:00 PM »

Maybe you could try and see whether he is right or wrong Smile

The standard printf for example doesn't work on the PSP.



Btw, I think you should add a note to the TS with the header to include in order to be able to use this function.
Saves a handful of questions about them.

Code:
#include "pspiofilemgr.h"
Logged

Watch me!
Feldor
Newbie
*

Karma: +1/-0
Offline Offline

Posts: 47
0.00 points

View Inventory
Send Money to Feldor


View Profile
« Reply #17 on: May 07, 2006, 07:59:07 PM »

Quote from: "tommydanger"

nathan42100 wrote:
I'm pretty sure you could also used the default C File I/O functions. I changed the title to specify that it is file i/o, not gamepad i/o.

are you sure?
that would be pretty sweet, cause i'm a lot more familiar with these, and int sceIoRead(SceUID fd, void *data, SceSize size); cannot be used to read line by line, it ignores the CR
well I think I have to write my one function


Well you could alwasy make a new function that reads the line.. its not THAT hard to do so..

Quote from: "Mianvro"

Maybe you could try and see whether he is right or wrong Smile

The standard printf for example doesn't work on the PSP.



Btw, I think you should add a note to the TS with the header to include in order to be able to use this function.
Saves a handful of questions about them.

Code:
#include "pspiofilemgr.h"


Haha, good point, Ill add it.
Logged


All my work is licensed under the Creative Commons (CC) License.
tommydanger
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 45
1090.20 points

View Inventory
Send Money to tommydanger

View Profile
« Reply #18 on: May 08, 2006, 01:06:04 AM »

ok so here is the function:
Code:

//read a txt line
int psp_fgets(char *s,int size, SceUID *fd)
{
  int bytesread=0;
  int offset=0;
  int i=0;
  int bufferlen=0;
 
  bytesread = sceIoRead(fd, s, size);//Get the txt data
  if(!bytesread)
  return -1;
 
  bufferlen=strlen(s);
  for(i=0;i<bufferlen;i++)
  {
    if(s[i]=13)//Check if it's a CR, if so skip the rest by adding a null terminating char
    {
      s[i] = 0x00;
      break;
    }
  }
 
  offset = bytesread-i;
  sceIoLseek(fd, -offset, SEEK_CUR);//Set the filepointer to the start of the new line
  return 1;
}


cannot test it right now, cause i'm not at home right now, but should work
Logged
jsharrad
Developer
Global Moderator
Hero Member
*

Karma: +44/-1
Offline Offline

Posts: 613
1170.44 points

View Inventory
Send Money to jsharrad

Yarr!


View Profile WWW
« Reply #19 on: May 10, 2006, 02:57:57 AM »

anyone know if there's any advantage to using these functions over fread/fwrite?
Logged

MinerPSP Coder
MinerPSP Website
nathan42100
Give miinaturvat Points!
Administrator
Hero Member
*

Karma: +32/-2
Offline Offline

Posts: 1161
934.18 points

View Inventory
Send Money to nathan42100


View Profile WWW
« Reply #20 on: May 10, 2006, 03:48:58 AM »

Quote from: "jsharrad"
anyone know if there's any advantage to using these functions over fread/fwrite?
It has psp somewere in the function Very Happy
Logged

All of my work is released under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
dn ʎɐʍ sıɥʇ
Help support my computer projects!

Feldor
Newbie
*

Karma: +1/-0
Offline Offline

Posts: 47
0.00 points

View Inventory
Send Money to Feldor


View Profile
« Reply #21 on: May 11, 2006, 05:53:40 AM »

Using these commands is better only because its made by the pspsdk so its not going to do something that the psp wont like, using the fread/fwrite is geared towards c in general and isnt specific only on PSP

ITs really up to you.
Logged


All my work is licensed under the Creative Commons (CC) License.
corpdecker
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1
0.00 points

View Inventory
Send Money to corpdecker

View Profile
« Reply #22 on: August 03, 2006, 05:51:40 AM »

Regarding the "mode" tests.. if you are saving to a file on ms0, it will ignore the mode because it's a FAT32 filesystem.. which if I recall correctly can't remember or handle ownership or file modes like ext2/ext3/reiserfs/ntfs, etc.
Not sure about flash0/1 ?
Logged
Waterbottle
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 34
16.37 points

View Inventory
Send Money to Waterbottle

View Profile
« Reply #23 on: October 17, 2006, 10:47:33 AM »

Whenever I'm using SceIoWrite/SceIoRead it seems like it has a sceKernelDelayThread() (or something) running regulary, becouse basically I'm having a prx and running it together with a game and the game runs at normal speed while it's writing/reading.

How could I disable this so the game gets completly frozen until the writing/reading is done?
Logged

Waterbottle
&#1057;&#1059;&am
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 97
0.00 points

View Inventory
Send Money to &#1057;&#1059;&am

View Profile
« Reply #24 on: October 17, 2006, 11:11:24 AM »

You would need to get the thread ID of the "game" and use something like sceKernelSuspendThread() to put it on hold.
Logged
Waterbottle
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 34
16.37 points

View Inventory
Send Money to Waterbottle

View Profile
« Reply #25 on: October 17, 2006, 12:39:12 PM »

Any tips on how to find the game's thread ID? the game is an umd ran with devhook if it matters..
Logged

Waterbottle
&#1057;&#1059;&am
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 97
0.00 points

View Inventory
Send Money to &#1057;&#1059;&am

View Profile
« Reply #26 on: October 18, 2006, 12:16:27 AM »

I'd imagine you'd use sceKernelGetThreadmanIdList() with SCE_KERNEL_TMID_Thread  as the type to enumerate system threads.  Then step through the results using sceKernelReferThreadStatus() until you find the one you want by name or some other identifier.
Logged
macthefork
Newbie
*

Karma: +5/-0
Offline Offline

Posts: 22
721.82 points

View Inventory
Send Money to macthefork

View Profile
« Reply #27 on: October 20, 2006, 01:24:02 PM »

mode isn't completly useless, for example if you set it to 0 then you cannot create new files on the memory stick. Of course if you use psplink on a linux system then the mode actually matters and will be reflected on the host files you create which in part is probably why it is there as the basic official kit runs on cygwin or linux machines.

Oh and printf does work, you just need something which actually handles the resulting output *cough* psplink *cough* Wink
Logged
Pages: 1 [2]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.392 seconds with 38 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com