customizemii/CustomizeMiiInstaller_Source/source/fat.c
leathl abb6b9927d Implemented CustomizeMiiInstaler, Project Cleanup, etc...
git-svn-id: svn://localhost/Users/andi/Downloads/code/trunk@26 eddbe33b-e435-4246-ac25-f5eb65f9a13c
2010-01-12 17:03:46 +00:00

58 lines
964 B
C

#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include "fat.h"
s32 Fat_Mount(fatDevice *dev)
{
s32 ret;
/* Initialize interface */
ret = dev->interface->startup();
if (!ret)
return -1;
/* Mount device */
ret = fatMountSimple(dev->mount, dev->interface);
if (!ret)
return -1;
return 0;
}
void Fat_Unmount(fatDevice *dev)
{
/* Unmount device */
fatUnmount(dev->mount);
/* Shutdown interface */
dev->interface->shutdown();
}
char *Fat_ToFilename(const char *filename)
{
static char buffer[128];
u32 cnt, idx, len;
/* Clear buffer */
memset(buffer, 0, sizeof(buffer));
/* Get filename length */
len = strlen(filename);
for (cnt = idx = 0; idx < len; idx++) {
char c = filename[idx];
/* Valid characters */
if ( (c >= '#' && c <= ')') || (c >= '-' && c <= '.') ||
(c >= '0' && c <= '9') || (c >= 'A' && c <= 'z') ||
(c >= 'a' && c <= 'z') || (c == '!') )
buffer[cnt++] = c;
}
return buffer;
}