21 #include "config/FileManagerConfig.hpp" 45 void FileManager ::CreateDirectory_cmdHandler(
const FwOpcodeType opCode,
50 bool errorIfDirExists =
true;
57 this->emitTelemetry(status);
58 this->sendCommandResponse(opCode, cmdSeq, status);
61 void FileManager ::RemoveFile_cmdHandler(
const FwOpcodeType opCode,
64 const bool ignoreErrors) {
70 if (ignoreErrors ==
true) {
79 this->emitTelemetry(status);
80 this->sendCommandResponse(opCode, cmdSeq, status);
83 void FileManager ::MoveFile_cmdHandler(
const FwOpcodeType opCode,
96 this->emitTelemetry(status);
97 this->sendCommandResponse(opCode, cmdSeq, status);
100 void FileManager ::RemoveDirectory_cmdHandler(
const FwOpcodeType opCode,
111 this->emitTelemetry(status);
112 this->sendCommandResponse(opCode, cmdSeq, status);
115 void FileManager ::ShellCommand_cmdHandler(
const FwOpcodeType opCode,
121 int status = this->systemCall(command, logFileName);
131 void FileManager ::AppendFile_cmdHandler(
const FwOpcodeType opCode,
147 this->emitTelemetry(status);
148 this->sendCommandResponse(opCode, cmdSeq, status);
162 this->emitTelemetry(status);
163 this->sendCommandResponse(opCode, cmdSeq, status);
166 void FileManager ::ListDirectory_cmdHandler(
const FwOpcodeType opCode,
170 if (m_listState == LISTING_IN_PROGRESS) {
189 m_listState = LISTING_IN_PROGRESS;
190 m_currentDirName = dirName;
191 m_currentOpCode = opCode;
192 m_currentCmdSeq = cmdSeq;
201 void FileManager ::pingIn_handler(
const FwIndexType portNum, U32 key) {
206 void FileManager ::schedIn_handler(
const FwIndexType portNum, U32 context) {
208 if (m_listState == LISTING_IN_PROGRESS) {
216 m_currentDir.
close();
237 m_currentDirName, filename,
251 m_currentDir.
close();
270 const char evalStr[] =
"eval '%s' 1>>%s 2>&1\n";
272 char buffer[bufferSize];
281 const int status = system(stringBuffer.toChar());
287 ++this->commandCount;
295 void FileManager ::sendCommandResponse(
const FwOpcodeType opCode,
void log_WARNING_HI_ListDirectoryError(const Fw::StringBase &dirName, U32 status) const
void log_ACTIVITY_HI_DirectoryListingSubdir(const Fw::StringBase &dirName, const Fw::StringBase &subdirName) const
void log_ACTIVITY_HI_CreateDirectoryStarted(const Fw::StringBase &dirName) const
FwIdType FwOpcodeType
The type of a command opcode.
void log_ACTIVITY_HI_RemoveDirectorySucceeded(const Fw::StringBase &dirName) const
void log_ACTIVITY_HI_DirectoryListing(const Fw::StringBase &dirName, const Fw::StringBase &fileName, FwSizeType fileSize) const
PlatformSizeType FwSizeType
static Status moveFile(const char *sourcePath, const char *destPath)
Move a file from sourcePath to destPath.
void log_WARNING_HI_FileSizeError(const Fw::StringBase &fileName, U32 status) const
FileManager(const char *const compName)
const char * toChar() const
static Status removeDirectory(const char *path)
Remove a directory at the specified path.
void log_ACTIVITY_HI_FileSizeSucceeded(const Fw::StringBase &fileName, FwSizeType size) const
static Status appendFile(const char *sourcePath, const char *destPath, bool createMissingDest=false)
Append the source file to the destination file.
void log_ACTIVITY_HI_ListDirectorySucceeded(const Fw::StringBase &dirName, U32 fileCount) const
Auto-generated base for FileManager component.
void log_ACTIVITY_HI_ListDirectoryStarted(const Fw::StringBase &dirName) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void log_ACTIVITY_HI_MoveFileStarted(const Fw::StringBase &sourceFileName, const Fw::StringBase &destFileName) const
void log_ACTIVITY_HI_AppendFileSucceeded(const Fw::StringBase &source, const Fw::StringBase &target) const
void log_ACTIVITY_HI_CreateDirectorySucceeded(const Fw::StringBase &dirName) const
A catch-all for other errors. Have to look in implementation-specific code.
void log_ACTIVITY_HI_RemoveDirectoryStarted(const Fw::StringBase &dirName) const
void log_ACTIVITY_HI_ShellCommandSucceeded(const Fw::StringBase &command) const
void close() override
Close directory.
Status read(char *fileNameBuffer, FwSizeType buffSize) override
Get next filename from directory stream.
A string backed by an external buffer.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Directory stream has no more files.
void log_ACTIVITY_HI_FileSizeStarted(const Fw::StringBase &fileName) const
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Command successfully executed.
void log_ACTIVITY_HI_MoveFileSucceeded(const Fw::StringBase &sourceFileName, const Fw::StringBase &destFileName) const
static Status getFileSize(const char *path, FwSizeType &size)
Get the size of the file (in bytes) at the specified path.
static Status createDirectory(const char *path, bool errorIfAlreadyExists=false)
Create a new directory at the specified path.
void log_WARNING_HI_DirectoryRemoveError(const Fw::StringBase &dirName, U32 status) const
Command had execution error.
static PathType getPathType(const char *path)
Return the type of the path (file, directory, or doesn't exist)
const char * toChar() const
void log_ACTIVITY_HI_AppendFileStarted(const Fw::StringBase &source, const Fw::StringBase &target) const
void tlmWrite_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_HI_RemoveFileStarted(const Fw::StringBase &fileName) const
void log_ACTIVITY_HI_ShellCommandStarted(const Fw::StringBase &command) const
PlatformIndexType FwIndexType
Operation was successful.
void log_WARNING_HI_AppendFileFailed(const Fw::StringBase &source, const Fw::StringBase &target, U32 status) const
Status open(const char *path, OpenMode mode) override
Open or create a directory.
RateGroupDivider component implementation.
Operation was successful.
static constexpr U32 FILES_PER_RATE_TICK
#define FW_CMD_STRING_MAX_SIZE
Max character size of command string arguments.
void log_WARNING_HI_ShellCommandFailed(const Fw::StringBase &command, U32 status) const
void log_WARNING_HI_DirectoryCreateError(const Fw::StringBase &dirName, U32 status) const
void log_ACTIVITY_HI_RemoveFileSucceeded(const Fw::StringBase &fileName) const
void log_WARNING_HI_FileMoveError(const Fw::StringBase &sourceFileName, const Fw::StringBase &destFileName, U32 status) const
void tlmWrite_CommandsExecuted(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
static Status removeFile(const char *path)
Remove a file at the specified path.
void log_WARNING_HI_FileRemoveError(const Fw::StringBase &fileName, U32 status) const
FormatStatus
status of string format calls