Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Added feature to remove previously queued PKG by pressing ([ ]) squ…

…are.

- Added scan of PKG files on root of USB devices as well (from "/dev_usb000/" to "/dev_usb003/")
- Added scan of PKG files on "/dev_cf/..." (compact flash), "/dev_sd/..." (sd card), "/dev_ms/..." (memory stick)
- Other code improvements
  • Loading branch information...
commit b4a31213312549dcb2e97463716f412b5cfb4b98 1 parent 8e70706
@CaptainCPS authored
View
29 README.md
@@ -15,7 +15,7 @@ PKGs without wasting much time.
Technical Info:
----------------------------------------------
-Tested on Rogero CFW 4.30 (v2.03)
+Rogero CFW 4.30 (v2.03) @ 1080p resolution [HDMI]
Should work on 3.40+ CFW
@@ -36,6 +36,18 @@ for PKG files:
- /dev_usb003/
- /dev_usb003/pkg/
- /dev_usb003/package/
+- /dev_cf/
+- /dev_cf/pkg
+- /dev_cf/package
+- /dev_cf/packages
+- /dev_sd/
+- /dev_sd/pkg
+- /dev_sd/package
+- /dev_sd/packages
+- /dev_ms/
+- /dev_ms/pkg
+- /dev_ms/package
+- /dev_ms/packages
NOTES:
-----------------------------------------------
@@ -44,28 +56,29 @@ remember that these take some time to copy, make sure to
have at least double the space on the HDD.
- The application doesn't support re-scaning devices for new PKG files (for now)
-- The application doesn't verify HDD for previously queued files (for now)
- The application doesn't display a Progress bar (for now)
- The application doesn't support split PKG files (for now)
-- The application doesn't support removing Queued PKG (for now)
- The application doesn't have any special GUI (don't know how to, sorry lol)
Usage:
----------------------------------------------
-- Use UP and DOWN to select PKGs
-- Press (X) to Queue the selected PKG
-- Press (O) to Quit and return to XMB
+- Use UP and DOWN to select PKGs.
+- Press (X) to Queue the selected PKG.
+- Press (O) to Quit and return to XMB.
+- Press ([ ]) to Remove the selected PKG from queue.
Changelog:
----------------------------------------------
1.1
-- Improved application performance by cleaning up, organizing and simplifying lot of code.
+- Added feature to remove previously queued PKG by pressing ([ ]) square.
- Added scan of PKG files on root of USB devices as well (from "/dev_usb000/" to "/dev_usb003/")
+- Added scan of PKG files on "/dev_cf/..." (compact flash), "/dev_sd/..." (sd card), "/dev_ms/..." (memory stick)
+- Improved application performance by cleaning up, organizing and simplifying lot of code.
- Copy of PKG files is faster now.
-- Rewrote module to write the PDB & Icon files.
+- Re-wrote module to write the PDB & Icon files from scratch.
- Other source code improvements.
1.0
View
28 include/gamePKG.h
@@ -17,37 +17,47 @@ class c_pkglist
bInternal = false;
bQueued = false;
nSize = 0;
- nPKGID = 80000000; // default
+ nPKGID = 0;
}
~c_pkglist() { }
};
+#define STATUS_NORMAL 0
+#define STATUS_COPY_START 1
+#define STATUS_COPY_OK 2
+#define STATUS_COPY_ERROR 10
+#define STATUS_RM_QUEUE_START 4
+#define STATUS_RM_QUEUE_OK 5
+
+
class c_gamePKG
{
public:
+ c_gamePKG();
+
int nSelectedPKG;
int nPKGListTop;
- char szFileIn[256];
- char szFileOut[256];
int nTotalPKG;
- bool bDeleting;
- int nCopyStatus;
+ bool bDeleting;
int nPKGID;
+ int nStatus;
+
c_pkglist* pkglst[9000];
- c_gamePKG();
- ~c_gamePKG();
-
int QueuePKG();
+ void RemoveFromQueue();
+ void RemovePKG(int nId);
int CreatePDBFiles();
int DeletePDBFiles(int nId);
+ int RemoveAllDirFiles(char* szDirectory);
int RemovePKGDir(int nId);
+ int GetPKGDirId();
void RefreshPKGList();
uint64_t GetPKGSize(char* szFilePath);
- int ParsePKGList(const char* szDevice);
+ int ParsePKGList(char* szDirectory);
void Frame();
void DisplayFrame();
View
19 include/main.h
@@ -24,19 +24,20 @@
class CapApp : public FWGLApplication
{
public:
+
CapApp();
- bool onInit(int argc, char **argv);
- void onRender();
- void onShutdown();
- bool onUpdate();
+ virtual bool onInit(int argc, char **argv);
+ virtual void onRender();
+ virtual void onShutdown();
+ virtual bool onUpdate();
- void InputFrameStart();
- void InputFrameEnd();
+ virtual void InputFrameStart();
+ virtual void InputFrameEnd();
- void dbgFontInit();
- void dbgFontDraw();
- void dbgFontExit();
+ virtual void dbgFontInit();
+ virtual void dbgFontDraw();
+ virtual void dbgFontExit();
unsigned int mFrame;
View
BIN  msvc/gamePKG/gamePKG.suo
Binary file not shown
View
BIN  release/PS3_GAME/USRDIR/EBOOT.BIN
Binary file not shown
View
335 src/gamePKG.cpp
@@ -19,6 +19,24 @@
"d0.pdb"
"ICON_FILE"
+---------------------------------------------------------------------
+
+Tested on:
+
+ Rogero CFW 4.30 (v2.03) @ 1080p resolution [HDMI]
+
+TODO:
+
+ * - implement easy thread creation class
+ - put delete operations into separate thread
+
+ - implement 'qsort' module to sort PKG list
+
+ - support re-scaning devices for new PKG files
+WIP - verify HDD for previously queued files
+ - display a Progress bar
+ - support split PKG files
+
*/
#include "main.h"
#include "misc.h"
@@ -53,38 +71,14 @@ c_gamePKG::c_gamePKG()
nPKGListTop = 0;
nTotalPKG = 0;
bDeleting = false;
- nCopyStatus = 0;
- nPKGID = 80000000;
-}
-
-c_gamePKG::~c_gamePKG()
-{
- // ...
- if(nTotalPKG > 0)
- {
- for(int nPKG = 0; nPKG < nTotalPKG; nPKG++)
- {
- if(pkglst[nPKG])
- {
- delete [] pkglst[nPKG];
- pkglst[nPKG] = NULL;
- }
- }
- nTotalPKG = 0;
- }
- nSelectedPKG = 0;
- nPKGListTop = 0;
- bDeleting = false;
- nCopyStatus = 0;
+ nStatus = 0;
nPKGID = 80000000;
}
void c_gamePKG::Frame()
{
DisplayFrame();
-
InputFrame();
-
DlgDisplayFrame();
}
@@ -219,7 +213,9 @@ void c_gamePKG::InputFrame()
{
static int nSelInputFrame = 0;
+ // ------------------------------------------------------
// Navigation UP/DOWN with no delay
+
if( !app.mIsUpPressed && app.upPressedNow)
{
if(nSelectedPKG > 0 && nSelectedPKG <= nTotalPKG)
@@ -236,9 +232,11 @@ void c_gamePKG::InputFrame()
nSelectedPKG++;
}
nSelInputFrame = 0;
- }
+ }
+ // ------------------------------------------------------
// Navigation UP/DOWN with delay
+
if(((app.mFrame + nSelInputFrame) - app.mFrame) == 5)
{
if( app.mIsUpPressed && app.upPressedNow)
@@ -257,14 +255,20 @@ void c_gamePKG::InputFrame()
}
nSelInputFrame = 0;
}
+
nSelInputFrame++;
- if ( !app.mIsCirclePressed && app.circlePressedNow )
+ // ------------------------------------------------------
+ // [ ] - SQUARE
+
+ if(!app.mIsSquarePressed && app.squarePressedNow)
{
- app.onShutdown();
- exit(0);
+ RemoveFromQueue();
}
+ // ------------------------------------------------------
+ // (X) - CROSS
+
if ( !app.mIsCrossPressed && app.crossPressedNow )
{
if(pkglst[nSelectedPKG]->bQueued)
@@ -278,19 +282,30 @@ void c_gamePKG::InputFrame()
} else {
QueuePKG();
}
+ }
+
+ // ------------------------------------------------------
+ // (O) - CIRCLE
+
+ if (!app.mIsCirclePressed && app.circlePressedNow)
+ {
+ app.onShutdown();
+ exit(0);
}
+
+
}
void c_gamePKG::DlgDisplayFrame()
{
// COPY STARTED
- if(nCopyStatus == 1)
+ 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.",
- szFileIn,
+ pkglst[nSelectedPKG]->path,
GetByteUnit(pkglst[nSelectedPKG]->nSize), GetByteUnitStr(pkglst[nSelectedPKG]->nSize)
);
@@ -299,17 +314,15 @@ void c_gamePKG::DlgDisplayFrame()
szMsg,
DlgCallbackFunction, NULL, NULL
);
-
- nCopyStatus = 0; // avoid loop
}
// COPY [OK]
- if(nCopyStatus == 2)
+ if(nStatus == STATUS_COPY_OK)
{
cellMsgDialogAbort();
char szMsg[256] = "";
- sprintf(szMsg, "Successfully added \"%s\" to queue.", szFileIn);
+ sprintf(szMsg, "Successfully added \"%s\" to queue.", pkglst[nSelectedPKG]->path);
::cellMsgDialogOpen2(
CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_ON,
@@ -318,16 +331,15 @@ void c_gamePKG::DlgDisplayFrame()
);
pkglst[nSelectedPKG]->bQueued = true;
- nCopyStatus = 0;
}
// COPY [ERROR]
- if(nCopyStatus == 10)
+ if(nStatus == STATUS_COPY_ERROR)
{
cellMsgDialogAbort();
char szMsg[256] = "";
- sprintf(szMsg, "Error while processing \"%s\".", szFileIn);
+ sprintf(szMsg, "Error while processing \"%s\".", pkglst[nSelectedPKG]->path);
::cellMsgDialogOpen2(
CELL_MSGDIALOG_DIALOG_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK | CELL_MSGDIALOG_TYPE_DISABLE_CANCEL_OFF,
@@ -339,75 +351,117 @@ void c_gamePKG::DlgDisplayFrame()
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\" from queue.", pkglst[nSelectedPKG]->title);
- nCopyStatus = 0;
+ ::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;
}
-int c_gamePKG::ParsePKGList(const char* szDevice)
+int c_gamePKG::GetPKGDirId()
{
int fd;
- CellFsDirent dir;
-
+
char szDirectory[256] = "";
- sprintf(szDirectory, "%s", szDevice);
+ sprintf(szDirectory, "/dev_hdd0/vsh/game_pkg/%d", nPKGID);
+ if(cellFsOpendir(szDirectory, &fd) == CELL_FS_SUCCEEDED)
+ {
+ // there is already a directory with the ID, try again...
+ cellFsClosedir(fd);
+
+ nPKGID++;
+ return 0;
+ }
+
+ return nPKGID;
+}
+
+int c_gamePKG::ParsePKGList(char* szDirectory)
+{
+ int fd;
+ CellFsDirent dirEntry;
+
CellFsErrno res = cellFsOpendir(szDirectory, &fd);
if (res == CELL_FS_SUCCEEDED)
- {
+ {
uint64_t nread;
- while (::cellFsReaddir(fd, &dir, &nread) == CELL_FS_SUCCEEDED)
+ while(cellFsReaddir(fd, &dirEntry, &nread) == CELL_FS_SUCCEEDED)
{
if(nread == 0) break;
- if (dir.d_type == CELL_FS_TYPE_DIRECTORY)
+ if (dirEntry.d_type == CELL_FS_TYPE_DIRECTORY)
{
// DIRECTORY
} else {
- if(dir.d_type != CELL_FS_TYPE_REGULAR) break;
+ if(dirEntry.d_type != CELL_FS_TYPE_REGULAR) break;
// FILE
- int namelen = strlen(dir.d_name);
- if (namelen < 5) continue;
+ int nNameLen = strlen(dirEntry.d_name);
+ if (nNameLen < 5) continue;
// PKG
- int nFNLen = strlen(dir.d_name) + 1; // filename length
-
- char* pszFN = NULL;
- pszFN = (char*)malloc(sizeof(char) * nFNLen);
- memcpy(pszFN, dir.d_name, nFNLen);
+ char* pszFilename = NULL;
+ pszFilename = (char*)malloc(sizeof(char) * nNameLen);
+ memcpy(pszFilename, dirEntry.d_name, nNameLen);
- if(strstr(toLowerCase(pszFN), ".pkg"))
+ if(strstr(toLowerCase(pszFilename), ".pkg"))
{
-
// Add entry values to game list
pkglst[nTotalPKG] = new c_pkglist();
- if(!strncmp(szDevice, "/dev_hdd0", strlen("/dev_hdd0")))
+ if(strstr(szDirectory, "/dev_hdd0"))
{
pkglst[nTotalPKG]->bInternal = true;
}
// PKG Path
- sprintf(pkglst[nTotalPKG]->path, "%s/%s", szDevice, dir.d_name);
+ if(szDirectory[strlen(szDirectory)-1] == '/')
+ {
+ szDirectory[strlen(szDirectory)-1] = 0;
+ }
+
+ sprintf(pkglst[nTotalPKG]->path, "%s/%s", szDirectory, dirEntry.d_name);
// PKG Filename
- sprintf(pkglst[nTotalPKG]->title, "%s", dir.d_name);
- pkglst[nTotalPKG]->title[63] = 0;
+ sprintf(pkglst[nTotalPKG]->title, "%s", dirEntry.d_name);
// PKG directory ID (ex. 80000000)
- pkglst[nTotalPKG]->nPKGID = nPKGID;
+ while(pkglst[nTotalPKG]->nPKGID == 0)
+ {
+ pkglst[nTotalPKG]->nPKGID = GetPKGDirId();
+ }
// PKG Size in bytes
pkglst[nTotalPKG]->nSize = GetPKGSize(pkglst[nTotalPKG]->path);
nTotalPKG++;
nPKGID++;
-
}
}
}
@@ -474,39 +528,34 @@ void c_gamePKG::RefreshPKGList()
nTotalPKG = 0;
}
- ParsePKGList("/dev_hdd0/pkg");
- ParsePKGList("/dev_hdd0/package");
-
- ParsePKGList("/dev_usb000");
- ParsePKGList("/dev_usb000/pkg");
- ParsePKGList("/dev_usb000/package");
-
- ParsePKGList("/dev_usb001");
- ParsePKGList("/dev_usb001/pkg");
- ParsePKGList("/dev_usb001/package");
-
- ParsePKGList("/dev_usb002");
- ParsePKGList("/dev_usb002/pkg");
- ParsePKGList("/dev_usb002/package");
-
- ParsePKGList("/dev_usb003");
- ParsePKGList("/dev_usb003/pkg");
- ParsePKGList("/dev_usb003/package");
-
- ParsePKGList("/dev_usb004");
- ParsePKGList("/dev_usb004/pkg");
- ParsePKGList("/dev_usb004/package");
-
- ParsePKGList("/dev_sd");
- ParsePKGList("/dev_sd/pkg");
- ParsePKGList("/dev_sd/package");
+ char szDir[][256] = {
+ "", "pkg", "package", "packages"
+ };
- // todo: add micro sd support
+ char szDevice[][256] = {
+ "/dev_hdd0",
+ "/dev_usb000", "/dev_usb001", "/dev_usb002", "/dev_usb003",
+ "/dev_cf",
+ "/dev_sd",
+ "/dev_ms"
+ };
+ for(unsigned int nDev = 0; nDev < (sizeof(szDevice) / 256); nDev++)
+ {
+ for(unsigned int nDir = 0; nDir < (sizeof(szDir) / 256); nDir++)
+ {
+ char szPath[256] = "";
+ sprintf(szPath, "%s/%s", szDevice[nDev], szDir[nDir]);
+ ParsePKGList(szPath);
+ }
+ }
}
int c_gamePKG::RemovePKGDir(int nId)
{
+ if(bDeleting) return 0;
+ bDeleting = true;
+
char szPKGDir[256] = "";
sprintf(szPKGDir, "/dev_hdd0/vsh/game_pkg/%d", nId);
@@ -515,21 +564,60 @@ int c_gamePKG::RemovePKGDir(int nId)
if(ret != CELL_FS_SUCCEEDED)
{
// couldn't delete the directory...
+ bDeleting = false;
return 0;
}
+ bDeleting = false;
+
+ return 1;
+}
+
+int c_gamePKG::RemoveAllDirFiles(char* szDirectory)
+{
+ int fd;
+ CellFsDirent dirEntry;
+
+ CellFsErrno res = cellFsOpendir(szDirectory, &fd);
+
+ if (res == CELL_FS_SUCCEEDED)
+ {
+ uint64_t nread;
+
+ while(cellFsReaddir(fd, &dirEntry, &nread) == CELL_FS_SUCCEEDED)
+ {
+ if(nread == 0) break;
+
+ if (dirEntry.d_type == CELL_FS_TYPE_DIRECTORY)
+ {
+ // DIRECTORY
+ } else {
+
+ if(dirEntry.d_type != CELL_FS_TYPE_REGULAR) break;
+
+ // FILE
+ char szFile[256] = "";
+ sprintf(szFile, "%s/%s", szDirectory, dirEntry.d_name);
+
+ cellFsUnlink(szFile);
+ }
+ }
+ }
+ cellFsClosedir(fd);
+
return 1;
}
int c_gamePKG::DeletePDBFiles(int nId)
{
+ if(bDeleting) return 0;
bDeleting = true;
char szPDB[256] = "";
char szIconFile[256] = "";
sprintf(szPDB, "/dev_hdd0/vsh/game_pkg/%d/d0.pdb", nId);
sprintf(szIconFile, "/dev_hdd0/vsh/game_pkg/%d/ICON_FILE", nId);
-
+
FILE *fpPDB, *fpIcon;
if((fpPDB = fopen(szPDB, "r")))
@@ -551,6 +639,45 @@ int c_gamePKG::DeletePDBFiles(int nId)
return 1;
}
+void c_gamePKG::RemovePKG(int nId)
+{
+ if(bDeleting) return;
+ bDeleting = true;
+
+ char szPKG[256] = "";
+ sprintf(szPKG, "/dev_hdd0/vsh/game_pkg/%d/%s", nId, pkglst[nSelectedPKG]->title);
+
+ FILE *fpPKG;
+
+ if((fpPKG = fopen(szPKG, "r")))
+ {
+ fclose(fpPKG);
+ fpPKG = NULL;
+ cellFsUnlink(szPKG);
+ }
+
+ bDeleting = false;
+}
+
+void c_gamePKG::RemoveFromQueue()
+{
+ if(bDeleting || !pkglst[nSelectedPKG]->bQueued) return; // nothing to do here...
+
+ nStatus = STATUS_RM_QUEUE_START;
+
+ pkglst[nSelectedPKG]->bQueued = false;
+
+ char szDir[256] = "";
+ sprintf(szDir, "/dev_hdd0/vsh/game_pkg/%d", pkglst[nSelectedPKG]->nPKGID);
+
+ RemoveAllDirFiles(szDir);
+ RemovePKGDir(pkglst[nSelectedPKG]->nPKGID);
+
+ // todo: add error checking here...
+
+ nStatus = STATUS_RM_QUEUE_OK;
+}
+
uint64_t c_gamePKG::GetPKGSize(char* szFilePath)
{
CellFsStat sb;
@@ -694,17 +821,24 @@ int c_gamePKG::CreatePDBFiles()
void thread_FileCopy(uint64_t /*arg*/)
{
- gamePKG->nCopyStatus = 1;
+ gamePKG->nStatus = STATUS_COPY_START;
FILE *filer, *filew;
int numr, numw;
char *buffer;
buffer = (char*)malloc(sizeof(char) * BUFF_SIZE);
- memset(buffer, 0, sizeof(char) * BUFF_SIZE);
- filer = fopen(gamePKG->szFileIn,"rb");
- filew = fopen(gamePKG->szFileOut,"wb");
+ 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)
{
@@ -736,9 +870,9 @@ void thread_FileCopy(uint64_t /*arg*/)
if(bCopyError)
{
- cellFsUnlink(gamePKG->szFileOut); // delete file
+ cellFsUnlink(szFileOut); // delete file
- gamePKG->nCopyStatus = 10;
+ gamePKG->nStatus = STATUS_COPY_ERROR;
sys_ppu_thread_exit(0);
return;
}
@@ -752,10 +886,10 @@ void thread_FileCopy(uint64_t /*arg*/)
if(filew)
{
fclose(filew);
- cellFsUnlink(gamePKG->szFileOut); // delete file
+ cellFsUnlink(szFileOut); // delete file
}
- gamePKG->nCopyStatus = 10;
+ gamePKG->nStatus = STATUS_COPY_ERROR;
sys_ppu_thread_exit(0);
return;
}
@@ -763,7 +897,7 @@ void thread_FileCopy(uint64_t /*arg*/)
if(buffer) free(buffer);
buffer = NULL;
- gamePKG->nCopyStatus = 2;
+ gamePKG->nStatus = STATUS_COPY_OK;
sys_ppu_thread_exit(0);
}
@@ -798,9 +932,6 @@ int c_gamePKG::QueuePKG()
return 0;
}
- sprintf(szFileIn, "%s", pkglst[nSelectedPKG]->path);
- sprintf(szFileOut, "%s/%s", pszPKGDir, pkglst[nSelectedPKG]->title);
-
sys_ppu_thread_t thread_id;
sys_ppu_thread_create(
View
19 src/main.cpp
@@ -1,23 +1,6 @@
// ----------------------------------------------------------------------------
// CaptainCPS-X's gamePKG Tool
// ----------------------------------------------------------------------------
-/*
-
-Tested on: Rogero CFW 4.30 v2.03
-
-TODO:
-
-- support re-scaning devices for new PKG files
-- verify HDD for previously queued files
-- display a Progress bar
-- support split PKG files (for now)
-- support removing Queued PKG (for now)
-
-- Clean code
-
-*/
-// ----------------------------------------------------------------------
-
#include "main.h"
#include "misc.h"
#include "gamePKG.h"
@@ -201,8 +184,6 @@ void CapApp::onRender()
void CapApp::onShutdown()
{
- gamePKG->~c_gamePKG();
-
FWInputDevice *pPad = FWInput::getDevice(FWInput::DeviceType_Pad, 0);
if(pPad != NULL)
Please sign in to comment.
Something went wrong with that request. Please try again.