WriteString replaced

strcpy_trunc (defined in GNU.h) is better for fixed-length char arrays
This commit is contained in:
Nekotekina 2014-09-05 03:23:36 +04:00
parent 27b24132a0
commit 964c1bfd6c
10 changed files with 74 additions and 69 deletions

View file

@ -56,7 +56,7 @@ void PPUThread::AddArgv(const std::string& arg)
m_stack_point -= arg.length() + 1;
m_stack_point = AlignAddr(m_stack_point, 0x10) - 0x10;
m_argv_addr.push_back(m_stack_point);
Memory.WriteString(m_stack_point, arg);
memcpy(vm::get_ptr<char>(m_stack_point), arg.c_str(), arg.size() + 1);
}
void PPUThread::InitRegs()

View file

@ -24,7 +24,7 @@ void MemoryBase::InvalidAddress(const char* func, const u64 addr)
void MemoryBase::RegisterPages(u64 addr, u32 size)
{
LV2_LOCK();
LV2_LOCK(0);
//LOG_NOTICE(MEMORY, "RegisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
@ -45,7 +45,7 @@ void MemoryBase::RegisterPages(u64 addr, u32 size)
void MemoryBase::UnregisterPages(u64 addr, u32 size)
{
LV2_LOCK();
LV2_LOCK(0);
//LOG_NOTICE(MEMORY, "UnregisterPages(addr=0x%llx, size=0x%x)", addr, size);
for (u64 i = addr / 4096; i < (addr + size) / 4096; i++)
@ -66,7 +66,7 @@ void MemoryBase::UnregisterPages(u64 addr, u32 size)
u32 MemoryBase::InitRawSPU(MemoryBlock* raw_spu)
{
LV2_LOCK();
LV2_LOCK(0);
u32 index;
for (index = 0; index < sizeof(RawSPUMem) / sizeof(RawSPUMem[0]); index++)
@ -84,7 +84,7 @@ u32 MemoryBase::InitRawSPU(MemoryBlock* raw_spu)
void MemoryBase::CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
{
LV2_LOCK();
LV2_LOCK(0);
for (int i = 0; i < MemoryBlocks.size(); ++i)
{
@ -99,7 +99,7 @@ void MemoryBase::CloseRawSPU(MemoryBlock* raw_spu, const u32 num)
void MemoryBase::Init(MemoryType type)
{
LV2_LOCK();
LV2_LOCK(0);
if (m_inited) return;
m_inited = true;
@ -152,7 +152,7 @@ void MemoryBase::Init(MemoryType type)
void MemoryBase::Close()
{
LV2_LOCK();
LV2_LOCK(0);
if (!m_inited) return;
m_inited = false;
@ -172,7 +172,7 @@ void MemoryBase::Close()
void MemoryBase::WriteMMIO32(u32 addr, const u32 data)
{
{
LV2_LOCK();
LV2_LOCK(0);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Write32(addr, data))
@ -188,7 +188,7 @@ u32 MemoryBase::ReadMMIO32(u32 addr)
{
u32 res;
{
LV2_LOCK();
LV2_LOCK(0);
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
((RawSPUThread*)RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])->Read32(addr, &res))
@ -203,7 +203,7 @@ u32 MemoryBase::ReadMMIO32(u32 addr)
bool MemoryBase::Map(const u64 addr, const u32 size)
{
LV2_LOCK();
LV2_LOCK(0);
if ((u32)addr != addr || (u64)addr + (u64)size > 0x100000000ull)
{
@ -224,7 +224,7 @@ bool MemoryBase::Map(const u64 addr, const u32 size)
bool MemoryBase::Unmap(const u64 addr)
{
LV2_LOCK();
LV2_LOCK(0);
for (u32 i = 0; i < MemoryBlocks.size(); i++)
{
@ -360,7 +360,7 @@ DynamicMemoryBlockBase::DynamicMemoryBlockBase()
const u32 DynamicMemoryBlockBase::GetUsedSize() const
{
LV2_LOCK();
LV2_LOCK(0);
u32 size = 0;
@ -389,7 +389,7 @@ bool DynamicMemoryBlockBase::IsMyAddress(const u64 addr)
MemoryBlock* DynamicMemoryBlockBase::SetRange(const u64 start, const u32 size)
{
LV2_LOCK();
LV2_LOCK(0);
m_max_size = PAGE_4K(size);
if (!MemoryBlock::SetRange(start, 0))
@ -403,7 +403,7 @@ MemoryBlock* DynamicMemoryBlockBase::SetRange(const u64 start, const u32 size)
void DynamicMemoryBlockBase::Delete()
{
LV2_LOCK();
LV2_LOCK(0);
m_allocated.clear();
m_max_size = 0;
@ -423,7 +423,7 @@ bool DynamicMemoryBlockBase::AllocFixed(u64 addr, u32 size)
return false;
}
LV2_LOCK();
LV2_LOCK(0);
for (u32 i = 0; i<m_allocated.size(); ++i)
{
@ -456,7 +456,7 @@ u64 DynamicMemoryBlockBase::AllocAlign(u32 size, u32 align)
exsize = size + align - 1;
}
LV2_LOCK();
LV2_LOCK(0);
for (u64 addr = MemoryBlock::GetStartAddr(); addr <= MemoryBlock::GetEndAddr() - exsize;)
{
@ -497,7 +497,7 @@ bool DynamicMemoryBlockBase::Alloc()
bool DynamicMemoryBlockBase::Free(u64 addr)
{
LV2_LOCK();
LV2_LOCK(0);
for (u32 num = 0; num < m_allocated.size(); num++)
{

View file

@ -313,10 +313,10 @@ public:
}
}
template<typename T> void WriteString(const T addr, const std::string& str)
{
memcpy((char*)GetMemFromAddr<T>(addr), str.c_str(), str.size() + 1);
}
//template<typename T> void WriteString(const T addr, const std::string& str)
//{
// memcpy((char*)GetMemFromAddr<T>(addr), str.c_str(), str.size() + 1);
//}
u32 GetUserMemTotalSize()
{

View file

@ -106,10 +106,15 @@ namespace vm
}
*/
template<typename AT> operator ps3::ptr<T, 1, AT>() const
template<typename AT> operator const ps3::ptr<T, 1, AT>() const
{
return ps3::ptr<T, 1, AT>::make(m_addr);
}
template<typename AT> operator const ps3::ptr<const T, 1, AT>() const
{
return ps3::ptr<const T, 1, AT>::make(m_addr);
}
operator T&()
{

View file

@ -181,8 +181,8 @@ int cellFontOpenFontset(vm::ptr<CellFontLibrary> library, vm::ptr<CellFontType>
return CELL_FONT_ERROR_NO_SUPPORT_FONTSET;
}
vm::var<const char> f((u32)file.length() + 1, 1);
Memory.WriteString(f.addr(), file);
vm::var<char> f((u32)file.length() + 1, 1);
memcpy(f.get_ptr(), file.c_str(), file.size() + 1);
int ret = cellFontOpenFontFile(library, f, 0, 0, font); //TODO: Find the correct values of subNum, uniqueId
font->origin = CELL_FONT_OPEN_FONTSET;
return ret;

View file

@ -16,7 +16,7 @@ Module *cellGame = nullptr;
std::string contentInfo = "";
std::string usrdir = "";
int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char> dirName)
int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm::ptr<CellGameContentSize> size, vm::ptr<char[CELL_GAME_DIRNAME_SIZE]> dirName)
{
cellGame->Warning("cellGameBootCheck(type_addr=0x%x, attributes_addr=0x%x, size_addr=0x%x, dirName_addr=0x%x)",
type.addr(), attributes.addr(), size.addr(), dirName.addr());
@ -50,7 +50,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
{
*type = CELL_GAME_GAMETYPE_DISC;
*attributes = 0; // TODO
if (dirName) Memory.WriteString(dirName.addr(), ""); // ???
if (dirName) strcpy_trunc(*dirName, ""); // ???
contentInfo = "/dev_bdvd/PS3_GAME";
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
}
@ -59,7 +59,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
std::string titleId = psf.GetString("TITLE_ID");
*type = CELL_GAME_GAMETYPE_HDD;
*attributes = 0; // TODO
if (dirName) Memory.WriteString(dirName.addr(), titleId);
if (dirName) strcpy_trunc(*dirName, titleId);
contentInfo = "/dev_hdd0/game/" + titleId;
usrdir = "/dev_hdd0/game/" + titleId + "/USRDIR";
}
@ -68,7 +68,7 @@ int cellGameBootCheck(vm::ptr<be_t<u32>> type, vm::ptr<be_t<u32>> attributes, vm
std::string titleId = psf.GetString("TITLE_ID");
*type = CELL_GAME_GAMETYPE_DISC;
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName) Memory.WriteString(dirName.addr(), titleId); // ???
if (dirName) strcpy_trunc(*dirName, titleId); // ???
contentInfo = "/dev_bdvd/PS3_GAME";
usrdir = "/dev_bdvd/PS3_GAME/USRDIR";
}
@ -177,7 +177,7 @@ int cellGameDataCheck(u32 type, vm::ptr<const char> dirName, vm::ptr<CellGameCon
return CELL_GAME_RET_OK;
}
int cellGameContentPermit(vm::ptr<char> contentInfoPath, vm::ptr<char> usrdirPath)
int cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPath, vm::ptr<char[CELL_GAME_PATH_MAX]> usrdirPath)
{
cellGame->Warning("cellGameContentPermit(contentInfoPath_addr=0x%x, usrdirPath_addr=0x%x)",
contentInfoPath.addr(), usrdirPath.addr());
@ -189,8 +189,8 @@ int cellGameContentPermit(vm::ptr<char> contentInfoPath, vm::ptr<char> usrdirPat
}
// TODO: make it better
Memory.WriteString(contentInfoPath.addr(), contentInfo);
Memory.WriteString(usrdirPath.addr(), usrdir);
strcpy_trunc(*contentInfoPath, contentInfo);
strcpy_trunc(*usrdirPath, usrdir);
contentInfo = "";
usrdir = "";
@ -350,9 +350,9 @@ int cellGameGetParamInt(u32 id, vm::ptr<be_t<u32>> value)
return CELL_OK;
}
int cellGameGetParamString(u32 id, u32 buf_addr, u32 bufsize)
int cellGameGetParamString(u32 id, vm::ptr<char> buf, u32 bufsize)
{
cellGame->Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf_addr, bufsize);
cellGame->Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.addr(), bufsize);
// TODO: Access through cellGame***Check functions
vfsFile f("/app_home/PARAM.SFO");
@ -393,8 +393,8 @@ int cellGameGetParamString(u32 id, u32 buf_addr, u32 bufsize)
return CELL_GAME_ERROR_INVALID_ID;
}
data.resize(bufsize-1);
Memory.WriteString(buf_addr, data.c_str());
if (data.size() >= bufsize) data.resize(bufsize - 1);
memcpy(buf.get_ptr(), data.c_str(), data.size() + 1);
return CELL_OK;
}

View file

@ -36,7 +36,7 @@ int UTF16stoUTF8s(vm::lptrl<const char16_t> utf16, vm::ptr<be_t<u32>> utf16_len,
}
*utf8_len = str.size();
Memory.WriteString(utf8.addr(), str);
memcpy(utf8.get_ptr(), str.c_str(), str.size());
#endif
return ConversionOK;
}
@ -305,7 +305,7 @@ int L10nConvertStr(int src_code, vm::ptr<const void> src, vm::ptr<be_t<u32>> src
if (target.length() > *dst_len) return DSTExhausted;
Memory.WriteString(dst.addr(), target);
memcpy(dst.get_ptr(), target.c_str(), target.size());
return ConversionOK;
#else

View file

@ -71,9 +71,9 @@ int cellRtcGetCurrentClockLocalTime(vm::ptr<CellRtcDateTime> pClock)
return CELL_OK;
}
int cellRtcFormatRfc2822(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
int cellRtcFormatRfc2822(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
cellRtc->Log("cellRtcFormatRfc2822(pszDateTime_addr=0x%x, pUtc=0x%x, time_zone=%d)", pszDateTime.addr(), pUtc.addr(), iTimeZone);
// Add time_zone as offset in minutes.
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
@ -84,28 +84,28 @@ int cellRtcFormatRfc2822(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iT
// Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000).
const std::string& str = date.Format("%a, %d %b %Y %T %z", rDateTime::TZ::UTC);
Memory.WriteString(pszDateTime_addr, str);
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
return CELL_OK;
}
int cellRtcFormatRfc2822LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
int cellRtcFormatRfc2822LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
cellRtc->Log("cellRtcFormatRfc2822LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime.addr(), pUtc.addr());
// Get date from ticks.
rDateTime date = rDateTime((time_t)pUtc->tick);
// Format date string in RFC2822 format (e.g.: Mon, 01 Jan 1990 12:00:00 +0000).
const std::string& str = date.Format("%a, %d %b %Y %T %z", rDateTime::TZ::Local);
Memory.WriteString(pszDateTime_addr, str);
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
return CELL_OK;
}
int cellRtcFormatRfc3339(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
int cellRtcFormatRfc3339(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime_addr, pUtc.addr(), iTimeZone);
cellRtc->Log("cellRtcFormatRfc3339(pszDateTime_addr=0x%x, pUtc=0x%x, iTimeZone=%d)", pszDateTime.addr(), pUtc.addr(), iTimeZone);
// Add time_zone as offset in minutes.
rTimeSpan tz = rTimeSpan(0, (long) iTimeZone, 0, 0);
@ -116,21 +116,21 @@ int cellRtcFormatRfc3339(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc, s32 iT
// Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z).
const std::string& str = date.Format("%FT%T.%zZ", rDateTime::TZ::UTC);
Memory.WriteString(pszDateTime_addr, str);
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
return CELL_OK;
}
int cellRtcFormatRfc3339LocalTime(u32 pszDateTime_addr, vm::ptr<CellRtcTick> pUtc)
int cellRtcFormatRfc3339LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime_addr, pUtc.addr());
cellRtc->Log("cellRtcFormatRfc3339LocalTime(pszDateTime_addr=0x%x, pUtc=0x%x)", pszDateTime.addr(), pUtc.addr());
// Get date from ticks.
rDateTime date = rDateTime((time_t) pUtc->tick);
// Format date string in RFC3339 format (e.g.: 1990-01-01T12:00:00.00Z).
const std::string& str = date.Format("%FT%T.%zZ", rDateTime::TZ::Local);
Memory.WriteString(pszDateTime_addr, str);
memcpy(pszDateTime.get_ptr(), str.c_str(), str.size() + 1);
return CELL_OK;
}

View file

@ -177,7 +177,7 @@ s32 cellFsOpendir(vm::ptr<const char> path, vm::ptr<be_t<u32>> fd)
s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
{
sys_fs->Log("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
sys_fs->Warning("cellFsReaddir(fd=%d, dir_addr=0x%x, nread_addr=0x%x)", fd, dir.addr(), nread.addr());
vfsDirBase* directory;
if(!sys_fs->CheckId(fd, directory))
@ -186,10 +186,10 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
const DirEntryInfo* info = directory->Read();
if(info)
{
*nread = 1;
Memory.WriteString(dir.addr() + 2, info->name);
dir->d_namlen = info->name.length();
dir->d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
dir->d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH));
strcpy_trunc(dir->d_name, info->name);
*nread = sizeof(CellFsDirent);
}
else
{
@ -201,7 +201,7 @@ s32 cellFsReaddir(u32 fd, vm::ptr<CellFsDirent> dir, vm::ptr<be_t<u64>> nread)
s32 cellFsClosedir(u32 fd)
{
sys_fs->Log("cellFsClosedir(fd=%d)", fd);
sys_fs->Warning("cellFsClosedir(fd=%d)", fd);
if(!Emu.GetIdManager().RemoveID(fd))
return CELL_ESRCH;
@ -252,7 +252,7 @@ s32 cellFsStat(vm::ptr<const char> path, vm::ptr<CellFsStat> sb)
s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
{
sys_fs->Log("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.addr());
sys_fs->Warning("cellFsFstat(fd=%d, sb_addr: 0x%x)", fd, sb.addr());
IDType type;
vfsStream* file;
@ -279,7 +279,7 @@ s32 cellFsFstat(u32 fd, vm::ptr<CellFsStat> sb)
s32 cellFsMkdir(vm::ptr<const char> path, u32 mode)
{
sys_fs->Log("cellFsMkdir(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
sys_fs->Warning("cellFsMkdir(path=\"%s\", mode=0x%x)", path.get_ptr(), mode);
const std::string _path = path.get_ptr();
@ -293,7 +293,7 @@ s32 cellFsMkdir(vm::ptr<const char> path, u32 mode)
s32 cellFsRename(vm::ptr<const char> from, vm::ptr<const char> to)
{
sys_fs->Log("cellFsRename(from='%s' (from_addr=0x%x), to='%s' (to_addr=0x%x))", from.get_ptr(), from.addr(), to.get_ptr(), to.addr());
sys_fs->Warning("cellFsRename(from='%s', to='%s')", from.get_ptr(), to.get_ptr());
std::string _from = from.get_ptr();
std::string _to = to.get_ptr();
@ -343,7 +343,7 @@ s32 cellFsFsync(u32 fd)
s32 cellFsRmdir(vm::ptr<const char> path)
{
sys_fs->Log("cellFsRmdir(path=\"%s\")", path.get_ptr());
sys_fs->Warning("cellFsRmdir(path=\"%s\")", path.get_ptr());
std::string _path = path.get_ptr();
@ -400,7 +400,7 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr<be_t<u64>> pos)
s32 cellFsFtruncate(u32 fd, u64 size)
{
sys_fs->Log("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
sys_fs->Warning("cellFsFtruncate(fd=%d, size=%lld)", fd, size);
IDType type;
vfsStream* file;
@ -429,7 +429,7 @@ s32 cellFsFtruncate(u32 fd, u64 size)
s32 cellFsTruncate(vm::ptr<const char> path, u64 size)
{
sys_fs->Log("cellFsTruncate(path=\"%s\", size=%lld)", path.get_ptr(), size);
sys_fs->Warning("cellFsTruncate(path=\"%s\", size=%lld)", path.get_ptr(), size);
vfsFile f(path.get_ptr(), vfsReadWrite);
if(!f.IsOpened())
@ -459,7 +459,7 @@ s32 cellFsTruncate(vm::ptr<const char> path, u64 size)
s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
{
sys_fs->Log("cellFsFGetBlockSize(fd=%d, sector_size_addr=0x%x, block_size_addr=0x%x)",
sys_fs->Warning("cellFsFGetBlockSize(fd=%d, sector_size_addr=0x%x, block_size_addr=0x%x)",
fd, sector_size.addr(), block_size.addr());
vfsStream* file;
@ -473,7 +473,7 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64
s32 cellFsGetBlockSize(vm::ptr<const char> path, vm::ptr<be_t<u64>> sector_size, vm::ptr<be_t<u64>> block_size)
{
sys_fs->Log("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)",
sys_fs->Warning("cellFsGetBlockSize(file='%s', sector_size_addr=0x%x, block_size_addr=0x%x)",
path.get_ptr(), sector_size.addr(), block_size.addr());
*sector_size = 4096; // ?
@ -496,7 +496,7 @@ s32 cellFsGetFreeSize(vm::ptr<const char> path, vm::ptr<be_t<u32>> block_size, v
s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<be_t<u32>> data_count)
{
sys_fs->Log("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size = 0x%x, data_count_addr=0x%x)",
sys_fs->Warning("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size=0x%x, data_count_addr=0x%x)",
fd, entries.addr(), entries_size, data_count.addr());
vfsDirBase* directory;
@ -506,11 +506,6 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
const DirEntryInfo* info = directory->Read();
if(info)
{
*data_count = 1;
Memory.WriteString(entries.addr()+2, info->name);
entries->entry_name.d_namlen = info->name.length();
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
entries->attribute.st_mode =
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
@ -522,6 +517,11 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
entries->attribute.st_mtime_ = 0; //TODO
entries->attribute.st_ctime_ = 0; //TODO
entries->attribute.st_blksize = 4096;
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
entries->entry_name.d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH));
strcpy_trunc(entries->entry_name.d_name, info->name);
*data_count = 1;
}
else
{

View file

@ -175,7 +175,7 @@ public:
__forceinline bool IsReady() const { return m_status == Ready; }
};
#define LV2_LOCK() std::lock_guard<std::recursive_mutex>(Emu.GetCoreMutex())
#define LV2_LOCK(x) std::lock_guard<std::recursive_mutex> core_lock##x(Emu.GetCoreMutex())
extern Emulator Emu;