Merge branch 'master' of ssh://devkitpro.git.sourceforge.net/gitroot/devkitpro/libfat

This commit is contained in:
Dave Murphy 2012-12-16 00:23:23 +00:00
commit f20e5200a7
3 changed files with 42 additions and 27 deletions

View File

@ -113,6 +113,7 @@ Methods to modify DOS File Attributes
int FAT_getAttr(const char *file); int FAT_getAttr(const char *file);
int FAT_setAttr(const char *file, int attr ); int FAT_setAttr(const char *file, int attr );
#define LIBFAT_FEOS_MULTICWD
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -566,13 +566,6 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
dirCluster = partition->cwdCluster; 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) { while (!found && !notFound) {
// Get the name of the next required subdirectory within the path // Get the name of the next required subdirectory within the path
nextPathPosition = strchr (pathPosition, DIR_SEPARATOR); nextPathPosition = strchr (pathPosition, DIR_SEPARATOR);
@ -587,6 +580,14 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
return false; 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 // Look for the directory within the path
foundFile = _FAT_directory_getFirstEntry (partition, entry, dirCluster); 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); foundFile = _FAT_directory_getNextEntry (partition, entry);
} }
} }
}
if (!foundFile) { if (!foundFile) {
// Check that the search didn't get to the end of the directory // 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; found = true;
} else if (entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) { } else if (entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) {
dirCluster = _FAT_directory_entryGetCluster (partition, entry->entryData); dirCluster = _FAT_directory_entryGetCluster (partition, entry->entryData);
if (dirCluster == CLUSTER_ROOT)
dirCluster = partition->rootDirCluster;
pathPosition = nextPathPosition; pathPosition = nextPathPosition;
// Consume separator(s) // Consume separator(s)
while (pathPosition[0] == DIR_SEPARATOR) { while (pathPosition[0] == DIR_SEPARATOR) {

View File

@ -429,3 +429,13 @@ void _FAT_partition_writeFSinfo(PARTITION * partition)
_FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer); _FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, sectorBuffer);
_FAT_mem_free(sectorBuffer); _FAT_mem_free(sectorBuffer);
} }
uint32_t* _FAT_getCwdClusterPtr(const char* name) {
PARTITION *partition = _FAT_partition_getPartitionFromPath(name);
if (!partition) {
return NULL;
}
return &partition->cwdCluster;
}