mirror of
https://github.com/wiiu-env/ContentRedirectionModule.git
synced 2024-09-28 19:18:41 +02:00
Fix readdir wrapper
This commit is contained in:
parent
eddbc7400e
commit
1cb894a64c
@ -99,13 +99,24 @@ FSError FSWrapper::FSReadDirWrapper(FSDirectoryHandle handle, FSDirectoryEntry *
|
|||||||
entry->info.size = 0;
|
entry->info.size = 0;
|
||||||
} else {
|
} else {
|
||||||
struct stat sb {};
|
struct stat sb {};
|
||||||
auto strLen = strlen(dirHandle->path) + 1 + strlen(entry_->d_name) + 1;
|
auto path = string_format("%s/%s", dirHandle->path, entry_->d_name);
|
||||||
char path[strLen];
|
std::replace(path.begin(), path.end(), '\\', '/');
|
||||||
snprintf(path, sizeof(path), "%s/%s", dirHandle->path, entry_->d_name);
|
|
||||||
if (stat(path, &sb) >= 0) {
|
uint32_t length = path.size();
|
||||||
|
|
||||||
|
//! clear path of double slashes
|
||||||
|
for (uint32_t i = 1; i < length; ++i) {
|
||||||
|
if (path[i - 1] == '/' && path[i] == '/') {
|
||||||
|
path.erase(i, 1);
|
||||||
|
i--;
|
||||||
|
length--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat(path.c_str(), &sb) >= 0) {
|
||||||
translate_stat(&sb, &entry->info);
|
translate_stat(&sb, &entry->info);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to stat file (%s) in read dir %08X (dir handle %08X)", getName().c_str(), path, dir, handle);
|
DEBUG_FUNCTION_LINE_ERR("[%s] Failed to stat file (%s) in read dir %08X (dir handle %08X)", getName().c_str(), path.c_str(), dir, handle);
|
||||||
result = FS_ERROR_MEDIA_ERROR;
|
result = FS_ERROR_MEDIA_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -222,12 +233,13 @@ FSError FSWrapper::FSOpenFileWrapper(const char *path, const char *mode, FSFileH
|
|||||||
auto fileHandle = getNewFileHandle();
|
auto fileHandle = getNewFileHandle();
|
||||||
if (fileHandle) {
|
if (fileHandle) {
|
||||||
std::lock_guard<std::mutex> lock(openFilesMutex);
|
std::lock_guard<std::mutex> lock(openFilesMutex);
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Opened %s (as %s) mode %s, fd %d (%08X)", getName().c_str(), path, newPath.c_str(), mode, fd, handle);
|
|
||||||
|
|
||||||
fileHandle->handle = (((uint32_t) fileHandle.get()) & 0x0FFFFFFF) | 0x30000000;
|
fileHandle->handle = (((uint32_t) fileHandle.get()) & 0x0FFFFFFF) | 0x30000000;
|
||||||
*handle = fileHandle->handle;
|
*handle = fileHandle->handle;
|
||||||
fileHandle->fd = fd;
|
fileHandle->fd = fd;
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("[%s] Opened %s (as %s) mode %s (%08X), fd %d (%08X)", getName().c_str(), path, newPath.c_str(), mode, _mode, fd, fileHandle->handle);
|
||||||
|
|
||||||
openFiles.push_back(fileHandle);
|
openFiles.push_back(fileHandle);
|
||||||
|
|
||||||
OSMemoryBarrier();
|
OSMemoryBarrier();
|
||||||
|
Loading…
Reference in New Issue
Block a user