Merge pull request #1068 from Nekotekina/master

wxDir replaced
This commit is contained in:
Hykem 2015-04-26 13:17:42 +01:00
commit bb63ec0c83
12 changed files with 326 additions and 191 deletions

View file

@ -1,10 +1,5 @@
#include "stdafx.h"
#include "Log.h"
#pragma warning(push)
#pragma message("TODO: remove wx dependency: <wx/dir.h>")
#pragma warning(disable : 4996)
#include <wx/dir.h>
#pragma warning(pop)
#include "File.h"
#ifdef _WIN32
@ -12,6 +7,8 @@
#define GET_API_ERROR static_cast<u64>(GetLastError())
static_assert(fs::file::null == intptr_t(INVALID_HANDLE_VALUE) && fs::dir::null == fs::file::null, "Check fs::file::null definition");
std::unique_ptr<wchar_t[]> ConvertUTF8ToWChar(const std::string& source)
{
const size_t length = source.size() + 1; // size + null terminator
@ -28,6 +25,24 @@ std::unique_ptr<wchar_t[]> ConvertUTF8ToWChar(const std::string& source)
return buffer;
}
std::string ConvertWCharToUTF8(const wchar_t* source)
{
const int size = WideCharToMultiByte(CP_UTF8, 0, source, -1 /* NTS */, NULL, 0, NULL, NULL); // size
if (size < 1) throw std::length_error(__FUNCTION__); // ???
std::string result;
result.resize(size - 1);
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1 /* NTS */, &result.front(), size, NULL, NULL))
{
LOG_ERROR(GENERAL, "ConvertWCharToUTF8() failed: 0x%llx", GET_API_ERROR);
}
return result;
}
time_t to_time_t(const ULARGE_INTEGER& ft)
{
return ft.QuadPart / 10000000ULL - 11644473600ULL;
@ -51,7 +66,7 @@ time_t to_time_t(const FILETIME& ft)
return to_time_t(v);
}
bool truncate_file(const std::string& file, uint64_t length)
bool truncate_file(const std::string& file, u64 length)
{
// open the file
const auto handle = CreateFileW(ConvertUTF8ToWChar(file).get(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@ -79,6 +94,7 @@ bool truncate_file(const std::string& file, uint64_t length)
#else
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#if defined(__APPLE__) || defined(__FreeBSD__)
@ -98,14 +114,12 @@ bool fs::stat(const std::string& path, stat_t& info)
WIN32_FILE_ATTRIBUTE_DATA attrs;
if (!GetFileAttributesExW(ConvertUTF8ToWChar(path).get(), GetFileExInfoStandard, &attrs))
{
info = {};
return false;
}
info.exists = true;
info.is_directory = (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info.is_writable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
info.size = (uint64_t)attrs.nFileSizeLow | ((uint64_t)attrs.nFileSizeHigh << 32);
info.size = (u64)attrs.nFileSizeLow | ((u64)attrs.nFileSizeHigh << 32);
info.atime = to_time_t(attrs.ftLastAccessTime);
info.mtime = to_time_t(attrs.ftLastWriteTime);
info.ctime = to_time_t(attrs.ftCreationTime);
@ -113,11 +127,9 @@ bool fs::stat(const std::string& path, stat_t& info)
struct stat64 file_info;
if (stat64(path.c_str(), &file_info) < 0)
{
info = {};
return false;
}
info.exists = true;
info.is_directory = S_ISDIR(file_info.st_mode);
info.is_writable = file_info.st_mode & 0200; // HACK: approximation
info.size = file_info.st_size;
@ -125,6 +137,7 @@ bool fs::stat(const std::string& path, stat_t& info)
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
#endif
return true;
}
@ -334,7 +347,7 @@ bool fs::remove_file(const std::string& file)
return true;
}
bool fs::truncate_file(const std::string& file, uint64_t length)
bool fs::truncate_file(const std::string& file, u64 length)
{
#ifdef _WIN32
if (!::truncate_file(file, length))
@ -349,53 +362,16 @@ bool fs::truncate_file(const std::string& file, uint64_t length)
return true;
}
fs::file::file()
#ifdef _WIN32
: fd(INVALID_HANDLE_VALUE)
#else
: fd(-1)
#endif
{
}
fs::file::~file()
{
#ifdef _WIN32
if (fd != INVALID_HANDLE_VALUE)
if (m_fd != null)
{
CloseHandle(fd);
}
#else
if (fd != -1)
{
::close(fd);
}
#endif
}
fs::file::file(const std::string& filename, u32 mode)
#ifdef _WIN32
: fd(INVALID_HANDLE_VALUE)
CloseHandle((HANDLE)m_fd);
#else
: fd(-1)
::close(m_fd);
#endif
{
open(filename, mode);
}
fs::file::operator bool() const
{
#ifdef _WIN32
return fd != INVALID_HANDLE_VALUE;
#else
return fd != -1;
#endif
}
void fs::file::import(handle_type handle)
{
this->~file();
fd = handle;
}
}
bool fs::file::open(const std::string& filename, u32 mode)
@ -436,7 +412,7 @@ bool fs::file::open(const std::string& filename, u32 mode)
return false;
}
if ((fd = CreateFileW(ConvertUTF8ToWChar(filename).get(), access, FILE_SHARE_READ, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
m_fd = (intptr_t)CreateFileW(ConvertUTF8ToWChar(filename).get(), access, FILE_SHARE_READ, NULL, disp, FILE_ATTRIBUTE_NORMAL, NULL);
#else
int flags = 0;
@ -463,8 +439,10 @@ bool fs::file::open(const std::string& filename, u32 mode)
return false;
}
if ((fd = ::open(filename.c_str(), flags, 0666)) == -1)
m_fd = ::open(filename.c_str(), flags, 0666);
#endif
if (m_fd == null)
{
LOG_WARNING(GENERAL, "fs::file::open('%s', 0x%x) failed: error 0x%llx", filename, mode, GET_API_ERROR);
return false;
@ -473,29 +451,24 @@ bool fs::file::open(const std::string& filename, u32 mode)
return true;
}
bool fs::file::is_opened() const
{
return *this;
}
bool fs::file::trunc(u64 size) const
{
#ifdef _WIN32
LARGE_INTEGER old, pos;
pos.QuadPart = 0;
SetFilePointerEx(fd, pos, &old, FILE_CURRENT); // get old position
SetFilePointerEx((HANDLE)m_fd, pos, &old, FILE_CURRENT); // get old position
pos.QuadPart = size;
SetFilePointerEx(fd, pos, NULL, FILE_BEGIN); // set new position
SetFilePointerEx((HANDLE)m_fd, pos, NULL, FILE_BEGIN); // set new position
SetEndOfFile(fd); // change file size
SetEndOfFile((HANDLE)m_fd); // change file size
SetFilePointerEx(fd, old, NULL, FILE_BEGIN); // restore position
SetFilePointerEx((HANDLE)m_fd, old, NULL, FILE_BEGIN); // restore position
return true; // TODO
#else
return !ftruncate64(fd, size);
return !ftruncate64(m_fd, size);
#endif
}
@ -503,15 +476,12 @@ bool fs::file::stat(stat_t& info) const
{
#ifdef _WIN32
FILE_BASIC_INFO basic_info;
//FILE_NAME_INFO name_info;
if (!GetFileInformationByHandleEx(fd, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)))
if (!GetFileInformationByHandleEx((HANDLE)m_fd, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)))
{
info = {};
return false;
}
info.exists = true;
info.is_directory = (basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info.is_writable = (basic_info.FileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
info.size = this->size();
@ -520,13 +490,11 @@ bool fs::file::stat(stat_t& info) const
info.ctime = to_time_t(basic_info.CreationTime);
#else
struct stat64 file_info;
if (fstat64(fd, &file_info) < 0)
if (fstat64(m_fd, &file_info) < 0)
{
info = {};
return false;
}
info.exists = true;
info.is_directory = S_ISDIR(file_info.st_mode);
info.is_writable = file_info.st_mode & 0200; // HACK: approximation
info.size = file_info.st_size;
@ -534,42 +502,39 @@ bool fs::file::stat(stat_t& info) const
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
#endif
return true;
}
bool fs::file::close()
{
if (m_fd == null)
{
return false;
}
auto fd = m_fd;
m_fd = null;
#ifdef _WIN32
if (CloseHandle(fd))
{
return true;
}
fd = INVALID_HANDLE_VALUE;
return CloseHandle((HANDLE)fd);
#else
if (!::close(fd))
{
return true;
}
fd = -1;
return !::close(fd);
#endif
return false;
}
u64 fs::file::read(void* buffer, u64 count) const
{
#ifdef _WIN32
DWORD nread;
if (!ReadFile(fd, buffer, count, &nread, NULL))
if (!ReadFile((HANDLE)m_fd, buffer, count, &nread, NULL))
{
return -1;
}
return nread;
#else
return ::read(fd, buffer, count);
return ::read(m_fd, buffer, count);
#endif
}
@ -577,14 +542,14 @@ u64 fs::file::write(const void* buffer, u64 count) const
{
#ifdef _WIN32
DWORD nwritten;
if (!WriteFile(fd, buffer, count, &nwritten, NULL))
if (!WriteFile((HANDLE)m_fd, buffer, count, &nwritten, NULL))
{
return -1;
}
return nwritten;
#else
return ::write(fd, buffer, count);
return ::write(m_fd, buffer, count);
#endif
}
@ -596,14 +561,14 @@ u64 fs::file::seek(u64 offset, u32 mode) const
LARGE_INTEGER pos;
pos.QuadPart = offset;
if (!SetFilePointerEx(fd, pos, &pos, mode))
if (!SetFilePointerEx((HANDLE)m_fd, pos, &pos, mode))
{
return -1;
}
return pos.QuadPart;
#else
return lseek64(fd, offset, mode);
return lseek64(m_fd, offset, mode);
#endif
}
@ -611,7 +576,7 @@ u64 fs::file::size() const
{
#ifdef _WIN32
LARGE_INTEGER size;
if (!GetFileSizeEx(fd, &size))
if (!GetFileSizeEx((HANDLE)m_fd, &size))
{
return -1;
}
@ -619,7 +584,7 @@ u64 fs::file::size() const
return size.QuadPart;
#else
struct stat64 file_info;
if (fstat64(fd, &file_info) < 0)
if (fstat64(m_fd, &file_info) < 0)
{
return -1;
}
@ -628,45 +593,182 @@ u64 fs::file::size() const
#endif
}
rDir::rDir()
fs::dir::~dir()
{
handle = reinterpret_cast<void*>(new wxDir());
if (m_dd != null)
{
#ifdef _WIN32
FindClose((HANDLE)m_dd);
#else
::closedir((DIR*)m_dd);
#endif
}
}
rDir::~rDir()
void fs::dir::import(handle_type dd, const std::string& path)
{
delete reinterpret_cast<wxDir*>(handle);
if (m_dd != null)
{
#ifdef _WIN32
FindClose((HANDLE)m_dd);
#else
::closedir((DIR*)m_dd);
#endif
}
m_dd = dd;
#ifdef _WIN32
m_path = ConvertUTF8ToWChar(path);
#else
m_path.reset(new char[path.size() + 1]);
memcpy(m_path.get(), path.c_str(), path.size() + 1);
#endif
}
rDir::rDir(const std::string &path)
bool fs::dir::open(const std::string& dirname)
{
handle = reinterpret_cast<void*>(new wxDir(fmt::FromUTF8(path)));
if (m_dd != null)
{
#ifdef _WIN32
FindClose((HANDLE)m_dd);
#else
::closedir((DIR*)m_dd);
#endif
}
m_dd = null;
m_path.reset();
if (!is_dir(dirname))
{
return false;
}
#ifdef _WIN32
m_path = ConvertUTF8ToWChar(dirname + "/*");
#else
m_path.reset(new char[dirname.size() + 1]);
memcpy(m_path.get(), dirname.c_str(), dirname.size() + 1);
#endif
return true;
}
bool rDir::Open(const std::string& path)
bool fs::dir::close()
{
return reinterpret_cast<wxDir*>(handle)->Open(fmt::FromUTF8(path));
if (m_dd == null)
{
if (m_path)
{
m_path.reset();
return true;
}
else
{
return false;
}
}
auto dd = m_dd;
m_dd = null;
m_path.reset();
#ifdef _WIN32
return FindClose((HANDLE)dd);
#else
return !::closedir((DIR*)dd);
#endif
}
bool rDir::IsOpened() const
bool fs::dir::get_first(std::string& name, stat_t& info)
{
return reinterpret_cast<wxDir*>(handle)->IsOpened();
if (m_dd != null) // close previous handle
{
#ifdef _WIN32
FindClose((HANDLE)m_dd);
#else
::closedir((DIR*)m_dd);
#endif
}
m_dd = null;
if (!m_path)
{
return false;
}
#ifdef _WIN32
WIN32_FIND_DATAW found;
m_dd = (intptr_t)FindFirstFileW(m_path.get(), &found);
if (m_dd == null)
{
return false;
}
name = ConvertWCharToUTF8(found.cFileName);
info.is_directory = (found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info.is_writable = (found.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow;
info.atime = to_time_t(found.ftLastAccessTime);
info.mtime = to_time_t(found.ftLastWriteTime);
info.ctime = to_time_t(found.ftCreationTime);
return true;
#else
m_dd = (intptr_t)::opendir(m_path.get());
return get_next(name, info);
#endif
}
bool rDir::GetFirst(std::string *filename) const
bool fs::dir::get_next(std::string& name, stat_t& info)
{
wxString str;
bool res;
res = reinterpret_cast<wxDir*>(handle)->GetFirst(&str);
*filename = str.ToStdString();
return res;
}
if (m_dd == null)
{
return false;
}
bool rDir::GetNext(std::string *filename) const
{
wxString str;
bool res;
res = reinterpret_cast<wxDir*>(handle)->GetNext(&str);
*filename = str.ToStdString();
return res;
#ifdef _WIN32
WIN32_FIND_DATAW found;
if (!FindNextFileW((HANDLE)m_dd, &found))
{
return false;
}
name = ConvertWCharToUTF8(found.cFileName);
info.is_directory = (found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info.is_writable = (found.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow;
info.atime = to_time_t(found.ftLastAccessTime);
info.mtime = to_time_t(found.ftLastWriteTime);
info.ctime = to_time_t(found.ftCreationTime);
#else
const auto found = ::readdir((DIR*)m_dd);
struct stat64 file_info;
if (!found || fstatat64(::dirfd((DIR*)m_dd), found->d_name, &file_info, 0) < 0)
{
return false;
}
name = found->d_name;
info.is_directory = S_ISDIR(file_info.st_mode);
info.is_writable = file_info.st_mode & 0200; // HACK: approximation
info.size = file_info.st_size;
info.atime = file_info.st_atime;
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
#endif
return true;
}

View file

@ -21,10 +21,9 @@ namespace fs
{
struct stat_t
{
bool exists;
bool is_directory;
bool is_writable;
uint64_t size;
u64 size;
time_t atime;
time_t mtime;
time_t ctime;
@ -40,23 +39,21 @@ namespace fs
bool rename(const std::string& from, const std::string& to);
bool copy_file(const std::string& from, const std::string& to, bool overwrite);
bool remove_file(const std::string& file);
bool truncate_file(const std::string& file, uint64_t length);
bool truncate_file(const std::string& file, u64 length);
struct file final
{
#ifdef _WIN32
using handle_type = void*;
#else
using handle_type = intptr_t;
#endif
static const handle_type null = -1;
private:
handle_type fd;
handle_type m_fd = null;
public:
file();
file() = default;
~file();
explicit file(const std::string& filename, u32 mode = o_read);
explicit file(const std::string& filename, u32 mode = o_read) { open(filename, mode); }
file(const file&) = delete;
file(file&&) = delete; // possibly TODO
@ -64,12 +61,12 @@ namespace fs
file& operator =(const file&) = delete;
file& operator =(file&&) = delete; // possibly TODO
operator bool() const; // check is_opened()
operator bool() const { return m_fd != null; }
void import(handle_type fd); // replace file handle
void import(handle_type fd) { this->~file(); m_fd = fd; }
bool open(const std::string& filename, u32 mode = o_read);
bool is_opened() const; // check whether the file is opened
bool is_opened() const { return m_fd != null; }
bool trunc(u64 size) const; // change file size (possibly appending zero bytes)
bool stat(stat_t& info) const; // get file info
bool close();
@ -79,19 +76,47 @@ namespace fs
u64 seek(u64 offset, u32 mode = from_begin) const;
u64 size() const;
};
struct dir final
{
#ifdef _WIN32
using handle_type = intptr_t;
using name_type = std::unique_ptr<wchar_t[]>;
static const handle_type null = -1;
#else
using handle_type = intptr_t;
using name_type = std::unique_ptr<char[]>;
static const handle_type null = 0;
#endif
private:
handle_type m_dd = null;
name_type m_path;
public:
dir() = default;
~dir();
explicit dir(const std::string& dirname) { open(dirname); }
dir(const dir&) = delete;
dir(dir&&) = delete; // possibly TODO
dir& operator =(const dir&) = delete;
dir& operator =(dir&&) = delete; // possibly TODO
operator bool() const { return m_path.operator bool(); }
void import(handle_type dd, const std::string& path);
bool open(const std::string& dirname);
bool is_opened() const { return *this; }
bool close();
bool get_first(std::string& name, stat_t& info);
//bool get_first(std::string& name);
bool get_next(std::string& name, stat_t& info);
//bool get_next(std::string& name);
};
}
struct rDir
{
rDir();
~rDir();
rDir(const rDir& other) = delete;
rDir(const std::string &path);
bool Open(const std::string& path);
bool IsOpened() const;
static bool Exists(const std::string &path);
bool GetFirst(std::string *filename) const;
bool GetNext(std::string *filename) const;
void *handle;
};

View file

@ -26,11 +26,17 @@ const g_spu_imm_table_t g_spu_imm;
class spu_inter_func_list_t
{
std::array<spu_inter_func_t, 2048> funcs;
std::array<spu_inter_func_t, 2048> funcs = {};
std::mutex m_mutex;
public:
spu_inter_func_list_t()
void initialize()
{
std::lock_guard<std::mutex> lock(m_mutex);
if (funcs[0]) return; // check if already initialized
auto inter = new SPUInterpreter2;
SPUDecoder dec(*inter);
@ -49,7 +55,7 @@ public:
return funcs[opcode >> 21];
}
}
const g_spu_inter_func_list;
g_spu_inter_func_list;
SPUThread& GetCurrentSPUThread()
{
@ -189,6 +195,7 @@ void SPUThread::DoRun()
case 1: // alternative interpreter
{
g_spu_inter_func_list.initialize(); // initialize helper table
break;
}

View file

@ -12,18 +12,16 @@ vfsLocalDir::~vfsLocalDir()
bool vfsLocalDir::Open(const std::string& path)
{
if (!vfsDirBase::Open(path) || !dir.Open(path))
if (!vfsDirBase::Open(path) || !m_dir.open(path))
{
return false;
}
std::string name;
fs::stat_t file_info;
for (bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name))
for (bool is_ok = m_dir.get_first(name, file_info); is_ok; is_ok = m_dir.get_next(name, file_info))
{
fs::stat_t file_info;
fs::stat(path + "/" + name, file_info);
m_entries.emplace_back();
DirEntryInfo& info = m_entries.back();
@ -62,5 +60,5 @@ bool vfsLocalDir::Remove(const std::string& path)
bool vfsLocalDir::IsOpened() const
{
return dir.IsOpened() && vfsDirBase::IsOpened();
return m_dir && vfsDirBase::IsOpened();
}

View file

@ -6,7 +6,7 @@ class vfsLocalDir : public vfsDirBase
{
private:
u32 m_pos;
rDir dir;
fs::dir m_dir;
public:
vfsLocalDir(vfsDevice* device);
@ -19,4 +19,4 @@ public:
virtual bool Remove(const std::string& path) override;
virtual bool IsOpened() const override;
virtual bool IsExists(const std::string& path) const;
};
};

View file

@ -129,7 +129,7 @@ __noinline s32 savedata_op(
for (const auto entry : vfsDir(base_dir))
{
if (!(entry->flags & DirEntry_TypeDir))
if (entry->flags & DirEntry_TypeFile)
{
continue;
}
@ -374,7 +374,10 @@ __noinline s32 savedata_op(
Emu.GetVFS().GetDevice(dir_path, dir_local_path);
fs::stat_t dir_info;
fs::stat(dir_local_path, dir_info);
if (!fs::stat(dir_local_path, dir_info))
{
// error
}
statGet->hddFreeSizeKB = 40 * 1024 * 1024; // 40 GB
statGet->isNewData = save_entry.isNew = !psf;

View file

@ -100,8 +100,8 @@ int npDrmIsAvailable(u32 k_licensee_addr, vm::ptr<const char> drm_path)
}
}
sceNp.Warning("npDrmIsAvailable: Found DRM license file at %s", drm_path.get_ptr());
sceNp.Warning("npDrmIsAvailable: Using k_licensee 0x%s", k_licensee_str.c_str());
sceNp.Warning("npDrmIsAvailable(): Found DRM license file at %s", drm_path.get_ptr());
sceNp.Warning("npDrmIsAvailable(): Using k_licensee 0x%s", k_licensee_str.c_str());
// Set the necessary file paths.
std::string drm_file_name = fmt::AfterLast(drm_path.get_ptr(), '/');
@ -116,21 +116,20 @@ int npDrmIsAvailable(u32 k_licensee_addr, vm::ptr<const char> drm_path)
std::string rap_path("/dev_hdd0/home/" + pf_str + "/exdata/");
// Search dev_usb000 for a compatible RAP file.
vfsDir raps_dir(rap_path);
if (!raps_dir.IsOpened())
sceNp.Warning("npDrmIsAvailable: Can't find RAP file for DRM!");
else
for (const auto entry : vfsDir(rap_path))
{
for (const DirEntryInfo *entry : raps_dir)
if (entry->name.find(titleID) != std::string::npos)
{
if (entry->name.find(titleID) != std::string::npos)
{
rap_path += entry->name;
break;
}
rap_path += entry->name;
break;
}
}
if (rap_path.back() == '/')
{
sceNp.Warning("npDrmIsAvailable(): Can't find RAP file for '%s' (titleID='%s')", drm_path.get_ptr(), titleID);
}
// Decrypt this EDAT using the supplied k_licensee and matching RAP file.
std::string enc_drm_path_local, dec_drm_path_local, rap_path_local;
Emu.GetVFS().GetDevice(enc_drm_path, enc_drm_path_local);

View file

@ -91,24 +91,29 @@ int sceNpTrophyInit(u32 pool_addr, u32 poolSize, u32 containerId, u64 options)
return CELL_OK;
}
int sceNpTrophyCreateContext(vm::ptr<u32> context, vm::ptr<SceNpCommunicationId> commID, vm::ptr<SceNpCommunicationSignature> commSign, u64 options)
int sceNpTrophyCreateContext(vm::ptr<u32> context, vm::ptr<const SceNpCommunicationId> commID, vm::ptr<const SceNpCommunicationSignature> commSign, u64 options)
{
sceNpTrophy.Warning("sceNpTrophyCreateContext(context_addr=0x%x, commID_addr=0x%x, commSign_addr=0x%x, options=0x%llx)",
context.addr(), commID.addr(), commSign.addr(), options);
sceNpTrophy.Warning("sceNpTrophyCreateContext(context=*0x%x, commID=*0x%x, commSign=*0x%x, options=0x%llx)", context, commID, commSign, options);
if (!sceNpTrophyInstance.m_bInitialized)
{
return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED;
if (options & (~(u64)1))
}
if (options & ~1)
{
return SCE_NP_TROPHY_ERROR_NOT_SUPPORTED;
}
// TODO: There are other possible errors
// TODO: Is the TROPHY.TRP file necessarily located in this path?
vfsDir dir("/app_home/../TROPDIR/");
if(!dir.IsOpened())
if (!Emu.GetVFS().ExistsDir("/app_home/../TROPDIR/"))
{
return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST;
}
// TODO: Following method will retrieve the TROPHY.TRP of the first folder that contains such file
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
for (const auto entry : vfsDir("/app_home/../TROPDIR/"))
{
if (entry->flags & DirEntry_TypeDir)
{

View file

@ -249,7 +249,7 @@ s32 sys_fs_stat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
fs::stat_t info;
if (!fs::stat(local_path, info) || !info.exists)
if (!fs::stat(local_path, info))
{
sys_fs.Error("sys_fs_stat('%s') failed: not found", path.get_ptr());
return CELL_FS_ENOENT;

View file

@ -106,23 +106,15 @@ void GameViewer::OnColClick(wxListEvent& event)
void GameViewer::LoadGames()
{
vfsDir dir(m_path);
LOG_NOTICE(HLE, "path: %s", m_path.c_str());
if(!dir.IsOpened()) return;
m_games.clear();
for(const DirEntryInfo* info : dir)
for (const auto info : vfsDir(m_path))
{
if(info->flags & DirEntry_TypeDir)
{
m_games.push_back(info->name);
}
}
dir.Close();
//ConLog.Write("path: %s", m_path.wx_str());
//ConLog.Write("folders count: %d", m_games.GetCount());
}
void GameViewer::LoadPSF()

View file

@ -44,10 +44,9 @@ void LLEModulesManagerFrame::Refresh()
Emu.GetVFS().Init(path);
vfsDir dir(path);
loader::handlers::elf64 sprx_loader;
for (const auto info : dir)
for (const auto info : vfsDir(path))
{
if (info->flags & DirEntry_TypeFile)
{

View file

@ -327,6 +327,11 @@ namespace loader
for (const auto module : lle_dir)
{
if (module->flags & DirEntry_TypeDir)
{
continue;
}
elf64 sprx_handler;
vfsFile fsprx(lle_dir.GetPath() + "/" + module->name);