F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileManager.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileManager.hpp
3 // \author bocchino
4 // \brief hpp file for FileManager component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #include <cstdio>
14 #include <cstdlib>
15 
16 #include <Fw/FPrimeBasicTypes.hpp>
17 #include "Fw/Types/Assert.hpp"
19 #include "Os/Directory.hpp"
21 #include "config/FileManagerConfig.hpp"
22 
23 namespace Svc {
24 
25 // ----------------------------------------------------------------------
26 // Construction, initialization, and destruction
27 // ----------------------------------------------------------------------
28 
29 FileManager ::FileManager(const char* const compName
30  )
31  : FileManagerComponentBase(compName),
32  commandCount(0),
33  errorCount(0),
34  m_listState(IDLE),
35  m_totalEntries(0),
36  m_currentOpCode(0),
37  m_currentCmdSeq(0),
38  m_runQueued(false),
39  m_dpState(DP_IDLE),
40  m_dpFileSize(0),
41  m_dpOffset(0),
42  m_dpChunkSize(0),
43  m_dpEndOffset(0),
44  m_dpPriority(0),
45  m_dpChunkCount(0),
46  m_dpOpCode(0),
47  m_dpCmdSeq(0),
48  m_dpBuffer{} {}
49 
51 
52 // ----------------------------------------------------------------------
53 // Command handler implementations
54 // ----------------------------------------------------------------------
55 
56 void FileManager ::CreateDirectory_cmdHandler(const FwOpcodeType opCode,
57  const U32 cmdSeq,
58  const Fw::CmdStringArg& dirName) {
59  Fw::LogStringArg logStringDirName(dirName.toChar());
60  this->log_ACTIVITY_HI_CreateDirectoryStarted(logStringDirName);
61  bool errorIfDirExists = true;
62  const Os::FileSystem::Status status = Os::FileSystem::createDirectory(dirName.toChar(), errorIfDirExists);
63  if (status != Os::FileSystem::OP_OK) {
64  this->log_WARNING_HI_DirectoryCreateError(logStringDirName, status);
65  } else {
66  this->log_ACTIVITY_HI_CreateDirectorySucceeded(logStringDirName);
67  }
68  this->emitTelemetry(status);
69  this->sendCommandResponse(opCode, cmdSeq, status);
70 }
71 
72 void FileManager ::RemoveFile_cmdHandler(const FwOpcodeType opCode,
73  const U32 cmdSeq,
74  const Fw::CmdStringArg& fileName,
75  const bool ignoreErrors) {
76  Fw::LogStringArg logStringFileName(fileName.toChar());
77  this->log_ACTIVITY_HI_RemoveFileStarted(logStringFileName);
78  const Os::FileSystem::Status status = Os::FileSystem::removeFile(fileName.toChar());
79  if (status != Os::FileSystem::OP_OK) {
80  this->log_WARNING_HI_FileRemoveError(logStringFileName, status);
81  if (ignoreErrors == true) {
82  ++this->errorCount;
83  this->tlmWrite_Errors(this->errorCount);
84  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
85  return;
86  }
87  } else {
88  this->log_ACTIVITY_HI_RemoveFileSucceeded(logStringFileName);
89  }
90  this->emitTelemetry(status);
91  this->sendCommandResponse(opCode, cmdSeq, status);
92 }
93 
94 void FileManager ::MoveFile_cmdHandler(const FwOpcodeType opCode,
95  const U32 cmdSeq,
96  const Fw::CmdStringArg& sourceFileName,
97  const Fw::CmdStringArg& destFileName) {
98  Fw::LogStringArg logStringSource(sourceFileName.toChar());
99  Fw::LogStringArg logStringDest(destFileName.toChar());
100  this->log_ACTIVITY_HI_MoveFileStarted(logStringSource, logStringDest);
101  const Os::FileSystem::Status status = Os::FileSystem::moveFile(sourceFileName.toChar(), destFileName.toChar());
102  if (status != Os::FileSystem::OP_OK) {
103  this->log_WARNING_HI_FileMoveError(logStringSource, logStringDest, status);
104  } else {
105  this->log_ACTIVITY_HI_MoveFileSucceeded(logStringSource, logStringDest);
106  }
107  this->emitTelemetry(status);
108  this->sendCommandResponse(opCode, cmdSeq, status);
109 }
110 
111 void FileManager ::RemoveDirectory_cmdHandler(const FwOpcodeType opCode,
112  const U32 cmdSeq,
113  const Fw::CmdStringArg& dirName) {
114  Fw::LogStringArg logStringDirName(dirName.toChar());
115  this->log_ACTIVITY_HI_RemoveDirectoryStarted(logStringDirName);
117  if (status != Os::FileSystem::OP_OK) {
118  this->log_WARNING_HI_DirectoryRemoveError(logStringDirName, status);
119  } else {
120  this->log_ACTIVITY_HI_RemoveDirectorySucceeded(logStringDirName);
121  }
122  this->emitTelemetry(status);
123  this->sendCommandResponse(opCode, cmdSeq, status);
124 }
125 
126 void FileManager ::AppendFile_cmdHandler(const FwOpcodeType opCode,
127  const U32 cmdSeq,
128  const Fw::CmdStringArg& source,
129  const Fw::CmdStringArg& target) {
130  Fw::LogStringArg logStringSource(source.toChar());
131  Fw::LogStringArg logStringTarget(target.toChar());
132  this->log_ACTIVITY_HI_AppendFileStarted(logStringSource, logStringTarget);
133 
134  Os::FileSystem::Status status;
135  status = Os::FileSystem::appendFile(source.toChar(), target.toChar(), true);
136  if (status != Os::FileSystem::OP_OK) {
137  this->log_WARNING_HI_AppendFileFailed(logStringSource, logStringTarget, status);
138  } else {
139  this->log_ACTIVITY_HI_AppendFileSucceeded(logStringSource, logStringTarget);
140  }
141 
142  this->emitTelemetry(status);
143  this->sendCommandResponse(opCode, cmdSeq, status);
144 }
145 
146 void FileManager ::FileSize_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq, const Fw::CmdStringArg& fileName) {
147  Fw::LogStringArg logStringFileName(fileName.toChar());
148  this->log_ACTIVITY_HI_FileSizeStarted(logStringFileName);
149 
150  FwSizeType size_arg;
151  const Os::FileSystem::Status status = Os::FileSystem::getFileSize(fileName.toChar(), size_arg);
152  if (status != Os::FileSystem::OP_OK) {
153  this->log_WARNING_HI_FileSizeError(logStringFileName, status);
154  } else {
155  this->log_ACTIVITY_HI_FileSizeSucceeded(logStringFileName, size_arg);
156  }
157  this->emitTelemetry(status);
158  this->sendCommandResponse(opCode, cmdSeq, status);
159 }
160 
161 void FileManager ::ListDirectory_cmdHandler(const FwOpcodeType opCode,
162  const U32 cmdSeq,
163  const Fw::CmdStringArg& dirName) {
164  // Check if we're already listing a directory
165  if (m_listState == LISTING_IN_PROGRESS) {
166  this->log_WARNING_HI_ListDirectoryError(dirName, static_cast<U32>(Os::Directory::OTHER_ERROR));
167  this->emitTelemetry(Os::FileSystem::OTHER_ERROR);
168  this->sendCommandResponse(opCode, cmdSeq, Os::FileSystem::OTHER_ERROR);
169  return;
170  }
171 
173 
174  // Open the directory for reading
175  Os::Directory::Status status = m_currentDir.open(dirName.toChar(), Os::Directory::OpenMode::READ);
176 
177  if (status != Os::Directory::OP_OK) {
178  this->log_WARNING_HI_ListDirectoryError(dirName, static_cast<U32>(status));
179  this->emitTelemetry(Os::FileSystem::OTHER_ERROR);
180  this->sendCommandResponse(opCode, cmdSeq, Os::FileSystem::OTHER_ERROR);
181  return;
182  }
183 
184  // Initialize state machine for asynchronous processing
185  m_listState = LISTING_IN_PROGRESS;
186  m_currentDirName = dirName;
187  m_currentOpCode = opCode;
188  m_currentCmdSeq = cmdSeq;
189  m_totalEntries = 0;
190 
191  // Directory listing will be processed asynchronously by the rate group.
192  // The schedIn_handler will process FILES_PER_RATE_TICK directory entries per rate tick to
193  // prevent event flooding while maintaining configurable performance.
194  // Command response will be sent when listing completes.
195 }
196 
197 void FileManager ::CalculateCrc_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg& filename) {
198  Os::File file;
199  U32 crcValue = 0;
200  this->log_ACTIVITY_HI_CalculateCrcStarted(filename);
201 
202  Os::File::Status status = file.open(filename.toChar(), Os::File::OPEN_READ);
203  if (status == Os::File::OP_OK) {
204  status = file.calculateCrc(crcValue);
205  }
206 
207  if (status == Os::File::OP_OK) {
208  this->log_ACTIVITY_HI_CalculateCrcSucceeded(filename, crcValue);
209  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
210  } else {
211  this->log_WARNING_HI_CalculateCrcFailed(filename, status);
212  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
213  }
214  file.close();
215 }
216 
217 void FileManager ::GenerateDp_cmdHandler(FwOpcodeType opCode,
218  U32 cmdSeq,
219  const Fw::CmdStringArg& fileName,
220  U32 chunkSize,
221  U64 beginOffset,
222  U64 endOffset,
223  U32 priority,
224  const FileManager_GenerateDpMode& mode) {
225  Fw::LogStringArg logFileName(fileName.toChar());
226 
227  // Reject a second request while one is already running
228  if (this->m_dpState != DP_IDLE) {
230  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
231  return;
232  }
233 
234  // Data products must be available
236  this->log_WARNING_HI_GenerateDpBufferFailed(logFileName);
237  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
238  return;
239  }
240 
241  // Clamp the requested chunk size to the configured read buffer
242  U32 effectiveChunkSize = chunkSize;
243  if ((effectiveChunkSize == 0) || (effectiveChunkSize > FileManagerConfig::GENERATE_DP_MAX_CHUNK_SIZE)) {
245  }
246 
247  Os::File::Status status = this->m_dpFile.open(fileName.toChar(), Os::File::OPEN_READ);
248  if (status != Os::File::OP_OK) {
249  this->log_WARNING_HI_GenerateDpFailed(logFileName, FileManager_GenerateDpStage::OPEN, static_cast<U32>(status));
250  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
251  return;
252  }
253 
254  FwSizeType fileSize = 0;
255  status = this->m_dpFile.size(fileSize);
256  if (status != Os::File::OP_OK) {
257  this->m_dpFile.close();
258  this->log_WARNING_HI_GenerateDpFailed(logFileName, FileManager_GenerateDpStage::SIZE, static_cast<U32>(status));
259  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
260  return;
261  }
262 
263  // An end offset of zero, or one past the end of the file, means the end of
264  // the file. Ranges let an operator retransmit part of a file or spread the
265  // downlink over several commands.
266  U64 effectiveEnd = endOffset;
267  if ((effectiveEnd == 0) || (effectiveEnd > static_cast<U64>(fileSize))) {
268  effectiveEnd = static_cast<U64>(fileSize);
269  }
270 
271  const bool emptyFile = (fileSize == 0);
272  const bool badRange = (beginOffset > static_cast<U64>(fileSize)) || (!emptyFile && (beginOffset >= effectiveEnd));
273  if (badRange) {
274  this->m_dpFile.close();
275  this->log_WARNING_HI_GenerateDpInvalidRange(logFileName, beginOffset, endOffset, static_cast<U64>(fileSize));
276  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
277  return;
278  }
279 
280  // Position the file at the start of the requested range
281  if (beginOffset > 0) {
282  status = this->m_dpFile.seek(static_cast<FwSignedSizeType>(beginOffset), Os::File::SeekType::ABSOLUTE);
283  if (status != Os::File::OP_OK) {
284  this->m_dpFile.close();
286  static_cast<U32>(status));
287  this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
288  return;
289  }
290  }
291 
292  this->m_dpFileName = Fw::String(fileName.toChar());
293  this->m_dpFileSize = fileSize;
294  this->m_dpOffset = beginOffset;
295  this->m_dpEndOffset = effectiveEnd;
296  this->m_dpChunkSize = effectiveChunkSize;
297  this->m_dpChunkCount = 0;
298  this->m_dpOpCode = opCode;
299  this->m_dpCmdSeq = cmdSeq;
300  // A priority of zero reverts to the configured default
301  this->m_dpPriority = (priority == 0) ? static_cast<FwDpPriorityType>(FileManagerCfg::DEFAULT_DP_PRIORITY)
302  : static_cast<FwDpPriorityType>(priority);
303  this->m_dpState = DP_IN_PROGRESS;
304 
305  // Report the number of bytes that will be written, which is the requested
306  // range rather than the size of the whole file
307  this->log_ACTIVITY_HI_GenerateDpStarted(logFileName, this->m_dpEndOffset - this->m_dpOffset);
308 
309  // An empty range produces no chunks, so complete immediately
310  if (this->m_dpOffset >= this->m_dpEndOffset) {
311  this->log_ACTIVITY_HI_GenerateDpComplete(logFileName, this->m_dpChunkCount);
312  this->finishDpGeneration();
313  return;
314  }
315 
316  // In immediate mode the whole range is emitted here, so that a project that
317  // wants the file out quickly is not limited by the rate group. In paced
318  // mode the rate group meters the work out and the response is deferred.
320  this->processDpChunks(0);
321  }
322 }
323 
324 void FileManager ::processDpChunks(U32 chunkLimit) {
325  Fw::LogStringArg logFileName(this->m_dpFileName.toChar());
326 
327  // A limit of zero means emit the whole remaining range in this call
328  const bool paced = (chunkLimit > 0);
329 
330  for (U32 chunk = 0; !paced || (chunk < chunkLimit); chunk++) {
331  // Number of bytes remaining in the requested range. The loop returns as
332  // soon as the range is exhausted, so this is always non-zero here.
333  const FwSizeType remaining = static_cast<FwSizeType>(this->m_dpEndOffset - this->m_dpOffset);
334 
335  const FwSizeType requestedSize = (remaining < static_cast<FwSizeType>(this->m_dpChunkSize))
336  ? remaining
337  : static_cast<FwSizeType>(this->m_dpChunkSize);
338 
339  // The file size is known, so a short read means the file changed underneath us
340  FwSizeType readSize = requestedSize;
341  const Os::File::Status status = this->m_dpFile.read(this->m_dpBuffer, readSize);
342  if ((status != Os::File::OP_OK) || (readSize != requestedSize)) {
344  static_cast<U32>(status));
345  this->finishDpGeneration();
346  return;
347  }
348 
349  // Request a container large enough for this chunk's header and data
351  DpContainer container;
352  const Fw::Success::T dpStatus = this->dpGet_FileDpContainer(dpSize, container);
353  if (dpStatus != Fw::Success::SUCCESS) {
354  this->log_WARNING_HI_GenerateDpBufferFailed(logFileName);
355  this->finishDpGeneration();
356  return;
357  }
358  container.setPriority(this->m_dpPriority);
359 
360  // Each chunk is a metadata record followed by a data record, so that
361  // ground tools can reassemble the file from any number of containers
362  const FileManager_FileChunkHeader header(this->m_dpFileName, this->m_dpOffset, static_cast<U32>(readSize));
363  Fw::SerializeStatus serializeStatus = container.serializeRecord_FileChunkHeaderRecord(header);
364  if (serializeStatus == Fw::FW_SERIALIZE_OK) {
365  serializeStatus = container.serializeRecord_FileChunkDataRecord(this->m_dpBuffer, readSize);
366  }
367  if (serializeStatus != Fw::FW_SERIALIZE_OK) {
369  static_cast<U32>(serializeStatus));
370  this->finishDpGeneration();
371  return;
372  }
373 
374  this->dpSend(container);
375 
376  this->m_dpOffset += static_cast<U64>(readSize);
377  this->m_dpChunkCount++;
378 
379  // Last chunk of the requested range
380  if (this->m_dpOffset >= this->m_dpEndOffset) {
381  this->log_ACTIVITY_HI_GenerateDpComplete(logFileName, this->m_dpChunkCount);
382  this->finishDpGeneration();
383  return;
384  }
385  }
386 }
387 
388 void FileManager ::finishDpGeneration() {
389  this->m_dpFile.close();
390  this->m_dpState = DP_IDLE;
391  this->m_dpOffset = 0;
392  this->m_dpEndOffset = 0;
393  this->m_dpFileSize = 0;
394  // Failures emit a warning event but still respond with OK, so that a bad
395  // file name or a transient resource problem does not stop a whole sequence
396  this->cmdResponse_out(this->m_dpOpCode, this->m_dpCmdSeq, Fw::CmdResponse::OK);
397 }
398 
399 void FileManager ::pingIn_handler(const FwIndexType portNum, U32 key) {
400  // return key
401  this->pingOut_out(0, key);
402 }
403 
404 void FileManager ::schedIn_handler(const FwIndexType portNum, U32 context) {
405  bool isQueued = false;
406  // m_runQueued will be compared to isQueued (false). When equal (i.e. m_runQueued is false) the atomic will be
407  // set to true and the function will return true indicating that a run was successfully marked as queued and thus
408  // the internal handler should be invoked.
409  bool expects_enqueue = this->m_runQueued.compare_exchange_strong(isQueued, true);
410  if (expects_enqueue) {
412  }
413 }
414 
415 void FileManager ::run_internalInterfaceHandler() {
416  FW_ASSERT(this->m_runQueued);
417  this->m_runQueued = false; // Run is not queued anymore (we are running)
418  // Data product generation is paced the same way as directory listing
419  if (this->m_dpState == DP_IN_PROGRESS) {
420  this->processDpChunks(FileManagerConfig::CHUNKS_PER_RATE_TICK);
421  }
422 
423  // Only process if we're in the middle of a directory listing
424  if (m_listState == LISTING_IN_PROGRESS) {
425  // Process multiple files per rate tick based on configuration
426  for (U32 fileCount = 0; fileCount < Svc::FileManagerConfig::FILES_PER_RATE_TICK; fileCount++) {
427  Fw::String filename;
428  Os::Directory::Status status = m_currentDir.read(filename);
429 
430  if (status == Os::Directory::NO_MORE_FILES) {
431  // We're done listing - close directory and send response
432  m_currentDir.close();
433  m_listState = IDLE;
434 
435  this->log_ACTIVITY_HI_ListDirectorySucceeded(m_currentDirName, m_totalEntries);
436  this->emitTelemetry(Os::FileSystem::OP_OK);
437  this->sendCommandResponse(m_currentOpCode, m_currentCmdSeq, Os::FileSystem::OP_OK);
438  break; // Exit the loop since we're done
439 
440  } else if (status == Os::Directory::OP_OK) {
441  // Construct full path for type checking
442  Fw::String fullPath;
443  Fw::FormatStatus formatStatus = fullPath.format("%s/%s", m_currentDirName.toChar(), filename.toChar());
444 
445  // Determine entry type
446  Os::FileSystem::PathType pathType = (formatStatus == Fw::FormatStatus::SUCCESS)
447  ? Os::FileSystem::getPathType(fullPath.toChar())
449 
450  if (formatStatus != Fw::FormatStatus::SUCCESS) {
451  // Cannot determine the type of an entry whose path did not format
452  this->log_WARNING_HI_FileNameFormatError(filename,
453  static_cast<Fw::StringFormatStatus::T>(formatStatus));
454  } else if (pathType == Os::FileSystem::FILE) {
455  // Regular file: get size and emit file event
456  FwSizeType fileSize;
457  Os::FileSystem::Status sizeStatus = Os::FileSystem::getFileSize(fullPath.toChar(), fileSize);
459  m_currentDirName, filename,
460  (sizeStatus == Os::FileSystem::OP_OK) ? fileSize : static_cast<FwSizeType>(0));
461  } else if (pathType == Os::FileSystem::DIRECTORY) {
462  // Subdirectory: emit subdirectory event
463  this->log_ACTIVITY_HI_DirectoryListingSubdir(m_currentDirName, filename);
464  } else {
465  // Special file or inaccessible: treat as file with 0 size
466  this->log_ACTIVITY_HI_DirectoryListing(m_currentDirName, filename, static_cast<FwSizeType>(0));
467  }
468 
469  m_totalEntries++;
470 
471  } else {
472  // Error reading directory - close and send error response
473  m_currentDir.close();
474  m_listState = IDLE;
475 
476  this->log_WARNING_HI_ListDirectoryError(m_currentDirName, static_cast<U32>(status));
477  this->emitTelemetry(Os::FileSystem::OTHER_ERROR);
478  this->sendCommandResponse(m_currentOpCode, m_currentCmdSeq, Os::FileSystem::OTHER_ERROR);
479  break; // Exit the loop since we had an error
480  }
481  }
482  }
483 }
484 
485 // ----------------------------------------------------------------------
486 // Helper methods
487 // ----------------------------------------------------------------------
488 
489 void FileManager ::emitTelemetry(const Os::FileSystem::Status status) {
490  if (status == Os::FileSystem::OP_OK) {
491  ++this->commandCount;
492  this->tlmWrite_CommandsExecuted(this->commandCount);
493  } else {
494  ++this->errorCount;
495  this->tlmWrite_Errors(this->errorCount);
496  }
497 }
498 
499 void FileManager ::sendCommandResponse(const FwOpcodeType opCode,
500  const U32 cmdSeq,
501  const Os::FileSystem::Status status) {
502  this->cmdResponse_out(opCode, cmdSeq,
504 }
505 
506 } // namespace Svc
bool isConnected_productSendOut_OutputPort(FwIndexType portNum) const
Serialization/Deserialization operation was successful.
A request arrived while another was in progress.
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
static constexpr FwSizeType SIZE_OF_FileChunkDataRecord_RECORD(FwSizeType arraySize)
Record sizes.
FwIdType FwOpcodeType
The type of a command opcode.
Fw::Success::T dpGet_FileDpContainer(FwSizeType dataSize, DpContainer &container)
Status calculateCrc(U32 &crc)
calculate the CRC32 of the entire file
Definition: File.cpp:237
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
Representing success.
PlatformSizeType FwSizeType
static Status moveFile(const char *sourcePath, const char *destPath)
Move a file from sourcePath to destPath.
Definition: FileSystem.cpp:209
U32 FwDpPriorityType
The type of a data product priority.
void log_ACTIVITY_HI_CalculateCrcStarted(const Fw::StringBase &fileName) const
static constexpr U32 CHUNKS_PER_RATE_TICK
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)
Definition: FileManager.cpp:29
void log_ACTIVITY_HI_GenerateDpStarted(const Fw::StringBase &fileName, U64 bytesToWrite) const
static Status removeDirectory(const char *path)
Remove a directory at the specified path.
Definition: FileSystem.cpp:83
StringTemplate< FW_FIXED_LENGTH_STRING_SIZE > String
Definition: String.hpp:14
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.
Definition: FileSystem.cpp:177
void log_ACTIVITY_HI_ListDirectorySucceeded(const Fw::StringBase &dirName, U32 fileCount) const
Auto-generated base for FileManager component.
Status size(FwSizeType &size_result) override
get size of currently open file
Definition: File.cpp:111
bool isConnected_productGetOut_OutputPort(FwIndexType portNum) const
void log_ACTIVITY_HI_CalculateCrcSucceeded(const Fw::StringBase &fileName, U32 crc) const
void log_ACTIVITY_HI_ListDirectoryStarted(const Fw::StringBase &dirName) const
void log_ACTIVITY_HI_MoveFileStarted(const Fw::StringBase &sourceFileName, const Fw::StringBase &destFileName) const
void log_WARNING_HI_GenerateDpInvalidRange(const Fw::StringBase &fileName, U64 beginOffset, U64 endOffset, U64 fileSize) const
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
void log_ACTIVITY_HI_AppendFileSucceeded(const Fw::StringBase &source, const Fw::StringBase &target) const
SerializeStatus
forward declaration for string
void log_WARNING_HI_GenerateDpBufferFailed(const Fw::StringBase &fileName) const
void log_ACTIVITY_HI_CreateDirectorySucceeded(const Fw::StringBase &dirName) const
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Definition: File.cpp:50
A catch-all for other errors. Have to look in implementation-specific code.
Definition: Directory.hpp:32
void log_WARNING_HI_GenerateDpFailed(const Fw::StringBase &fileName, const Svc::FileManager_GenerateDpStage &stage, U32 status) const
void log_ACTIVITY_HI_RemoveDirectoryStarted(const Fw::StringBase &dirName) const
void close() override
Close directory.
Definition: Directory.cpp:74
Status seek(FwSignedSizeType offset, SeekType seekType) override
seek the file pointer to the given offset
Definition: File.cpp:142
Status read(char *fileNameBuffer, FwSizeType buffSize) override
Get next filename from directory stream.
Definition: Directory.cpp:54
T
The raw enum type.
static constexpr U32 GENERATE_DP_MAX_CHUNK_SIZE
void close() override
close the file, if not opened then do nothing
Definition: File.cpp:97
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Directory stream has no more files.
Definition: Directory.hpp:27
const char * toChar() const
Convert to a C-style char*.
void log_ACTIVITY_HI_FileSizeStarted(const Fw::StringBase &fileName) const
void log_WARNING_HI_FileNameFormatError(const Fw::StringBase &fileName, const Fw::StringFormatStatus &status) const
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
Command successfully executed.
void log_ACTIVITY_HI_GenerateDpComplete(const Fw::StringBase &fileName, U32 chunks) const
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.
Definition: FileSystem.cpp:227
static Status createDirectory(const char *path, bool errorIfAlreadyExists=false)
Create a new directory at the specified path.
Definition: FileSystem.cpp:111
static constexpr FwSizeType SIZE_OF_FileChunkHeaderRecord_RECORD
Status read(U8 *buffer, FwSizeType &size)
read data from this file into supplied buffer bounded by size
Definition: File.cpp:194
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&#39;t exist)
Definition: FileSystem.cpp:138
other OS-specific error
Definition: FileSystem.hpp:40
void log_ACTIVITY_HI_AppendFileStarted(const Fw::StringBase &source, const Fw::StringBase &target) const
Operation was successful.
Definition: File.hpp:42
void tlmWrite_Errors(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
void log_ACTIVITY_HI_RemoveFileStarted(const Fw::StringBase &fileName) const
PlatformIndexType FwIndexType
Operation was successful.
Definition: Directory.hpp:22
Open file for reading.
Definition: File.hpp:33
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.
Definition: Directory.cpp:31
RateGroupDivider component implementation.
Emit all chunks in the command handler, completing immediately.
void log_WARNING_HI_CalculateCrcFailed(const Fw::StringBase &fileName, U32 status) const
Operation was successful.
Definition: FileSystem.hpp:24
static constexpr U32 FILES_PER_RATE_TICK
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
#define FW_ASSERT(...)
Definition: Assert.hpp:14
static Status removeFile(const char *path)
Remove a file at the specified path.
Definition: FileSystem.cpp:87
void log_WARNING_HI_FileRemoveError(const Fw::StringBase &fileName, U32 status) const
void dpSend(DpContainer &container, Fw::Time timeTag=Fw::ZERO_TIME)
Send a data product.
FormatStatus
status of string format calls
Definition: format.hpp:18