Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/os/inc/osapi-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,16 @@ int32 OS_chkfs(const char *name, bool repair);
*/
int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint);

#ifndef OSAL_OMIT_DEPRECATED

/*-------------------------------------------------------------------------------------*/
/**
* @brief Translates an OSAL Virtual file system path to a host Local path
*
* Translates a virtual path to an actual system path name
*
* @note The buffer provided in the LocalPath argument is required to be at
* least OS_MAX_PATH_LEN characters in length.
* least OS_MAX_LOCAL_PATH_LEN characters in length.
*
* @param[in] VirtualPath OSAL virtual path name @nonnull
* @param[out] LocalPath Buffer to store native/translated path name @nonnull
Expand All @@ -287,6 +289,27 @@ int32 OS_FS_GetPhysDriveName(char *PhysDriveName, const char *MountPoint);
*/
int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath);

#endif

/*-------------------------------------------------------------------------------------*/
/**
* @brief Translates an OSAL Virtual file system path to a host Local path
*
* Translates a virtual path to an actual system path name
*
* @param[in] VirtualPath OSAL virtual path name @nonnull
* @param[out] LocalPath Buffer to store native/translated path name @nonnull
* @param[out] LocalPathSize Size of buffer to store native/translated path name @nonnull
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_INVALID_POINTER if either parameter is NULL
* @retval #OS_FS_ERR_NAME_TOO_LONG if the filename component is too long
* @retval #OS_FS_ERR_PATH_INVALID if either parameter cannot be interpreted as a path
* @retval #OS_FS_ERR_PATH_TOO_LONG if either input or output pathnames are too long
*/
int32 OS_TranslatePathWithSize(const char *VirtualPath, char *LocalPath, size_t LocalPathSize);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Returns information about the file system
Expand Down
17 changes: 15 additions & 2 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,20 @@ int32 OS_GetFsInfo(os_fsinfo_t *filesys_info)
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
#ifndef OSAL_OMIT_DEPRECATED
int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
{
return OS_TranslatePathWithSize(VirtualPath, LocalPath, OS_MAX_LOCAL_PATH_LEN);
}
#endif

/*----------------------------------------------------------------
*
* Purpose: Implemented per public OSAL API
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_TranslatePathWithSize(const char *VirtualPath, char *LocalPath, size_t LocalPathSize)
{
OS_object_token_t token;
int32 return_code;
Expand Down Expand Up @@ -750,7 +763,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
{
SysMountPointLen = OS_strnlen(filesys->system_mountpt, sizeof(filesys->system_mountpt));
VirtPathBegin = OS_strnlen(filesys->virtual_mountpt, sizeof(filesys->virtual_mountpt));
if (SysMountPointLen < OS_MAX_LOCAL_PATH_LEN)
if (SysMountPointLen < LocalPathSize)
{
memcpy(LocalPath, filesys->system_mountpt, SysMountPointLen);
}
Expand All @@ -772,7 +785,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
else
{
VirtPathLen -= VirtPathBegin;
if ((SysMountPointLen + VirtPathLen) < OS_MAX_LOCAL_PATH_LEN)
if ((SysMountPointLen + VirtPathLen) < LocalPathSize)
{
memcpy(&LocalPath[SysMountPointLen], &VirtualPath[VirtPathBegin], VirtPathLen);
LocalPath[SysMountPointLen + VirtPathLen] = 0;
Expand Down
Loading