mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-12-18 07:51:54 +01:00
branches: Updating LibFAT to 1.0.13
This commit is contained in:
parent
0cd2573062
commit
1fed6e83f2
@ -6,7 +6,7 @@ export TOPDIR := $(CURDIR)
|
||||
|
||||
export LIBFAT_MAJOR := 1
|
||||
export LIBFAT_MINOR := 0
|
||||
export LIBFAT_PATCH := 10
|
||||
export LIBFAT_PATCH := 13
|
||||
|
||||
export VERSTRING := $(LIBFAT_MAJOR).$(LIBFAT_MINOR).$(LIBFAT_PATCH)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
fat.h
|
||||
Simple functionality for startup, mounting and unmounting of FAT-based devices.
|
||||
|
||||
Copyright (c) 2006 - 2009
|
||||
Copyright (c) 2006 - 2012
|
||||
Michael "Chishm" Chisholm
|
||||
Dave "WinterMute" Murphy
|
||||
|
||||
@ -36,6 +36,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "libfatversion.h"
|
||||
|
||||
// When compiling for NDS, make sure NDS is defined
|
||||
#ifndef NDS
|
||||
#if defined ARM9 || defined ARM7
|
||||
@ -49,9 +51,9 @@ extern "C" {
|
||||
# include <ogc/disc_io.h>
|
||||
#else
|
||||
# ifdef NDS
|
||||
# include "nds/disc_io.h"
|
||||
# include <nds/disc_io.h>
|
||||
# else
|
||||
# include "disc_io.h"
|
||||
# include <disc_io.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -97,6 +99,22 @@ Get Volume Label
|
||||
*/
|
||||
extern void fatGetVolumeLabel (const char* name, char *label);
|
||||
|
||||
// File attributes
|
||||
#define ATTR_ARCHIVE 0x20 // Archive
|
||||
#define ATTR_DIRECTORY 0x10 // Directory
|
||||
#define ATTR_VOLUME 0x08 // Volume
|
||||
#define ATTR_SYSTEM 0x04 // System
|
||||
#define ATTR_HIDDEN 0x02 // Hidden
|
||||
#define ATTR_READONLY 0x01 // Read only
|
||||
|
||||
/*
|
||||
Methods to modify DOS File Attributes
|
||||
*/
|
||||
int FAT_getAttr(const char *file);
|
||||
int FAT_setAttr(const char *file, int attr );
|
||||
|
||||
#define LIBFAT_FEOS_MULTICWD
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
#define _LIBFAT_MAJOR_ 1
|
||||
#define _LIBFAT_MINOR_ 0
|
||||
#define _LIBFAT_PATCH_ 10
|
||||
#define _LIBFAT_PATCH_ 13
|
||||
|
||||
#define _LIBFAT_STRING "libFAT Release 1.0.10"
|
||||
#define _LIBFAT_STRING "libFAT Release 1.0.13"
|
||||
|
||||
#endif // __LIBFATVERSION_H__
|
||||
|
@ -1 +1 @@
|
||||
<Project name="libfat"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="source" path="source\"><File path="bit_ops.h"></File><File path="cache.c"></File><File path="cache.h"></File><File path="common.h"></File><File path="directory.c"></File><File path="directory.h"></File><File path="disc.c"></File><File path="disc.h"></File><File path="fatdir.c"></File><File path="fatdir.h"></File><File path="fatfile.c"></File><File path="fatfile.h"></File><File path="fatfile_frag.c"></File><File path="fatfile_frag.h"></File><File path="filetime.c"></File><File path="filetime.h"></File><File path="file_allocation_table.c"></File><File path="file_allocation_table.h"></File><File path="libfat.c"></File><File path="lock.c"></File><File path="lock.h"></File><File path="mem_allocate.h"></File><File path="partition.c"></File><File path="partition.h"></File></MagicFolder><Folder name="nds"><Folder name="include"><File path="nds\include\fat.h"></File><File path="nds\include\nitrofs.h"></File></Folder><Folder name="source"><File path="nds\source\nitrofs.c"></File></Folder><File path="nds\Makefile"></File></Folder><Folder name="libogc"><Folder name="include"><File path="libogc\include\fat.h"></File></Folder><File path="libogc\Makefile"></File></Folder><Folder name="gba"><Folder name="include"><File path="gba\include\fat.h"></File></Folder><File path="gba\Makefile"></File></Folder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"><File path="fat.h"></File><File path="libfatversion.h"></File></MagicFolder><File path="Makefile"></File></Project>
|
||||
<Project name="libfat"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.h" name="source" path="source\"><File path="bit_ops.h"></File><File path="cache.c"></File><File path="cache.h"></File><File path="common.h"></File><File path="directory.c"></File><File path="directory.h"></File><File path="disc.c"></File><File path="disc.h"></File><File path="fatdir.c"></File><File path="fatdir.h"></File><File path="fatfile.c"></File><File path="fatfile.h"></File><File path="fatfile_frag.c"></File><File path="fatfile_frag.h"></File><File path="filetime.c"></File><File path="filetime.h"></File><File path="file_allocation_table.c"></File><File path="file_allocation_table.h"></File><File path="libfat.c"></File><File path="lock.c"></File><File path="lock.h"></File><File path="mem2.h"></File><File path="mem_allocate.h"></File><File path="partition.c"></File><File path="partition.h"></File></MagicFolder><Folder name="libogc"><Folder name="include"><File path="libogc\include\fat.h"></File></Folder><File path="libogc\Makefile"></File></Folder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"><File path="fat.h"></File><File path="libfatversion.h"></File></MagicFolder><File path="Makefile"></File></Project>
|
@ -1 +1 @@
|
||||
<pd><ViewState><e p="libfat\include" x="false"></e><e p="libfat\libogc" x="false"></e><e p="libfat\nds" x="false"></e><e p="libfat" x="true"></e><e p="libfat\gba" x="false"></e><e p="libfat\source" x="false"></e></ViewState></pd>
|
||||
<pd><ViewState><e p="libfat" x="true"></e><e p="libfat\include" x="false"></e><e p="libfat\libogc" x="false"></e><e p="libfat\source" x="false"></e></ViewState></pd>
|
@ -30,7 +30,7 @@ LIBDIR := $(TOPDIR)/libogc/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
ASFLAGS := -g
|
||||
@ -96,17 +96,19 @@ $(BUILD):
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr wii_debug wii_release cube_debug cube_release $(LIBDIR)
|
||||
@rm -fr wii_debug wii_release cube_debug cube_release $(LIBDIR) include
|
||||
|
||||
all: $(CUBEBIN)
|
||||
|
||||
dist-bin:
|
||||
@mkdir -p include
|
||||
@cp $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h include
|
||||
@tar --exclude=.svn --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(VERSTRING)/libfat-ogc-$(VERSTRING).tar.bz2 include lib
|
||||
|
||||
install:
|
||||
cp lib/wii/libfat.a $(DEVKITPRO)/libogc/lib/wii
|
||||
cp lib/cube/libfat.a $(DEVKITPRO)/libogc/lib/cube
|
||||
cp include/fat.h $(DEVKITPRO)/libogc/include
|
||||
@cp lib/wii/libfat.a $(DEVKITPRO)/libogc/lib/wii
|
||||
@cp lib/cube/libfat.a $(DEVKITPRO)/libogc/lib/cube
|
||||
@cp $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h $(DEVKITPRO)/libogc/include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
@ -125,7 +125,7 @@ static size_t _FAT_directory_mbstoucs2 (ucs2_t* dst, const char* src, size_t len
|
||||
int bytes;
|
||||
size_t count = 0;
|
||||
|
||||
while (count < len-1 && src != '\0') {
|
||||
while (count < len-1 && *src != '\0') {
|
||||
bytes = mbrtowc (&tempChar, src, MB_CUR_MAX, &ps);
|
||||
if (bytes > 0) {
|
||||
*dst = (ucs2_t)tempChar;
|
||||
@ -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,30 +580,39 @@ bool _FAT_directory_entryFromPath (PARTITION* partition, DIR_ENTRY* entry, const
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look for the directory within the path
|
||||
foundFile = _FAT_directory_getFirstEntry (partition, entry, dirCluster);
|
||||
// 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);
|
||||
|
||||
while (foundFile && !found && !notFound) { // It hasn't already found the file
|
||||
// Check if the filename matches
|
||||
if ((dirnameLength == strnlen(entry->filename, MAX_FILENAME_LENGTH))
|
||||
&& (_FAT_directory_mbsncasecmp(pathPosition, entry->filename, dirnameLength) == 0)) {
|
||||
found = true;
|
||||
}
|
||||
while (foundFile && !found && !notFound) { // It hasn't already found the file
|
||||
// Check if the filename matches
|
||||
if ((dirnameLength == strnlen(entry->filename, MAX_FILENAME_LENGTH))
|
||||
&& (_FAT_directory_mbsncasecmp(pathPosition, entry->filename, dirnameLength) == 0)) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
// Check if the alias matches
|
||||
_FAT_directory_entryGetAlias (entry->entryData, alias);
|
||||
if ((dirnameLength == strnlen(alias, MAX_ALIAS_LENGTH))
|
||||
&& (strncasecmp(pathPosition, alias, dirnameLength) == 0)) {
|
||||
found = true;
|
||||
}
|
||||
// Check if the alias matches
|
||||
_FAT_directory_entryGetAlias (entry->entryData, alias);
|
||||
if ((dirnameLength == strnlen(alias, MAX_ALIAS_LENGTH))
|
||||
&& (strncasecmp(pathPosition, alias, dirnameLength) == 0)) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found && !(entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) && (nextPathPosition != NULL)) {
|
||||
// Make sure that we aren't trying to follow a file instead of a directory in the path
|
||||
found = false;
|
||||
}
|
||||
if (found && !(entry->entryData[DIR_ENTRY_attributes] & ATTRIB_DIR) && (nextPathPosition != NULL)) {
|
||||
// Make sure that we aren't trying to follow a file instead of a directory in the path
|
||||
found = false;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
foundFile = _FAT_directory_getNextEntry (partition, entry);
|
||||
if (!found) {
|
||||
foundFile = _FAT_directory_getNextEntry (partition, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
@ -69,9 +69,54 @@ int FAT_getAttr(const char *file) {
|
||||
}
|
||||
|
||||
int FAT_setAttr(const char *file, int attr) {
|
||||
DIR_ENTRY dirEntry;
|
||||
if (!_FAT_findEntry(file,&dirEntry)) return -1;
|
||||
|
||||
// Defines...
|
||||
DIR_ENTRY_POSITION entryEnd;
|
||||
PARTITION *partition = NULL;
|
||||
DIR_ENTRY* dirEntry = NULL;
|
||||
|
||||
// Get Partition
|
||||
partition = _FAT_partition_getPartitionFromPath( file );
|
||||
|
||||
// Check Partition
|
||||
if( !partition )
|
||||
return -1;
|
||||
|
||||
// Move the path pointer to the start of the actual path
|
||||
if (strchr (file, ':') != NULL)
|
||||
file = strchr (file, ':') + 1;
|
||||
if (strchr (file, ':') != NULL)
|
||||
return -1;
|
||||
|
||||
// Get DIR_ENTRY
|
||||
if( !_FAT_directory_entryFromPath (partition, dirEntry, file, NULL) )
|
||||
return -1;
|
||||
|
||||
// Get Entry-End
|
||||
entryEnd = dirEntry->dataEnd;
|
||||
|
||||
// Lock Partition
|
||||
_FAT_lock(&partition->lock);
|
||||
|
||||
|
||||
// Write Data
|
||||
_FAT_cache_writePartialSector (
|
||||
partition->cache // Cache to write
|
||||
, &attr // Value to be written
|
||||
, _FAT_fat_clusterToSector( partition , entryEnd.cluster ) + entryEnd.sector // cluster
|
||||
, entryEnd.offset * DIR_ENTRY_DATA_SIZE + DIR_ENTRY_attributes // offset
|
||||
, 1 // Size in bytes
|
||||
);
|
||||
|
||||
// Flush any sectors in the disc cache
|
||||
if ( !_FAT_cache_flush( partition->cache ) ) {
|
||||
_FAT_unlock(&partition->lock); // Unlock Partition
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Unlock Partition
|
||||
_FAT_unlock(&partition->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "partition.h"
|
||||
@ -82,7 +83,8 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec
|
||||
return false;
|
||||
|
||||
char devname[10];
|
||||
sprintf(devname, "%s:", name);
|
||||
strcpy(devname, name);
|
||||
strcat(devname, ":");
|
||||
if(FindDevice(devname) >= 0)
|
||||
return true;
|
||||
|
||||
|
@ -429,3 +429,13 @@ void _FAT_partition_writeFSinfo(PARTITION * partition)
|
||||
_FAT_disc_writeSectors (partition->disc, partition->fsInfoSector, 1, 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user