How would i define, bytes_written. FD would be like sceUID FD right?bytes_written = sceIoWrite(fd, data, 100);
and also what about data. the 100 is the size of the file right?
How would i define, bytes_written. FD would be like sceUID FD right?bytes_written = sceIoWrite(fd, data, 100);
Code: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
Code: Select all
#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: Select all
int main(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}