Skip to content

Commit

Permalink
create new files (#432)
Browse files Browse the repository at this point in the history
* introduce new file creation, remove new folder from main menu

* aesthetics
  • Loading branch information
abertschi authored and TheOfficialFloW committed Jun 16, 2018
1 parent 3202651 commit 4c09085
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 65 deletions.
2 changes: 2 additions & 0 deletions language.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ void loadLanguage(int id) {
LANGUAGE_ENTRY(PASTE),
LANGUAGE_ENTRY(DELETE),
LANGUAGE_ENTRY(RENAME),
LANGUAGE_ENTRY(NEW),
LANGUAGE_ENTRY(NEW_FILE),
LANGUAGE_ENTRY(NEW_FOLDER),
LANGUAGE_ENTRY(PROPERTIES),
LANGUAGE_ENTRY(SEND),
Expand Down
2 changes: 2 additions & 0 deletions language.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ enum LanguageContainer {
PASTE,
DELETE,
RENAME,
NEW,
NEW_FILE,
NEW_FOLDER,
PROPERTIES,
SEND,
Expand Down
37 changes: 34 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ static int dialogSteps() {

break;
}

case DIALOG_STEP_NEW_FOLDER:
{
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
Expand Down Expand Up @@ -922,7 +922,38 @@ static int dialogSteps() {

break;
}


case DIALOG_STEP_NEW_FILE:
{
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
char *name = (char *)getImeDialogInputTextUTF8();
if (name[0] == '\0') {
setDialogStep(DIALOG_STEP_NONE);
} else {
char path[MAX_PATH_LENGTH];
snprintf(path, MAX_PATH_LENGTH - 1, "%s%s", file_list.path, name);

SceUID fd = sceIoOpen(path, SCE_O_WRONLY | SCE_O_CREAT, 0777);
if (fd < 0) {
errorDialog(fd);
} else {
sceIoClose(fd);

// Focus
strcpy(focus_name, name);
addEndSlash(focus_name);

refresh = REFRESH_MODE_SETFOCUS;
setDialogStep(DIALOG_STEP_NONE);
refreshFileList();
}
}
} else if (ime_result == IME_DIALOG_RESULT_CANCELED) {
setDialogStep(DIALOG_STEP_NONE);
}
break;
}

case DIALOG_STEP_COMPRESS_NAME:
{
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
Expand All @@ -941,7 +972,7 @@ static int dialogSteps() {

break;
}

case DIALOG_STEP_COMPRESS_LEVEL:
{
if (ime_result == IME_DIALOG_RESULT_FINISHED) {
Expand Down
2 changes: 2 additions & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ enum DialogSteps {
DIALOG_STEP_USB,

DIALOG_STEP_RENAME,

DIALOG_STEP_NEW_FILE,
DIALOG_STEP_NEW_FOLDER,

DIALOG_STEP_COPYING,
Expand Down
Loading

0 comments on commit 4c09085

Please sign in to comment.