F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FilePathUtils.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/FilePathUtils.hpp
3 // \brief Utilities for resolving and validating file paths
4 // ======================================================================
5 #ifndef Os_FilePathUtils_hpp_
6 #define Os_FilePathUtils_hpp_
7 
11 
12 namespace Os {
13 
20 namespace FilePathUtils {
21 
22 enum Status {
27 };
28 
31 
47 Status resolvePath(const char* path, const char* baseDir, char* resolvedOut, FwSizeType resolvedSize);
48 
56 Status resolvePath(const Fw::ConstStringBase& path, const Fw::ConstStringBase& baseDir, Fw::StringBase& resolvedOut);
57 
69 Status resolveFromCwd(const char* path, char* resolvedOut, FwSizeType resolvedSize);
70 
81 Status checkContainment(const char* resolvedPath, const char* allowedDirectory);
82 
83 } // namespace FilePathUtils
84 } // namespace Os
85 
86 #endif
Resolved path falls outside the allowed directory.
PlatformSizeType FwSizeType
Path is malformed or cannot be resolved.
Status checkContainment(const char *resolvedPath, const char *allowedDirectory)
Check whether an already-resolved path is within an allowed directory.
static constexpr FwSizeType MAX_PATH_LENGTH
Maximum supported path length for resolution buffers.
Path is valid and within the allowed directory.
Status resolveFromCwd(const char *path, char *resolvedOut, FwSizeType resolvedSize)
Resolve a path using CWD as the base for relative paths.
A read-only abstract superclass for StringBase.
Declares F Prime string base class.
Status resolvePath(const char *path, const char *baseDir, char *resolvedOut, FwSizeType resolvedSize)
Resolve a path by collapsing . and .. segments.
Combined path length exceeds the output buffer size.