Fixes for unix directories list with path filter
This commit is contained in:
@@ -44,7 +44,6 @@ namespace
|
|||||||
bool DeleteUnixPathTree(const char* path)
|
bool DeleteUnixPathTree(const char* path)
|
||||||
{
|
{
|
||||||
size_t pathLength;
|
size_t pathLength;
|
||||||
DIR* dir;
|
|
||||||
struct stat statPath, statEntry;
|
struct stat statPath, statEntry;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
|
|
||||||
@@ -59,7 +58,8 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not possible to read the directory for this user
|
// If not possible to read the directory for this user
|
||||||
if ((dir = opendir(path)) == nullptr)
|
DIR* dir = dir = opendir(path);
|
||||||
|
if (dir == nullptr)
|
||||||
{
|
{
|
||||||
// Cannot open directory
|
// Cannot open directory
|
||||||
return true;
|
return true;
|
||||||
@@ -77,7 +77,7 @@ namespace
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
@@ -168,7 +168,6 @@ bool AndroidFileSystem::DirectoryGetFiles(Array<String>& results, const String&
|
|||||||
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String& directory)
|
||||||
{
|
{
|
||||||
size_t pathLength;
|
size_t pathLength;
|
||||||
DIR* dir;
|
|
||||||
struct stat statPath, statEntry;
|
struct stat statPath, statEntry;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
const StringAsANSI<> pathANSI(*directory, directory.Length());
|
const StringAsANSI<> pathANSI(*directory, directory.Length());
|
||||||
@@ -185,7 +184,8 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not possible to read the directory for this user
|
// If not possible to read the directory for this user
|
||||||
if ((dir = opendir(path)) == nullptr)
|
DIR* dir = opendir(path);
|
||||||
|
if (dir == nullptr)
|
||||||
{
|
{
|
||||||
// Cannot open directory
|
// Cannot open directory
|
||||||
return true;
|
return true;
|
||||||
@@ -203,7 +203,7 @@ bool AndroidFileSystem::GetChildDirectories(Array<String>& results, const String
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
@@ -381,7 +381,6 @@ out_error:
|
|||||||
bool AndroidFileSystem::getFilesFromDirectoryTop(Array<String>& results, const char* path, const char* searchPattern)
|
bool AndroidFileSystem::getFilesFromDirectoryTop(Array<String>& results, const char* path, const char* searchPattern)
|
||||||
{
|
{
|
||||||
size_t pathLength;
|
size_t pathLength;
|
||||||
DIR* dir;
|
|
||||||
struct stat statPath, statEntry;
|
struct stat statPath, statEntry;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
|
|
||||||
@@ -396,7 +395,8 @@ bool AndroidFileSystem::getFilesFromDirectoryTop(Array<String>& results, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not possible to read the directory for this user
|
// If not possible to read the directory for this user
|
||||||
if ((dir = opendir(path)) == nullptr)
|
DIR* dir = opendir(path);
|
||||||
|
if (dir == nullptr)
|
||||||
{
|
{
|
||||||
// Cannot open directory
|
// Cannot open directory
|
||||||
return true;
|
return true;
|
||||||
@@ -432,7 +432,7 @@ bool AndroidFileSystem::getFilesFromDirectoryTop(Array<String>& results, const c
|
|||||||
{
|
{
|
||||||
// All files
|
// All files
|
||||||
}
|
}
|
||||||
else if (searchPattern[0] == '*' && searchPatternLength < fullPathLength && StringUtils::Compare(fullPath + fullPathLength - searchPatternLength, searchPattern + 1) == 0)
|
else if (searchPattern[0] == '*' && searchPatternLength < fullPathLength && StringUtils::Compare(fullPath + fullPathLength - searchPatternLength + 1, searchPattern + 1) == 0)
|
||||||
{
|
{
|
||||||
// Path ending
|
// Path ending
|
||||||
}
|
}
|
||||||
@@ -458,7 +458,6 @@ bool AndroidFileSystem::getFilesFromDirectoryAll(Array<String>& results, const c
|
|||||||
getFilesFromDirectoryTop(results, path, searchPattern);
|
getFilesFromDirectoryTop(results, path, searchPattern);
|
||||||
|
|
||||||
size_t pathLength;
|
size_t pathLength;
|
||||||
DIR* dir;
|
|
||||||
struct stat statPath, statEntry;
|
struct stat statPath, statEntry;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
|
|
||||||
@@ -473,7 +472,8 @@ bool AndroidFileSystem::getFilesFromDirectoryAll(Array<String>& results, const c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not possible to read the directory for this user
|
// If not possible to read the directory for this user
|
||||||
if ((dir = opendir(path)) == nullptr)
|
DIR* dir = opendir(path);
|
||||||
|
if (dir == nullptr)
|
||||||
{
|
{
|
||||||
// Cannot open directory
|
// Cannot open directory
|
||||||
return true;
|
return true;
|
||||||
@@ -491,7 +491,7 @@ bool AndroidFileSystem::getFilesFromDirectoryAll(Array<String>& results, const c
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ bool DeleteUnixPathTree(const char* path)
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
@@ -211,7 +211,7 @@ bool LinuxFileSystem::GetChildDirectories(Array<String>& results, const String&
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
@@ -373,7 +373,6 @@ out_error:
|
|||||||
bool LinuxFileSystem::getFilesFromDirectoryTop(Array<String>& results, const char* path, const char* searchPattern)
|
bool LinuxFileSystem::getFilesFromDirectoryTop(Array<String>& results, const char* path, const char* searchPattern)
|
||||||
{
|
{
|
||||||
size_t pathLength;
|
size_t pathLength;
|
||||||
DIR* dir;
|
|
||||||
struct stat statPath, statEntry;
|
struct stat statPath, statEntry;
|
||||||
struct dirent* entry;
|
struct dirent* entry;
|
||||||
|
|
||||||
@@ -388,7 +387,8 @@ bool LinuxFileSystem::getFilesFromDirectoryTop(Array<String>& results, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not possible to read the directory for this user
|
// If not possible to read the directory for this user
|
||||||
if ((dir = opendir(path)) == NULL)
|
DIR* dir = opendir(path);
|
||||||
|
if (dir == NULL)
|
||||||
{
|
{
|
||||||
// Cannot open directory
|
// Cannot open directory
|
||||||
return true;
|
return true;
|
||||||
@@ -406,7 +406,7 @@ bool LinuxFileSystem::getFilesFromDirectoryTop(Array<String>& results, const cha
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char fullPath[256];
|
char fullPath[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(fullPath));
|
||||||
strcpy(fullPath, path);
|
strcpy(fullPath, path);
|
||||||
strcat(fullPath, "/");
|
strcat(fullPath, "/");
|
||||||
strcat(fullPath, entry->d_name);
|
strcat(fullPath, entry->d_name);
|
||||||
@@ -424,7 +424,7 @@ bool LinuxFileSystem::getFilesFromDirectoryTop(Array<String>& results, const cha
|
|||||||
{
|
{
|
||||||
// All files
|
// All files
|
||||||
}
|
}
|
||||||
else if (searchPattern[0] == '*' && searchPatternLength < fullPathLength && StringUtils::Compare(fullPath + fullPathLength - searchPatternLength, searchPattern + 1) == 0)
|
else if (searchPattern[0] == '*' && searchPatternLength < fullPathLength && StringUtils::Compare(fullPath + fullPathLength - searchPatternLength + 1, searchPattern + 1, searchPatternLength - 1) == 0)
|
||||||
{
|
{
|
||||||
// Path ending
|
// Path ending
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ bool LinuxFileSystem::getFilesFromDirectoryAll(Array<String>& results, const cha
|
|||||||
|
|
||||||
// Determinate a full path of an entry
|
// Determinate a full path of an entry
|
||||||
char full_path[256];
|
char full_path[256];
|
||||||
ASSERT(pathLength + strlen(entry->d_name) <= 255);
|
ASSERT(pathLength + strlen(entry->d_name) < ARRAY_COUNT(full_path));
|
||||||
strcpy(full_path, path);
|
strcpy(full_path, path);
|
||||||
strcat(full_path, "/");
|
strcat(full_path, "/");
|
||||||
strcat(full_path, entry->d_name);
|
strcat(full_path, entry->d_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user