Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
- #include <pspsdk.h>
- #include <pspiofilemgr.h>
- #include "file.h"
- PSP_MODULE_INFO("TEST", 0, 1, 0);
- PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
- #define printf pspDebugScreenPrintf
- int Remove(const char *filename)
- {
- SceIoStat state;
- if( sceIoGetstat(filename, &state) < 0 )
- return -1;
- if( state.st_attr & FIO_SO_IFDIR )
- return 0;
- return sceIoRemove(filename);
- }
- int FlashWriteEnable(void)
- {
- u32 res = sceIoUnassign("flash0:");
- if(res<0) return -1;
- res = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
- if(res<0) return -1;
- return 0;
- }
- int Copy_File(const char *in, const char *out)
- {
- if( strcmp(in,out) == 0 || in == NULL || out == NULL )
- return -1;
- SceUID fd_out = sceIoOpen( out, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC , 0777 );
- if (fd_out < 0){
- sceIoClose(fd_out);
- return -1;
- }
- SceUID fd_in = sceIoOpen( in , PSP_O_RDONLY, 0777);
- if (fd_in < 0){
- sceIoClose(fd_in);
- sceIoClose(fd_out);
- return -1;
- }
- unsigned char buffer[COPY_BUFFERSIZE];
- while(1)
- {
- int read_byte = sceIoRead(fd_in, buffer, COPY_BUFFERSIZE);
- if( read_byte < 0 ) {
- sceIoClose(fd_in);
- sceIoClose(fd_in);
- return -1;
- } else if(read_byte == 0 ) {
- break;
- } else if(read_byte == COPY_BUFFERSIZE ) {
- sceIoWrite(fd_out, buffer, COPY_BUFFERSIZE );
- } else {
- sceIoWrite(fd_out, buffer, read_byte);
- break;
- }
- }
- sceIoClose(fd_out);
- sceIoClose(fd_in);
- return 0;
- }
- int FlashProtect(void)
- {
- u32 res = sceIoUnassign("flash0:");
- if(res<0) return -1;
- res = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDONLY, NULL, 0);
- if(res<0) return -1;
- return 0;
- }
- int main(int argc, char *argv[])
- {
- pspDebugScreenInit();
- sceCtrlSetSamplingCycle(0);
- sceDisplayWaitVblankStart();
- pspDebugScreenInit();
- printf(" please wait...\n\n");
- FlashWriteEnable();
- Remove("flash0:/font/ltn0.pgf");
- Copy_File("ms0:/FONT/ltn0.pgf","flash0:/font/ltn0.pgf");
- FlashProtect();
- sceKernelExitGame();
- return 0;
- }
Add Comment
Please, Sign In to add comment