-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Hui
committed
Sep 11, 2023
1 parent
409c7c4
commit 82ca64c
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "fileCLI.hpp" | ||
|
||
#include "cli/conio.hpp" | ||
#include "cli/flog.hpp" | ||
#include "consts.hpp" | ||
|
||
#include <fcntl.h> | ||
|
||
#include "Particle.h" | ||
|
||
#include <sys/dirent.h> | ||
|
||
|
||
FileCLI::menu_t FileCLI::fsExplorerMenu[] = | ||
{ | ||
{'l', &FileCLI::list_dir}, | ||
{'\0', NULL} | ||
}; | ||
|
||
|
||
void FileCLI::execute(void) | ||
{ | ||
char input_buffer[FILE_CLI_INPUT_BUFFER_LEN]; | ||
menu_t* cmd; | ||
void (FileCLI::*fn)(void); | ||
|
||
this->run = 1; | ||
this->current_dir = opendir("/"); | ||
if(NULL == this->current_dir) | ||
{ | ||
FLOG_AddError(FLOG_FS_OPENDIR_FAIL, (uint32_t)this->current_dir); | ||
SF_OSAL_printf("Failed to open root" __NL__); | ||
return; | ||
} | ||
} | ||
|
||
void FileCLI::list_dir(void) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#ifndef __FILECLI_H__ | ||
#define __FILECLI_H__ | ||
|
||
#include <dirent.h> | ||
|
||
#include "Particle.h" | ||
|
||
#define FILE_CLI_INPUT_BUFFER_LEN 80 | ||
|
||
/** | ||
* @brief File CLI | ||
* | ||
* Provides a set of commands to interact with the local filesystem | ||
* | ||
*/ | ||
class FileCLI{ | ||
public: | ||
/** | ||
* @brief Creates a new FileCLI object | ||
* | ||
*/ | ||
FileCLI(void){}; | ||
/** | ||
* @brief Executes the File CLI | ||
* | ||
*/ | ||
void execute(void); | ||
/** | ||
* @brief Destructor | ||
* | ||
*/ | ||
~FileCLI(void){}; | ||
|
||
protected: | ||
private: | ||
/** | ||
* @brief Switches to the next active file | ||
* | ||
*/ | ||
void doNextFile(void); | ||
/** | ||
* @brief Duplicates the current file | ||
* | ||
*/ | ||
void copyFile(void); | ||
/** | ||
* @brief Dumps the current file to console as base85 | ||
* | ||
*/ | ||
void dumpBase85(void); | ||
/** | ||
* @brief Dumps the current file as a comma separate sequence of byte values | ||
* | ||
*/ | ||
void dumpDecimal(void); | ||
/** | ||
* @brief Dumps the current file as a hexdump | ||
* | ||
*/ | ||
void dumpHex(void); | ||
/** | ||
* @brief Dumps the current file to console as ASCII | ||
* | ||
*/ | ||
void dumpAscii(void); | ||
/** | ||
* @brief Removes the current file from the filesystem | ||
* | ||
*/ | ||
void deleteFile(void); | ||
/** | ||
* @brief Exits the file CLI | ||
* | ||
*/ | ||
void exit(void); | ||
/** | ||
* @brief Lists the files in the current directory | ||
* | ||
*/ | ||
void list_dir(void); | ||
int run = 1; | ||
DIR* current_dir; | ||
typedef struct menu_ | ||
{ | ||
const char cmd; | ||
void (FileCLI::*fn)(void); | ||
} menu_t; | ||
static menu_t fsExplorerMenu[]; | ||
}; | ||
#endif |