Refactor platform apis comments and cleanup a bit

This commit is contained in:
Wojtek Figat
2024-09-24 18:29:30 +02:00
parent da203352fd
commit 207c6a0cb5
21 changed files with 205 additions and 224 deletions

View File

@@ -167,18 +167,18 @@ bool AndroidFileSystem::DirectoryGetFiles(Array<String>& results, const String&
return getFilesFromDirectoryAll(results, pathANSI.Get(), searchPatternANSI.Get());
}
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& path)
{
size_t pathLength;
struct stat statPath, statEntry;
struct dirent* entry;
const StringAsANSI<> pathANSI(*directory, directory.Length());
const char* path = pathANSI.Get();
const StringAsANSI<> pathANSI(*path, path.Length());
const char* pathStr = pathANSI.Get();
// Stat for the path
stat(path, &statPath);
stat(pathStr, &statPath);
// If path does not exists or is not dir - exit with status -1
// If path does not exist or is not dir - exit with status -1
if (S_ISDIR(statPath.st_mode) == 0)
{
// Is not directory
@@ -186,7 +186,7 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
}
// If not possible to read the directory for this user
DIR* dir = opendir(path);
DIR* dir = opendir(pathStr);
if (dir == nullptr)
{
// Cannot open directory
@@ -194,7 +194,7 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
}
// The length of the path
pathLength = strlen(path);
pathLength = strlen(pathStr);
// Iteration through entries in the directory
while ((entry = readdir(dir)) != nullptr)
@@ -204,20 +204,20 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
continue;
// Determinate a full path of an entry
char full_path[256];
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
strcpy(full_path, path);
strcat(full_path, "/");
strcat(full_path, entry->d_name);
char fullPath[256];
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
strcpy(fullPath, pathStr);
strcat(fullPath, "/");
strcat(fullPath, entry->d_name);
// Stat for the entry
stat(full_path, &statEntry);
stat(fullPath, &statEntry);
// Check for directory
if (S_ISDIR(statEntry.st_mode) != 0)
{
// Add directory
results.Add(String(full_path));
results.Add(String(fullPath));
}
}