mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 19:45:41 -04:00
[libromdata] IFst::readdir(): Return const DirEnt*
instead of DirEnt*
.
This ensures the caller won't modify the DirEnt. Note that this doesn't match POSIX readdir(), but we don't need to strictly match it. (We're also not returning `struct dirent*`; we're returning a custom one.)
This commit is contained in:
parent
b884747254
commit
5ed38edbec
@ -1550,10 +1550,11 @@ int GameCube::loadFieldData(void)
|
||||
// - 21.29: IOS version. (21.29 == v5405)
|
||||
IFst::Dir *const dirp = d->updatePartition->opendir("/_sys/");
|
||||
if (dirp) {
|
||||
IFst::DirEnt *dirent;
|
||||
const IFst::DirEnt *dirent;
|
||||
while ((dirent = d->updatePartition->readdir(dirp)) != nullptr) {
|
||||
if (!dirent->name || dirent->type != DT_REG)
|
||||
if (!dirent->name || dirent->type != DT_REG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for a retail System Menu.
|
||||
if (dirent->name[0] == 'R') {
|
||||
|
@ -447,7 +447,7 @@ IFst::Dir *GcnFst::opendir(const char *path)
|
||||
* @return IFst::DirEnt*, or nullptr if end of directory or on error.
|
||||
* (End of directory does not set lastError; an error does.)
|
||||
*/
|
||||
IFst::DirEnt *GcnFst::readdir(IFst::Dir *dirp)
|
||||
const IFst::DirEnt *GcnFst::readdir(IFst::Dir *dirp)
|
||||
{
|
||||
assert(dirp != nullptr);
|
||||
assert(dirp->parent == this);
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
* @return DirEnt*, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
DirEnt *readdir(Dir *dirp) final;
|
||||
const DirEnt *readdir(Dir *dirp) final;
|
||||
|
||||
/**
|
||||
* Close an opened directory.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ROM Properties Page shell extension. (libromdata) *
|
||||
* GcnPartition.cpp: GameCube partition reader. *
|
||||
* *
|
||||
* Copyright (c) 2016-2024 by David Korth. *
|
||||
* Copyright (c) 2016-2025 by David Korth. *
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
@ -217,7 +217,7 @@ IFst::Dir *GcnPartition::opendir(const char *path)
|
||||
* @return IFst::DirEnt*, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
IFst::DirEnt *GcnPartition::readdir(IFst::Dir *dirp)
|
||||
const IFst::DirEnt *GcnPartition::readdir(IFst::Dir *dirp)
|
||||
{
|
||||
RP_D(GcnPartition);
|
||||
if (!d->fst) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ROM Properties Page shell extension. (libromdata) *
|
||||
* GcnPartition.hpp: GameCube partition reader. *
|
||||
* *
|
||||
* Copyright (c) 2016-2023 by David Korth. *
|
||||
* Copyright (c) 2016-2025 by David Korth. *
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
@ -107,7 +107,7 @@ public:
|
||||
* @return IFst::DirEnt, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
LibRpBase::IFst::DirEnt *readdir(LibRpBase::IFst::Dir *dirp) final;
|
||||
const LibRpBase::IFst::DirEnt *readdir(LibRpBase::IFst::Dir *dirp) final;
|
||||
|
||||
/**
|
||||
* Close an opened directory.
|
||||
|
@ -492,7 +492,7 @@ IFst::Dir *WiiUFst::opendir(const char *path)
|
||||
* @return IFst::DirEnt*, or nullptr if end of directory or on error.
|
||||
* (End of directory does not set lastError; an error does.)
|
||||
*/
|
||||
IFst::DirEnt *WiiUFst::readdir(IFst::Dir *dirp)
|
||||
const IFst::DirEnt *WiiUFst::readdir(IFst::Dir *dirp)
|
||||
{
|
||||
RP_D(WiiUFst);
|
||||
assert(dirp != nullptr);
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
* @return DirEnt*, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
DirEnt *readdir(Dir *dirp) final;
|
||||
const DirEnt *readdir(Dir *dirp) final;
|
||||
|
||||
/**
|
||||
* Close an opened directory.
|
||||
|
@ -71,7 +71,7 @@ static int fstPrint(IFst *fst, ostream &os, const string &path,
|
||||
}
|
||||
|
||||
// Read the directory entries.
|
||||
IFst::DirEnt *dirent = fst->readdir(dirp);
|
||||
const IFst::DirEnt *dirent = fst->readdir(dirp);
|
||||
while (dirent != nullptr) {
|
||||
if (!dirent->name || dirent->name[0] == 0) {
|
||||
// Empty name...
|
||||
@ -79,8 +79,7 @@ static int fstPrint(IFst *fst, ostream &os, const string &path,
|
||||
}
|
||||
|
||||
// Print the tree lines.
|
||||
for (int i = 0; i < level; i++)
|
||||
{
|
||||
for (int i = 0; i < level; i++) {
|
||||
if (tree_lines[i]) {
|
||||
// Directory tree exists for this segment.
|
||||
os << "\xE2\x94\x82 ";
|
||||
|
@ -357,7 +357,7 @@ void GcnFstTest::checkNoDuplicateFilenames(const char *subdir)
|
||||
ASSERT_TRUE(dirp != nullptr) <<
|
||||
"Failed to open directory '" << subdir << "'.";
|
||||
|
||||
IFst::DirEnt *dirent = m_fst->readdir(dirp);
|
||||
const IFst::DirEnt *dirent = m_fst->readdir(dirp);
|
||||
while (dirent != nullptr) {
|
||||
// Make sure we haven't seen this filename in
|
||||
// the current subdirectory yet.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ROM Properties Page shell extension. (librpbase) *
|
||||
* IFst.hpp: File System Table interface. *
|
||||
* *
|
||||
* Copyright (c) 2016-2024 by David Korth. *
|
||||
* Copyright (c) 2016-2025 by David Korth. *
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
* @return DirEnt*, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
virtual DirEnt *readdir(Dir *dirp) = 0;
|
||||
virtual const DirEnt *readdir(Dir *dirp) = 0;
|
||||
|
||||
/**
|
||||
* Close an opened directory.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ROM Properties Page shell extension. (librpbase) *
|
||||
* IPartition.cpp: Partition reader interface. *
|
||||
* *
|
||||
* Copyright (c) 2016-2024 by David Korth. *
|
||||
* Copyright (c) 2016-2025 by David Korth. *
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
@ -38,7 +38,7 @@ IFst::Dir *IPartition::opendir(const char *path)
|
||||
* @return IFst::DirEnt, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
IFst::DirEnt *IPartition::readdir(IFst::Dir *dirp)
|
||||
const IFst::DirEnt *IPartition::readdir(IFst::Dir *dirp)
|
||||
{
|
||||
RP_UNUSED(dirp);
|
||||
assert(!"IFst wrapper functions are not implemented for this class!");
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ROM Properties Page shell extension. (librpbase) *
|
||||
* IPartition.hpp: Partition reader interface. *
|
||||
* *
|
||||
* Copyright (c) 2016-2024 by David Korth. *
|
||||
* Copyright (c) 2016-2025 by David Korth. *
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
* @return IFst::DirEnt, or nullptr if end of directory or on error.
|
||||
* (TODO: Add lastError()?)
|
||||
*/
|
||||
virtual IFst::DirEnt *readdir(IFst::Dir *dirp);
|
||||
virtual const IFst::DirEnt *readdir(IFst::Dir *dirp);
|
||||
|
||||
/**
|
||||
* Close an opened directory.
|
||||
|
Loading…
Reference in New Issue
Block a user