mirror of
https://github.com/KarnerF/SMPlusGui.git
synced 2026-10-17 11:00:51 +02:00
Pre-cache all icons from /user/appmeta/ when gamelist is generated
This commit is contained in:
1 parent
871fac5bf4
commit
81077b64d3
1 file changed
+16
@@ -2929,6 +2929,22 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
for(int i=0;i<4;i++) if(!isalpha((unsigned char)tmp[i])){ok=0;break;}
|
||||
for(int i=4;i<9;i++) if(!isdigit((unsigned char)tmp[i])){ok=0;break;}
|
||||
if(ok) strncpy(tid,tmp,sizeof(tid)-1);}
|
||||
/* proactively cache icon from /user/appmeta/ if not already cached */
|
||||
if(tid[0]){
|
||||
char ic2[256]; snprintf(ic2,sizeof(ic2),"/data/SMPlusGui/icon-cache/%s.png",tid);
|
||||
struct stat ics; if(stat(ic2,&ics)!=0){
|
||||
char isrc[256]; snprintf(isrc,sizeof(isrc),"/user/appmeta/%s/icon0.png",tid);
|
||||
struct stat iss; if(stat(isrc,&iss)==0){
|
||||
FILE *sf=fopen(isrc,"rb");
|
||||
if(sf){fseek(sf,0,SEEK_END);long il=ftell(sf);fseek(sf,0,SEEK_SET);
|
||||
if(il>0&&il<=524288){char *ib=malloc(il);
|
||||
if(ib&&(fread(ib,1,il,sf)==(size_t)il)){
|
||||
mkdir("/data/SMPlusGui",0777);mkdir("/data/SMPlusGui/icon-cache",0777);
|
||||
FILE *cf=fopen(ic2,"wb");if(cf){fwrite(ib,1,il,cf);fclose(cf);}
|
||||
}free(ib);}fclose(sf);}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* look up title_name from games JSON if available */
|
||||
char dname[128]={0};
|
||||
if(tid[0]&&gam_json){
|
||||
|
||||
Reference in new issue
Block a user