void thread_FileCopy(uint64_t /*arg*/) { gamePKG->nStatus = STATUS_COPY_START; FILE *filer = NULL; FILE *filew = NULL; uint64_t numr = 0; // elements read uint64_t numw = 0; // elements wrote uint64_t nTotalRead = 0; double nCopyPct = 0.0f; double nTotDelta = 0.0f; uint32_t nApproxTotDelta = 0; char *buffer = NULL; buffer = (char*)malloc(BUFF_SIZE); filer = fopen(gamePKG->pkglst[gamePKG->nSelectedPKG].path,"rb"); char szFileOut[256] =""; sprintf( szFileOut, "/dev_hdd0/vsh/game_pkg/%d/%s", gamePKG->pkglst[gamePKG->nSelectedPKG].nPKGID, gamePKG->pkglst[gamePKG->nSelectedPKG].title ); filew = fopen(szFileOut, "wb"); if(filer != NULL && filew != NULL) { bool bCopyError = false; while(feof(filer) == 0) { // read if((numr = fread(buffer, 1, BUFF_SIZE, filer)) != BUFF_SIZE) { if(ferror(filer) != 0) { bCopyError = true; break; } else if(feof(filer) != 0) { // ... } } // write if((numw = fwrite(buffer, 1, numr, filew)) != numr) { bCopyError = true; break; } nTotalRead += numr; nCopyPct = (double)(((double)numr / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f); double nTotalPct = (double)((double)nTotalRead / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f; nTotDelta += nCopyPct; nApproxTotDelta += (uint32_t)round(nCopyPct); if((double)nApproxTotDelta < nTotalPct) { // Compensate loss of float/double data, as for example: approx 70% vs. precise 95% nApproxTotDelta += (uint32_t)(nTotalPct - (double)nApproxTotDelta); nCopyPct += (nTotalPct - (double)nApproxTotDelta); } cellMsgDialogProgressBarInc(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, (uint32_t)nCopyPct); char msg[256] = ""; sprintf( msg, //"%.2f %s / %.2f %s (%.1f %%)(delta: %d %%)", "%.2f %s / %.2f %s", GetByteUnit(nTotalRead), GetByteUnitStr(nTotalRead), GetByteUnit(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize), GetByteUnitStr(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) //, //nTotalPct, //nApproxTotDelta ); cellMsgDialogProgressBarSetMsg(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, msg); } nCopyPct = (double)(((double)numr / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f); double nTotalPct = (double)((double)nTotalRead / (double)gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) * 100.0f; nTotDelta += nCopyPct; nApproxTotDelta += (uint32_t)round(nCopyPct); if((double)nApproxTotDelta < nTotalPct) { // Compensate loss of float/double data, as for example: approx 70% vs. precise 95% nApproxTotDelta += (uint32_t)(nTotalPct - (double)nApproxTotDelta); nCopyPct += (nTotalPct - (double)nApproxTotDelta); } cellMsgDialogProgressBarInc(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, (uint32_t)nCopyPct); char msg[256] = ""; sprintf( msg, //"%.2f %s / %.2f %s (%.1f %%)(delta: %d %%)", "%.2f %s / %.2f %s", GetByteUnit(nTotalRead), GetByteUnitStr(nTotalRead), GetByteUnit(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize), GetByteUnitStr(gamePKG->pkglst[gamePKG->nSelectedPKG].nSize) //, //nTotalPct, //nApproxTotDelta ); cellMsgDialogProgressBarSetMsg(CELL_MSGDIALOG_PROGRESSBAR_INDEX_SINGLE, msg); if(filer) fclose(filer); if(filew) fclose(filew); if(bCopyError) { cellFsUnlink(szFileOut); // delete file gamePKG->nStatus = STATUS_COPY_ERROR; sys_ppu_thread_exit(0); return; } } else { if(buffer) free(buffer); buffer = NULL; if(filer) fclose(filer); if(filew) { fclose(filew); cellFsUnlink(szFileOut); // delete file } gamePKG->nStatus = STATUS_COPY_ERROR; sys_ppu_thread_exit(0); return; } if(buffer) { free(buffer); buffer = NULL; } sys_timer_usleep(1000000); // wait 1 second gamePKG->nStatus = STATUS_COPY_OK; sys_ppu_thread_exit(0); }
void c_gamePKG::DisplayFrame() { float xPos = 0.05f; float yPos = 0.05f; float yPosDiff = 0.03f; float nFontSize = 0.6f; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, APP_TITLE); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PRESS -(O)- TO EXIT AND RETURN TO XMB"); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PRESS -(X)- TO QUEUE PKG ON XMB"); yPos += yPosDiff; //::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PRESS -(/\)- TO VIEW FILE INFO"); //yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PRESS -([ ])- TO REMOVE FROM QUEUE"); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PRESS -[SELECT]- TO LOAD \"multiMAN\""); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; // Main menu uint32_t block_size = 0; uint64_t free_block_count = 0; ::cellFsGetFreeSize("/dev_hdd0", &block_size, &free_block_count); uint64_t nFreeHDDSpace = block_size * free_block_count; ::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "Free Space on /dev_hdd0/: %.2f %s (%lld bytes)", GetByteUnit(nFreeHDDSpace), GetByteUnitStr(nFreeHDDSpace), nFreeHDDSpace ); yPos += yPosDiff; //::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "Free Space on /dev_usb000/: %.2f %s (%lld bytes)", // GetByteUnit(nFreeUSB000Space), // GetByteUnitStr(nFreeUSB000Space), // nFreeUSB000Space // //GetNumWithCommas(nFreeUSB000Space) //); //yPos += yPosDiff; ::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "Total PKG found on all scanned devices: %d", nTotalPKG); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; int nPKGListMax = 14; if(nSelectedPKG > nPKGListMax || nPKGListTop > 0) { if(nPKGListTop < (nSelectedPKG - nPKGListMax)) { nPKGListTop = nSelectedPKG - nPKGListMax; } if(nPKGListTop > 0) { if(nSelectedPKG < nPKGListTop) { nPKGListTop = nSelectedPKG; } } else { nPKGListTop = nSelectedPKG - nPKGListMax; } } else { nPKGListTop = nSelectedPKG - nPKGListMax; } if(nPKGListTop < 0) nPKGListTop = 0; int nPKG = nPKGListTop; while(nPKG <= (nPKGListTop + nPKGListMax)) { if(nPKG == nTotalPKG) break; uint32_t nColor = 0xffffffff; // white nFontSize = 0.6f; // PKG QUEUED if(pkglst[nPKG].bQueued) { nColor = 0xff00ff00; // green } // PKG SELECTED if(nPKG == nSelectedPKG) { nColor = 0xff00ccff; // yellow nFontSize = 0.8f; if(pkglst[nPKG].bQueued) { nColor = 0xff0000ff; // red } } ::cellDbgFontPrintf(xPos, yPos, nFontSize, nColor, "[%d] %s [%.2f %s] %s %s", nPKG+1, pkglst[nPKG].title, GetByteUnit(pkglst[nPKG].nSize), GetByteUnitStr(pkglst[nPKG].nSize), pkglst[nPKG].bInternal ? "[HDD]" : "[USB]", pkglst[nPKG].bQueued ? "[Queued]" : " " ); yPos += yPosDiff; nPKG++; } nFontSize = 0.6f; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; }
bool CapApp::onUpdate() { mFrame++; Input(); dbgFontPut(); // COPY STARTED if(gamePKG->nCopyStatus == 1) { char szMsg[256] = ""; sprintf(szMsg, "Processing \"%s\" [%.2f %s]...\n\nAttendere, questo potrebbe richiedere tempo a seconda delle dimensioni del PKG. Non spegnere il sistema.", gamePKG->szFileIn, GetByteUnit(gamePKG->pkglst[gamePKG->nSelectedPKG]->nSize), GetByteUnitStr(gamePKG->pkglst[gamePKG->nSelectedPKG]->nSize) ); ::cellMsgDialogOpen2( CELL_MSGDIALOG_BUTTON_TYPE_NONE | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, // canceling not implemented yet szMsg, cbFileCopyDlg, NULL, NULL); gamePKG->nCopyStatus = 0; // avoid loop } // COPY [OK] if(gamePKG->nCopyStatus == 2) { cellMsgDialogAbort(); char szMsg[256] = ""; sprintf(szMsg, "Aggiunto con successo \"%s\" in coda.", gamePKG->szFileIn); ::cellMsgDialogOpen2( CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, szMsg, callbackfunction, NULL, NULL); gamePKG->pkglst[gamePKG->nSelectedPKG]->bQueued = true; gamePKG->nCopyStatus = 0; } // COPY [ERROR] if(gamePKG->nCopyStatus == 10) { cellMsgDialogAbort(); char szMsg[256] = ""; sprintf(szMsg, "Errore durante l'elaborazione \"%s\".", gamePKG->szFileIn); ::cellMsgDialogOpen2( CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, szMsg, callbackfunction, NULL, NULL); gamePKG->pkglst[gamePKG->nSelectedPKG]->bQueued = false; gamePKG->DeletePDBFiles(gamePKG->pkglst[gamePKG->nSelectedPKG]->nPKGID); gamePKG->RemovePKGDir(gamePKG->pkglst[gamePKG->nSelectedPKG]->nPKGID); gamePKG->nCopyStatus = 0; } return FWGLApplication::onUpdate(); }
void c_gamePKG::DlgDisplayFrame() { // COPY STARTED if(nStatus == STATUS_COPY_START) { char szMsg[256] = ""; sprintf( szMsg, "Processing \"%s\" [%.2f %s]...\n\nPlease wait, this could take a while depending on the size of the PKG. Do not turn off the system.", pkglst[nSelectedPKG].title, GetByteUnit(pkglst[nSelectedPKG].nSize), GetByteUnitStr(pkglst[nSelectedPKG].nSize) ); ::cellMsgDialogOpen2( CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL |CELL_MSGDIALOG_TYPE_BUTTON_TYPE_NONE |CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON |CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NONE |CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE, szMsg, DlgCallbackFunction, NULL, NULL ); } // COPY [OK] if(nStatus == STATUS_COPY_OK) { cellMsgDialogAbort(); char szMsg[256] = ""; sprintf( szMsg, "Successfully added \"%s\" [%.2f %s] to queue.", pkglst[nSelectedPKG].title, GetByteUnit(pkglst[nSelectedPKG].nSize), GetByteUnitStr(pkglst[nSelectedPKG].nSize) ); ::cellMsgDialogOpen2( CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, szMsg, DlgCallbackFunction, NULL, NULL ); pkglst[nSelectedPKG].bQueued = true; } // COPY [ERROR] if(nStatus == STATUS_COPY_ERROR) { cellMsgDialogAbort(); char szMsg[256] = ""; sprintf( szMsg, "Error while processing \"%s\" [%.2f %s].", pkglst[nSelectedPKG].title, GetByteUnit(pkglst[nSelectedPKG].nSize), GetByteUnitStr(pkglst[nSelectedPKG].nSize) ); ::cellMsgDialogOpen2( CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF, szMsg, DlgCallbackFunction, NULL, NULL ); pkglst[nSelectedPKG].bQueued = false; DeletePDBFiles(pkglst[nSelectedPKG].nPKGID); RemovePKGDir(pkglst[nSelectedPKG].nPKGID); } if(nStatus == STATUS_RM_QUEUE_START) { ::cellMsgDialogOpen2( CELL_MSGDIALOG_BUTTON_TYPE_NONE | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, "Removing selected PKG from queue, please wait. Do not turn off the system.", DlgCallbackFunction, NULL, NULL ); } if(nStatus == STATUS_RM_QUEUE_OK) { cellMsgDialogAbort(); char szMsg[256] = ""; sprintf( szMsg, "Successfully removed \"%s\" [%.2f %s] from queue.", pkglst[nSelectedPKG].title, GetByteUnit(pkglst[nSelectedPKG].nSize), GetByteUnitStr(pkglst[nSelectedPKG].nSize) ); ::cellMsgDialogOpen2( CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON, szMsg, DlgCallbackFunction, NULL, NULL ); } nStatus = STATUS_NORMAL; }
void CapApp::dbgFontPut(void) { float xPos = 0.05f; float yPos = 0.05f; float yPosDiff = 0.03f; float nFontSize = 0.6f; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, " gamePKG Tool v1.1 - by CaptainCPS-X Translate in ita by consolehackdev team [2012] [Yes the UI sucks...LOL]"); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PREMERE -(O)- PER USCIRE E RITORNARE ALLA XMB"); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PREMERE -(X)- METTERE IN CODA I PKG NELLA XMB"); yPos += yPosDiff; //::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PREMERE -(/\)- VEDERE IL FILE INFO"); //yPos += yPosDiff; //::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PREMERE -([ ])- PER RIMUOVERE DALLA CODA"); //yPos += yPosDiff; //::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "PREMERE -[SELECT]- PER CANCELLARE TUTTE LE CODE E AGGIORNARE I DISPOSITIVI"); //yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; // Main menu uint32_t block_size = 0; uint64_t free_block_count = 0; ::cellFsGetFreeSize("/dev_hdd0", &block_size, &free_block_count); uint64_t nFreeHDDSpace = block_size * free_block_count; ::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "Spazio libero disponibile in /dev_hdd0/: %.2f %s (%lld bytes)", GetByteUnit(nFreeHDDSpace), GetByteUnitStr(nFreeHDDSpace), nFreeHDDSpace ); yPos += yPosDiff; //::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "Spazio libero disponibile in /dev_usb000/: %.2f %s (%lld bytes)", // GetByteUnit(nFreeUSB000Space), // GetByteUnitStr(nFreeUSB000Space), // nFreeUSB000Space // //GetNumWithCommas(nFreeUSB000Space) //); //yPos += yPosDiff; ::cellDbgFontPrintf(xPos, yPos, nFontSize, 0xffffffff, "PKG Totali trovati su tutti i dispositivi analizzati: %d", gamePKG->nTotalPKG); yPos += yPosDiff; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; int nPKGListMax = 14; if(gamePKG->nSelectedPKG > nPKGListMax || gamePKG->nPKGListTop > 0) { if(gamePKG->nPKGListTop < (gamePKG->nSelectedPKG - nPKGListMax)) { gamePKG->nPKGListTop = gamePKG->nSelectedPKG - nPKGListMax; } if(gamePKG->nPKGListTop > 0) { if(gamePKG->nSelectedPKG < gamePKG->nPKGListTop) { gamePKG->nPKGListTop = gamePKG->nSelectedPKG; } } else { gamePKG->nPKGListTop = gamePKG->nSelectedPKG - nPKGListMax; } } else { gamePKG->nPKGListTop = gamePKG->nSelectedPKG - nPKGListMax; } if(gamePKG->nPKGListTop < 0) gamePKG->nPKGListTop = 0; int nPKG = gamePKG->nPKGListTop; while(nPKG <= (gamePKG->nPKGListTop + nPKGListMax)) { if(nPKG == gamePKG->nTotalPKG) break; uint32_t nColor = 0xffffffff; // white nFontSize = 0.6f; // PKG QUEUED if(gamePKG->pkglst[nPKG]->bQueued) { nColor = 0xff00ff00; // green } // PKG SELECTED if(nPKG == gamePKG->nSelectedPKG) { nColor = 0xff00ccff; // yellow nFontSize = 0.8f; if(gamePKG->pkglst[nPKG]->bQueued) { nColor = 0xff0000ff; // red } } ::cellDbgFontPrintf(xPos, yPos, nFontSize, nColor, "[%d] %s [%.2f %s] %s %s", nPKG+1, gamePKG->pkglst[nPKG]->title, GetByteUnit(gamePKG->pkglst[nPKG]->nSize), GetByteUnitStr(gamePKG->pkglst[nPKG]->nSize), gamePKG->pkglst[nPKG]->bInternal ? "[HDD]" : "[USB]", gamePKG->pkglst[nPKG]->bQueued ? "[In coda]" : " " ); yPos += yPosDiff; nPKG++; } nFontSize = 0.6f; ::cellDbgFontPuts(xPos, yPos, nFontSize, 0xffffffff, "----------------------------------------------------------------------" ); yPos += yPosDiff; }