| View previous topic :: View next topic |
| Author |
Message |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Mon Aug 31, 2009 7:01 pm Post subject: using sceIoOpen and sceIoWrite |
|
|
Hello all, right, i know how to check for a file using sceIoOpen simple stuff. But how do write using sceIoWite.
| Quote: | bytes_written = sceIoWrite(fd, data, 100);
|
How would i define, bytes_written. FD would be like sceUID FD right?
and also what about data. the 100 is the size of the file right? |
|
| Back to top |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Mon Aug 31, 2009 8:18 pm Post subject: |
|
|
Is's basicly the same as in the normal libc (stdio.h - fopen/fwrite/fclose)
http://psp.jim.sh/pspsdk-doc/group__FileIO.html
And use better english? _________________
| Code: | int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
} |
|
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Mon Aug 31, 2009 10:19 pm Post subject: |
|
|
sceIoOpen has not the standard form of fopen. But the other two have same parameters, you're right. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Mon Aug 31, 2009 11:09 pm Post subject: |
|
|
well i have this
SceUID test;
test = sceIoOpen("ms0:/test.txt", O_WRONLY|O_CREAT, 0777);
that will open test.txt for writing and will create the file if it dont exist.
now what do i do with sceIowrite?
im trying copy the contents ./test.txt to ms0:/test.txt |
|
| Back to top |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Tue Sep 01, 2009 12:08 am Post subject: |
|
|
main.c:
| Code: | #include <malloc.h>
#include <pspkernel.h>
#include <pspdebug.h>
PSP_MODULE_INFO("test", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(1024 * 2);
int main() {
SceUID filein, fileout;
char* pBuf=0;
int mSize=0;
pspDebugScreenInit();
pspDebugScreenPrintf("Opening test.txt and read the content.\n");
//Open test.txt for reading.
filein = sceIoOpen("test.txt", PSP_O_RDONLY | PSP_O_CREAT, 0777);
//Check if the file is opened correctly.
if (filein) {
//Get filesize and set cursor back to the beginning of the file.
mSize = sceIoLseek(filein, 0, PSP_SEEK_END);
sceIoLseek(filein, 0, PSP_SEEK_SET);
//Allocate enough memory to store the file.
pBuf = (char*) malloc(mSize);
sceIoRead(filein, pBuf, mSize);
//Close the file.
sceIoClose(filein);
}
else{
pspDebugScreenPrintf("Opening test.txt failed: %i\n",filein);
}
//Open ms0:/test.txt for writing.
fileout = sceIoOpen("ms0:/test.txt", PSP_O_WRONLY | PSP_O_CREAT, 0777);
//Write pBuf to the new file/
sceIoWrite(fileout, pBuf, mSize);
//Close the file.
sceIoClose(fileout);
pspDebugScreenPrintf("ms0:/test.txt has been written.\nSize: %i\n",mSize);
//Timeout before app shuts down.
sceKernelDelayThread(5000000);
sceKernelExitGame();
} |
_________________
| Code: | int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
} |
|
|
| Back to top |
|
 |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Tue Sep 01, 2009 1:56 am Post subject: |
|
|
| Thanks alot, i get it now :) |
|
| Back to top |
|
 |
Ameen

Joined: 14 Jun 2009 Posts: 12 Location: Bahrain
|
Posted: Tue Sep 01, 2009 11:27 am Post subject: |
|
|
| Wow, that was more than sufficient! |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Thu Sep 03, 2009 2:10 am Post subject: |
|
|
Wow, wonderful standard file handling. Awesome! >_> _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
|