Robotran C Documentation
Functions
mbs_path.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
#include "useful_functions.h"

Functions

char * find_user_path (const char *mbsfile)
 Find the user folder corresponding to the given *.mbs file. More...
 
int find_project_path (const char *mbsfile, char *prjpath)
 Find the project directory (containing dataR, symbolicR, ...). More...
 
char * mbs_basename (const char *path)
 mbs_basename return sthe trailing part of the path (UNIX and MAC). More...
 
char * mbs_dirname (const char *path)
 mbs_dirname returns the leading part of the path (UNIX and MAC). More...
 

Function Documentation

◆ find_project_path()

int find_project_path ( const char *  mbsfile,
char *  prjpath 
)

Find the project directory (containing dataR, symbolicR, ...).

prjpath should be large enough to contain at least mbsfile.

Parameters
[in]mbsfilethe path and filename to the .mbs file
[out]prjpaththe path to the root of the mbs project
Returns
err <0 if error occurs

◆ find_user_path()

char* find_user_path ( const char *  mbsfile)

Find the user folder corresponding to the given *.mbs file.

This function allocat a char* that must be freed by the user.

Parameters
[in]mbsfilethe path and filename to the .mbs file
Returns
pointer to char array containing the path to the userfctR folder.

◆ mbs_basename()

char* mbs_basename ( const char *  path)

mbs_basename return sthe trailing part of the path (UNIX and MAC).

If the path ends on a folder, it returns the terminal folder. If it is a file it returns the filename and its extention.

If the path is the root folder it returns '/'. However under Windows we do not check if the path only contains the path to a drive (such as 'C:/').

Parameters
pathThe path from which the basename must be extracted.
Returns
The base name of the given path.

◆ mbs_dirname()

char* mbs_dirname ( const char *  path)

mbs_dirname returns the leading part of the path (UNIX and MAC).

If the path ends on a folder, it returns the previous folder. If it is a file it returns the path to the folder containing the file.

If the path is the root folder it returns '/'. However under Windows we do not check if the path only contains the path to a drive (such as 'C:/').

Parameters
pathThe path from which the leading part must be extracted.
Returns
The leading part of the given path.