Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented sysCacheClear() #4445

Merged
merged 12 commits into from Apr 18, 2018
21 changes: 16 additions & 5 deletions rpcs3/Emu/Cell/Modules/cellSysutil.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
Expand Down Expand Up @@ -283,18 +283,29 @@ s32 cellSysutilUnregisterCallback(u32 slot)
return CELL_OK;
}

s32 cellSysCacheClear(void)
s32 cellSysCacheClear()
{
cellSysutil.todo("cellSysCacheClear()");
// Checks if the param exists, else we quit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log command shouldn't be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll push a new version tonight after I get back from work.


if (!fxm::check<CellSysCacheParam>())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I told you on Discord, remove this and add it below if fxm::get fails

{
return CELL_SYSCACHE_ERROR_NOTMOUNTED;
}

const std::string& local_path = vfs::get("/dev_hdd1/cache/");
// Get the param as a shared ptr, then decipher the cacheid from it
// (Instead of assuming naively that the param is passed as argument)
std::shared_ptr<CellSysCacheParam> param = fxm::get<CellSysCacheParam>();
const std::string& cache_id = param->cacheId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need to check for
if (!param) return CELL_SYSCACHE_ERROR_ACCESS_ERROR;
or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do that check above in

if(!fxm::check<CellSysCacheParam>())

and return CELL_SYSCACHE_ERROR_NOTMOUNTED

This check was already part of the repo beforehand so I didn't change it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I told you to...
Also - you can change existing code you know :p

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't bind references, it's old style.


const std::string& cache_path = "/dev_hdd1/cache/" + cache_id + '/';
const std::string& dir_path = vfs::get(cache_path);

if (!fs::exists(dir_path) || !fs::is_dir(dir_path))
{
return CELL_SYSCACHE_ERROR_ACCESS_ERROR;
}

// TODO: Write tests to figure out, what is deleted.
fs::remove_all(dir_path, true);

return CELL_SYSCACHE_RET_OK_CLEARED;
}
Expand Down