21 #include "config/FileManagerConfig.hpp" 46 void FileManager ::CreateDirectory_cmdHandler(
const FwOpcodeType opCode,
51 bool errorIfDirExists =
true;
58 this->emitTelemetry(status);
59 this->sendCommandResponse(opCode, cmdSeq, status);
62 void FileManager ::RemoveFile_cmdHandler(
const FwOpcodeType opCode,
65 const bool ignoreErrors) {
71 if (ignoreErrors ==
true) {
80 this->emitTelemetry(status);
81 this->sendCommandResponse(opCode, cmdSeq, status);
84 void FileManager ::MoveFile_cmdHandler(
const FwOpcodeType opCode,
97 this->emitTelemetry(status);
98 this->sendCommandResponse(opCode, cmdSeq, status);
101 void FileManager ::RemoveDirectory_cmdHandler(
const FwOpcodeType opCode,
112 this->emitTelemetry(status);
113 this->sendCommandResponse(opCode, cmdSeq, status);
116 void FileManager ::ShellCommand_cmdHandler(
const FwOpcodeType opCode,
122 int status = this->systemCall(command, logFileName);
132 void FileManager ::AppendFile_cmdHandler(
const FwOpcodeType opCode,
148 this->emitTelemetry(status);
149 this->sendCommandResponse(opCode, cmdSeq, status);
163 this->emitTelemetry(status);
164 this->sendCommandResponse(opCode, cmdSeq, status);
167 void FileManager ::ListDirectory_cmdHandler(
const FwOpcodeType opCode,
171 if (m_listState == LISTING_IN_PROGRESS) {
190 m_listState = LISTING_IN_PROGRESS;
191 m_currentDirName = dirName;
192 m_currentOpCode = opCode;
193 m_currentCmdSeq = cmdSeq;
222 void FileManager ::pingIn_handler(
const FwIndexType portNum, U32 key) {
227 void FileManager ::schedIn_handler(
const FwIndexType portNum, U32 context) {
228 bool isQueued =
false;
232 bool expects_enqueue = this->m_runQueued.compare_exchange_strong(isQueued,
true);
233 if (expects_enqueue) {
238 void FileManager ::run_internalInterfaceHandler() {
240 this->m_runQueued =
false;
242 if (m_listState == LISTING_IN_PROGRESS) {
250 m_currentDir.
close();
271 m_currentDirName, filename,
285 m_currentDir.
close();
304 const char evalStr[] =
"eval '%s' 1>>%s 2>&1\n";
306 char buffer[bufferSize];
315 const int status = system(stringBuffer.toChar());
321 ++this->commandCount;
329 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.
Status calculateCrc(U32 &crc)
calculate the CRC32 of the entire file
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_ACTIVITY_HI_CalculateCrcStarted(const Fw::StringBase &fileName) const
void log_WARNING_HI_FileSizeError(const Fw::StringBase &fileName, U32 status) const
void run_internalInterfaceInvoke()
Internal interface base-class function for run.
FileManager(const char *const compName)
const char * toChar() const
Convert to a C-style char*.
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_CalculateCrcSucceeded(const Fw::StringBase &fileName, U32 crc) const
void log_ACTIVITY_HI_ListDirectoryStarted(const Fw::StringBase &dirName) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
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 close() override
close the file, if not opened then do nothing
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
Convert to a C-style char*.
void log_ACTIVITY_HI_AppendFileStarted(const Fw::StringBase &source, const Fw::StringBase &target) const
Operation was successful.
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.
void log_WARNING_HI_CalculateCrcFailed(const Fw::StringBase &fileName, U32 status) const
Operation was successful.
static constexpr U32 FILES_PER_RATE_TICK
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