Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Freakler authored Feb 15, 2017
1 parent e77c7d7 commit 951d3af
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 183 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ TITLE_ID = ADRINSTAL
TARGET = EasyInstaller
OBJS = main.o font.o graphics.o init.o file.o

PSVITAIP = 192.168.0.110
PSVITAIP = 192.168.0.111

RESOURCES_PNG = materials/button_pad.png materials/button_cross.png materials/button_circle.png
OBJS += $(RESOURCES_PNG:.png=.o)

LIBS = -lvita2d -lSceKernel_stub -lScePower_stub -lSceDisplay_stub -lSceGxm_stub -lSceAppUtil_stub -lSceAppMgr_stub \
LIBS = -lvita2d -lScePower_stub -lSceLibKernel_stub -lSceDisplay_stub -lSceGxm_stub -lSceAppUtil_stub -lSceAppMgr_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lScePgf_stub -lSceHttp_stub -lSceNet_stub -lSceNetCtl_stub\
-lSceCommonDialog_stub -lSceVshBridge_stub -lfreetype -lpng -ljpeg -lz -lm -lc
-lSceCommonDialog_stub -lSceVshBridge_stub -lSceShellSvc_stub -lfreetype -lpng -ljpeg -lz -lm -lc

PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
Expand All @@ -25,6 +25,7 @@ all: $(TARGET).vpk
-a livearea/template.xml=sce_sys/livearea/contents/template.xml \
-a livearea/startup.png=sce_sys/livearea/contents/startup.png \
-a livearea/bg0.png=sce_sys/livearea/contents/bg0.png \
-a livearea/changeinfo.xml=sce_sys/changeinfo/changeinfo.xml \
-a files/adrenaline.skprx=files/adrenaline.skprx \
-a files/adrenaline.suprx=files/adrenaline.suprx \
-a files/icon0.dds=files/icon0.dds \
Expand Down
79 changes: 64 additions & 15 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,30 @@ int copyFile(char *src_path, char *dst_path) { //thx Flow VitaShell
return 0;
}

int makePath(const char *dir) { //thx molecule
char dir_copy[0x400] = {0};
snprintf(dir_copy, sizeof(dir_copy) - 2, "%s", dir);
dir_copy[strlen(dir_copy)] = '/';
char *c;

for (c = dir_copy; *c; ++c) {
if (*c == '/') {
*c = '\0';
sceIoMkdir(dir_copy, 0777);
*c = '/';
}
}

//test
SceUID test = sceIoDopen(dir);
if (test >= 0) {
sceIoDclose(test);
return 0; //success
} else {
return 1;
}
}

int removePath(char *path) { //thx Flow VitaShell
SceUID dfd = sceIoDopen(path);
if (dfd >= 0) {
Expand Down Expand Up @@ -224,25 +248,28 @@ int removePath(char *path) { //thx Flow VitaShell


int download_file(const char *src, const char *dst) { //thx molecule offline installer

int ret;
int coord = psvDebugScreenGetX(); //save current position of screen once

int tpl = sceHttpCreateTemplate("henkaku offline", 2, 1);
if (tpl < 0) {
//printf("sceHttpCreateTemplate: 0x%x\n", tpl);
printf("sceHttpCreateTemplate: 0x%x\n", tpl);
return tpl;
}
int conn = sceHttpCreateConnectionWithURL(tpl, src, 0);
if (conn < 0) {
//printf("sceHttpCreateConnectionWithURL: 0x%x\n", conn);
printf("sceHttpCreateConnectionWithURL: 0x%x\n", conn);
return conn;
}
int req = sceHttpCreateRequestWithURL(conn, 0, src, 0);
if (req < 0) {
//printf("sceHttpCreateRequestWithURL: 0x%x\n", req);
printf("sceHttpCreateRequestWithURL: 0x%x\n", req);
return req;
}
ret = sceHttpSendRequest(req, NULL, 0);
if (ret < 0) {
//printf("sceHttpSendRequest: 0x%x\n", ret);
printf("sceHttpSendRequest: 0x%x\n", ret);
return ret;
}
unsigned char buf[4096] = {0};
Expand All @@ -253,37 +280,36 @@ int download_file(const char *src, const char *dst) { //thx molecule offline ins
int fd = sceIoOpen(dst, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 6);
int total_read = 0;
if (fd < 0) {
//printf("sceIoOpen: 0x%x\n", fd);
printf("sceIoOpen: 0x%x\n", fd);
return fd;
}
// draw progress bar background
//fg_color = 0xFF666666;
//draw_rect(psvDebugScreenGetX(), psvDebugScreenGetY(), PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT);
//fg_color = 0xFFFFFFFF;

while (1) {
int read = sceHttpReadData(req, buf, sizeof(buf));

if (read < 0) {
//printf("sceHttpReadData error! 0x%x\n", read);
printf("sceHttpReadData error! 0x%x\n", read);
return read;
}

if (read == 0) break; //done downloading

ret = sceIoWrite(fd, buf, read);
if (ret < 0 || ret != read) {
//printf("sceIoWrite error! 0x%x\n", ret);
printf("sceIoWrite error! 0x%x\n", ret);
if (ret < 0)
return ret;
return -1;
}
total_read += read;
//draw_rect(psvDebugScreenGetX() + 1, psvDebugScreenGetY() + 1, (PROGRESS_BAR_WIDTH - 2) * total_read / length, PROGRESS_BAR_HEIGHT - 2);

psvDebugScreenSetXY( coord, psvDebugScreenGetY() );
printf("(%i bytes) ", total_read);
}
printf("\n\n");

ret = sceIoClose(fd);
//if (ret < 0)
//printf("sceIoClose: 0x%x\n", ret);
if (ret < 0)
printf("sceIoClose: 0x%x\n", ret);

return 0;
}
Expand Down Expand Up @@ -321,6 +347,7 @@ const char *get_id_of_psp_game_that_adrenaline_is_installed_to() { //return PSP
int write_adrenaline_to_config(char *id) {

char buffer[1024];

FILE *file = fopen("ux0:tai/config.txt", "r");
FILE *temp = fopen("ux0:tai/temp.txt", "w");

Expand All @@ -331,6 +358,7 @@ int write_adrenaline_to_config(char *id) {
} else {

while (fgets(buffer, sizeof(buffer), file) != NULL) {

if ( buffer[0] != '\n' ) { //empty row fix
fprintf(temp, "%s", buffer);
}
Expand All @@ -342,6 +370,8 @@ int write_adrenaline_to_config(char *id) {
}
}



//end of file (append the rest)
fprintf(temp, "*%s\n", id);
fprintf(temp, "vs0:sys/external/libpgf.suprx\n");
Expand Down Expand Up @@ -502,3 +532,22 @@ void trigger_rebuild_database() {

sceIoRemove("ur0:shell/db/app.db");
}

int writeChangeinfo(const char* id) { // return 1 on success

char temp_buffer[256];
int ret;

sprintf(temp_buffer, "ux0:patch/%s/sce_sys/changeinfo", id);
ret = makePath(temp_buffer); //0 on success

if ( ret == 0 ) { //if success
sprintf(temp_buffer, "ux0:patch/%s/sce_sys/changeinfo/changeinfo.xml", id);
ret = copyFile("app0:sce_sys/changeinfo/changeinfo.xml", temp_buffer); //0 on success

if ( ret == 0 ) return 1; //success
}

return 0;
}

8 changes: 8 additions & 0 deletions file.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#include <psp2/net/net.h>
#include <psp2/net/netctl.h>

#define printf psvDebugScreenPrintf

#define TRANSFER_SIZE 64 * 1024 //64kb
#define MAX_PATH_LENGTH 1024


char PSP_GAME_ID[32];

struct PSPContent {
Expand All @@ -28,7 +31,10 @@ char *getEbootTitle(char *src_path);

int doesFileExist(const char* path);
int doesDirExist(const char* path);

int copyFile(char *src_path, char *dst_path);

int makePath(const char *dir);
int removePath(char *path);

int download_file(const char *src, const char *dst);
Expand All @@ -40,4 +46,6 @@ int check_for_psp_content(char *path);

void trigger_update_database();
void trigger_rebuild_database();

int writeChangeinfo(const char* id);
#endif
Loading

0 comments on commit 951d3af

Please sign in to comment.