mirror of
https://github.com/joel16/3DSident.git
synced 2024-11-23 11:39:43 +00:00
50 lines
795 B
C
50 lines
795 B
C
|
#include "fs.h"
|
||
|
|
||
|
void openSdArchive()
|
||
|
{
|
||
|
FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
|
||
|
}
|
||
|
|
||
|
void closeSdArchive()
|
||
|
{
|
||
|
FSUSER_CloseArchive(sdmcArchive);
|
||
|
}
|
||
|
|
||
|
int makeDir(const char *path)
|
||
|
{
|
||
|
if (!path)
|
||
|
return -1;
|
||
|
|
||
|
return mkdir(path, 0777);
|
||
|
}
|
||
|
|
||
|
bool fileExists(char *path)
|
||
|
{
|
||
|
FILE * temp = fopen(path, "r");
|
||
|
if(temp == NULL)
|
||
|
return false;
|
||
|
|
||
|
fclose(temp);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool dirExists(const char *path)
|
||
|
{
|
||
|
struct stat info;
|
||
|
|
||
|
if(stat( path, &info ) != 0)
|
||
|
return false;
|
||
|
else if(info.st_mode & S_IFDIR)
|
||
|
return true;
|
||
|
else
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool deleteFile(const char *path)
|
||
|
{
|
||
|
openSdArchive();
|
||
|
Result ret = FSUSER_DeleteFile(sdmcArchive, fsMakePath(PATH_ASCII, path));
|
||
|
closeSdArchive();
|
||
|
return ret == 0;
|
||
|
}
|