Skip to content

Commit

Permalink
feat: Adds mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hui committed Sep 27, 2023
1 parent 4d6f328 commit f641578
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/fileCLI/fileCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FileCLI::menu_t FileCLI::fsExplorerMenu[] =
{'d', &FileCLI::dumpBase85},
{'h', &FileCLI::dumpHex},
{'l', &FileCLI::list_dir},
{'m', &FileCLI::mkdir},
{'p', &FileCLI::print_dir},
{'q', &FileCLI::exit},
{'r', &FileCLI::deleteFile},
Expand All @@ -37,6 +38,7 @@ void FileCLI::print_help(void)
SF_OSAL_printf("%c\t%s" __NL__, 'p', "Print Working Directory");
SF_OSAL_printf("%c\t%s" __NL__, 'l', "List Directory");
SF_OSAL_printf("%c\t%s" __NL__, 'c', "Change Directory");
SF_OSAL_printf("%c\t%s" __NL__, 'm', "Make Directory");
SF_OSAL_printf("%c\t%s" __NL__, 'r', "Remove File/Directory");
SF_OSAL_printf("%c\t%s" __NL__, 'd', "Base85/64 Dump");
SF_OSAL_printf("%c\t%s" __NL__, 'h', "Hex Dump");
Expand Down Expand Up @@ -332,7 +334,7 @@ void hexdump(int fp, size_t file_len)
}
SF_OSAL_printf(" |%s|" __NL__, (const char*)byte_buffer);
}
SF_OSAL_printf("0x%08x" __NL__, file_idx);
SF_OSAL_printf("%08x" __NL__, file_idx);

}

Expand Down Expand Up @@ -483,3 +485,16 @@ void FileCLI::dumpBase85(void)

close(fp);
}

void FileCLI::mkdir(void)
{
char input_buffer[FILE_CLI_INPUT_BUFFER_LEN];
int result;

SF_OSAL_printf("Enter new directory name: ");
getline(input_buffer, FILE_CLI_INPUT_BUFFER_LEN);

result = ::mkdir(input_buffer, 0777);
SF_OSAL_printf("Returned %d" __NL__, result);
return;
}
6 changes: 6 additions & 0 deletions src/fileCLI/fileCLI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ class FileCLI{
*/
void print_help(void);

/**
* @brief Creates a new directory
*
*/
void mkdir(void);

int run = 1;
DIR* dir_stack[FILE_CLI_MAX_DIR_DEPTH];
char path_stack[FILE_CLI_MAX_DIR_DEPTH][NAME_MAX];
Expand Down

0 comments on commit f641578

Please sign in to comment.