Skip to content

Commit

Permalink
feat!: Adds fileCLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hui committed Sep 11, 2023
1 parent 409c7c4 commit 82ca64c
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cli/cliDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Menu_t CLI_debugMenu[] =
{10, "test has data", &CLI_testHasData},
{11, "test num files", &CLI_testGetNumFiles},
{12, "wipe file system", &CLI_wipeFileSystem},
{13, "File CLI", &CLI_fileCLI},
{0, NULL, NULL}
};

Expand Down
6 changes: 6 additions & 0 deletions src/cli/menuItems/debugCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "cli/flog.hpp"
#include "cli/cli.hpp"
#include "states.hpp"
#include "fileCLI/fileCLI.hpp"

#include <fcntl.h>
#include <dirent.h>
Expand Down Expand Up @@ -230,3 +231,8 @@ void CLI_monitorWetDry(void)
SF_OSAL_printf(__NL__);
}

void CLI_fileCLI(void)
{
FileCLI cli;
cli.execute();
}
5 changes: 5 additions & 0 deletions src/cli/menuItems/debugCommands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ void CLI_monitorWetDry(void);
*/
void CLI_doMfgTest(void);

/**
* @brief File CLI
*
*/
void CLI_fileCLI(void);
#endif
40 changes: 40 additions & 0 deletions src/fileCLI/fileCLI.cpp
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)
{

}
90 changes: 90 additions & 0 deletions src/fileCLI/fileCLI.hpp
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

0 comments on commit 82ca64c

Please sign in to comment.