Skip to content

Commit

Permalink
fix: Adds chgdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hui committed Sep 12, 2023
1 parent 621797d commit 3422dcb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
"editor.rulers": [
80
],
"particle.enableVerboseLocalCompilerLogging": true,

}
20 changes: 20 additions & 0 deletions src/fileCLI/fileCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void FileCLI::list_dir(void)
file_stats.st_size,
dirent->d_name);
}
rewinddir(cwd);
}

FileCLI::menu_t* FileCLI::findCommand(const char* const cmd)
Expand Down Expand Up @@ -129,4 +130,23 @@ const char* FileCLI::buildPath(void)
path_buffer_idx = strlen(path_buffer);
}
return path_buffer;
}

void FileCLI::change_dir(void)
{
DIR* cwd = this->dir_stack[this->current_dir];
struct dirent* dirent;
long idx = 0;

while ((dirent = readdir(cwd)))
{
if(dirent->d_type == DT_REG)
{
continue;
}
idx = telldir(cwd);
SF_OSAL_printf("%d: %-16s" __NL__,
idx,
dirent->d_name);
}
}
10 changes: 5 additions & 5 deletions src/fileCLI/fileCLI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ class FileCLI{

protected:
private:
/**
* @brief Switches to the next active file
*
*/
void doNextFile(void);
/**
* @brief Duplicates the current file
*
Expand Down Expand Up @@ -82,6 +77,11 @@ class FileCLI{
*
*/
void list_dir(void);
/**
* @brief Changes to the specified directory
*
*/
void change_dir(void);
int run = 1;
DIR* dir_stack[FILE_CLI_MAX_DIR_DEPTH];
char* path_stack[FILE_CLI_MAX_DIR_DEPTH];
Expand Down

0 comments on commit 3422dcb

Please sign in to comment.