mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-22 01:49:17 +01:00
fix finding . and .. entries for root directory
This commit is contained in:
parent
27d818367e
commit
2aaf2cfd6f
@ -566,13 +566,6 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
|
||||
dirCluster = partition->cwdCluster;
|
||||
}
|
||||
|
||||
// If the path is only specifying a directory in the form "."
|
||||
// and this is the root directory, return it
|
||||
if ((dirCluster == partition->rootDirCluster) && (strcmp(".", pathPosition) == 0)) {
|
||||
_FAT_directory_getRootEntry (partition, entry);
|
||||
found = true;
|
||||
}
|
||||
|
||||
while (!found && !notFound) {
|
||||
// Get the name of the next required subdirectory within the path
|
||||
nextPathPosition = strchr (pathPosition, DIR_SEPARATOR);
|
||||
@ -587,6 +580,14 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for "." or ".." when the dirCluster is root cluster
|
||||
// These entries do not exist, so we must fake it
|
||||
if ((dirCluster == partition->rootDirCluster)
|
||||
&& ((strncmp(".", pathPosition, dirnameLength) == 0)
|
||||
|| (strncmp("..", pathPosition, dirnameLength) == 0))) {
|
||||
foundFile = true;
|
||||
_FAT_directory_getRootEntry(partition, entry);
|
||||
} else {
|
||||
// Look for the directory within the path
|
||||
foundFile = _FAT_directory_getFirstEntry (partition, entry, dirCluster);
|
||||
|
||||
@ -613,6 +614,7 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
|
||||
foundFile = _FAT_directory_getNextEntry (partition, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundFile) {
|
||||
// Check that the search didn't get to the end of the directory
|
||||
@ -623,6 +625,8 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
|
||||
found = true;
|
||||
} else if (entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) {
|
||||
dirCluster = _FAT_directory_entryGetCluster (partition, entry->entryData);
|
||||
if (dirCluster == CLUSTER_ROOT)
|
||||
dirCluster = partition->rootDirCluster;
|
||||
pathPosition = nextPathPosition;
|
||||
// Consume separator(s)
|
||||
while (pathPosition[0] == DIR_SEPARATOR) {
|
||||
|
Loading…
Reference in New Issue
Block a user