Added ability to create folders

This commit is contained in:
d0k3 2016-03-14 23:58:25 +01:00
parent 7fea4e81b0
commit 1debcaeecc
3 changed files with 16 additions and 1 deletions

View File

@ -298,6 +298,12 @@ bool PathRename(const char* path, const char* newname) {
return (f_rename(path, npath) == FR_OK); return (f_rename(path, npath) == FR_OK);
} }
bool DirCreate(const char* cpath, const char* dirname) {
char npath[256]; // 256 is the maximum length of a full path
snprintf(npath, 255, "%s/%s", cpath, dirname);
return (f_mkdir(npath) == FR_OK);
}
void CreateScreenshot() { void CreateScreenshot() {
const u8 bmp_header[54] = { const u8 bmp_header[54] = {
0x42, 0x4D, 0x36, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x42, 0x4D, 0x36, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,

View File

@ -52,6 +52,9 @@ bool PathDelete(const char* path);
/** Rename file / folder in path to new name **/ /** Rename file / folder in path to new name **/
bool PathRename(const char* path, const char* newname); bool PathRename(const char* path, const char* newname);
/** Create a new directory in cpath **/
bool DirCreate(const char* cpath, const char* dirname);
/** Create a screenshot of the current framebuffer **/ /** Create a screenshot of the current framebuffer **/
void CreateScreenshot(); void CreateScreenshot();

View File

@ -283,7 +283,13 @@ u32 GodMode() {
} else if (pad_state & BUTTON_Y) { // create a folder } else if (pad_state & BUTTON_Y) { // create a folder
char dirname[256]; char dirname[256];
snprintf(dirname, 255, "newdir"); snprintf(dirname, 255, "newdir");
ShowInputPrompt(dirname, 256, "Create a new folder here?\nEnter name below."); if (ShowInputPrompt(dirname, 256, "Create a new folder here?\nEnter name below.")) {
if (!DirCreate(current_path, dirname)) {
char namestr[20+1];
TruncateString(namestr, current_dir->entry[cursor].name, 20, 12);
ShowPrompt(false, "Failed creating dir:\n%s", namestr);
} else GetDirContents(current_dir, current_path);
}
} }
} }