fix FAT_setAttr

This commit is contained in:
Dave Murphy 2014-12-15 02:21:51 +00:00
parent d468306a18
commit b42fdc447c

View File

@ -48,6 +48,10 @@
bool _FAT_findEntry(const char *path, DIR_ENTRY *dirEntry) { bool _FAT_findEntry(const char *path, DIR_ENTRY *dirEntry) {
PARTITION *partition = _FAT_partition_getPartitionFromPath(path); PARTITION *partition = _FAT_partition_getPartitionFromPath(path);
// Check Partition
if( !partition )
return false;
// Move the path pointer to the start of the actual path // Move the path pointer to the start of the actual path
if (strchr (path, ':') != NULL) { if (strchr (path, ':') != NULL) {
path = strchr (path, ':') + 1; path = strchr (path, ':') + 1;
@ -58,13 +62,13 @@ bool _FAT_findEntry(const char *path, DIR_ENTRY *dirEntry) {
// Search for the file on the disc // Search for the file on the disc
return _FAT_directory_entryFromPath (partition, dirEntry, path, NULL); return _FAT_directory_entryFromPath (partition, dirEntry, path, NULL);
} }
int FAT_getAttr(const char *file) { int FAT_getAttr(const char *file) {
DIR_ENTRY dirEntry; DIR_ENTRY dirEntry;
if (!_FAT_findEntry(file,&dirEntry)) return -1; if (!_FAT_findEntry(file,&dirEntry)) return -1;
return dirEntry.entryData[DIR_ENTRY_attributes]; return dirEntry.entryData[DIR_ENTRY_attributes];
} }
@ -73,7 +77,7 @@ int FAT_setAttr(const char *file, int attr) {
// Defines... // Defines...
DIR_ENTRY_POSITION entryEnd; DIR_ENTRY_POSITION entryEnd;
PARTITION *partition = NULL; PARTITION *partition = NULL;
DIR_ENTRY* dirEntry = NULL; DIR_ENTRY dirEntry;
// Get Partition // Get Partition
partition = _FAT_partition_getPartitionFromPath( file ); partition = _FAT_partition_getPartitionFromPath( file );
@ -81,7 +85,7 @@ int FAT_setAttr(const char *file, int attr) {
// Check Partition // Check Partition
if( !partition ) if( !partition )
return -1; return -1;
// Move the path pointer to the start of the actual path // Move the path pointer to the start of the actual path
if (strchr (file, ':') != NULL) if (strchr (file, ':') != NULL)
file = strchr (file, ':') + 1; file = strchr (file, ':') + 1;
@ -89,11 +93,11 @@ int FAT_setAttr(const char *file, int attr) {
return -1; return -1;
// Get DIR_ENTRY // Get DIR_ENTRY
if( !_FAT_directory_entryFromPath (partition, dirEntry, file, NULL) ) if( !_FAT_directory_entryFromPath (partition, &dirEntry, file, NULL) )
return -1; return -1;
// Get Entry-End // Get Entry-End
entryEnd = dirEntry->dataEnd; entryEnd = dirEntry.dataEnd;
// Lock Partition // Lock Partition
_FAT_lock(&partition->lock); _FAT_lock(&partition->lock);