Guest User

Untitled

a guest
Oct 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdarg.h>
  5.  
  6. #include <pspsdk.h>
  7. #include <pspiofilemgr.h>
  8.  
  9. #include "file.h"
  10.  
  11. PSP_MODULE_INFO("TEST", 0, 1, 0);
  12. PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
  13.  
  14. #define printf pspDebugScreenPrintf
  15.  
  16.  
  17. int Remove(const char *filename)
  18. {
  19. SceIoStat state;
  20. if( sceIoGetstat(filename, &state) < 0 )
  21. return -1;
  22.  
  23. if( state.st_attr & FIO_SO_IFDIR )
  24. return 0;
  25.  
  26. return sceIoRemove(filename);
  27. }
  28.  
  29. int FlashWriteEnable(void)
  30. {
  31. u32 res = sceIoUnassign("flash0:");
  32. if(res<0) return -1;
  33. res = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
  34. if(res<0) return -1;
  35.  
  36. return 0;
  37. }
  38.  
  39.  
  40. int Copy_File(const char *in, const char *out)
  41. {
  42. if( strcmp(in,out) == 0 || in == NULL || out == NULL )
  43. return -1;
  44.  
  45. SceUID fd_out = sceIoOpen( out, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC , 0777 );
  46. if (fd_out < 0){
  47. sceIoClose(fd_out);
  48. return -1;
  49. }
  50. SceUID fd_in = sceIoOpen( in , PSP_O_RDONLY, 0777);
  51. if (fd_in < 0){
  52. sceIoClose(fd_in);
  53. sceIoClose(fd_out);
  54. return -1;
  55. }
  56.  
  57. unsigned char buffer[COPY_BUFFERSIZE];
  58.  
  59. while(1)
  60. {
  61. int read_byte = sceIoRead(fd_in, buffer, COPY_BUFFERSIZE);
  62. if( read_byte < 0 ) {
  63. sceIoClose(fd_in);
  64. sceIoClose(fd_in);
  65. return -1;
  66. } else if(read_byte == 0 ) {
  67. break;
  68. } else if(read_byte == COPY_BUFFERSIZE ) {
  69. sceIoWrite(fd_out, buffer, COPY_BUFFERSIZE );
  70. } else {
  71. sceIoWrite(fd_out, buffer, read_byte);
  72. break;
  73. }
  74. }
  75.  
  76. sceIoClose(fd_out);
  77. sceIoClose(fd_in);
  78. return 0;
  79. }
  80.  
  81.  
  82. int FlashProtect(void)
  83. {
  84. u32 res = sceIoUnassign("flash0:");
  85. if(res<0) return -1;
  86. res = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDONLY, NULL, 0);
  87. if(res<0) return -1;
  88.  
  89. return 0;
  90. }
  91.  
  92. int main(int argc, char *argv[])
  93. {
  94.  
  95. pspDebugScreenInit();
  96.  
  97. sceCtrlSetSamplingCycle(0);
  98. sceDisplayWaitVblankStart();
  99. pspDebugScreenInit();
  100.  
  101. printf(" please wait...\n\n");
  102.  
  103. FlashWriteEnable();
  104. Remove("flash0:/font/ltn0.pgf");
  105.  
  106.  
  107. Copy_File("ms0:/FONT/ltn0.pgf","flash0:/font/ltn0.pgf");
  108.  
  109. FlashProtect();
  110.  
  111. sceKernelExitGame();
  112. return 0;
  113. }
Add Comment
Please, Sign In to add comment