File path data type

A variable of type path_t can be used to hold the value of __file->path (refer to __file built in for I/O probe manager) or function fd_path(). Only local or global variables of type path_t are supported. A variable of this type can also be the key or value in an associative Array.

Declaration of file path variable

path_t pth; // global variable of type path_t
auto:pth2 = fd_path(fd); // store in a local path_t variable
my_aso[__file->fname] = __file->path; // store in associative array

The signed, unsigned, register, static, thread, and kernel qualifiers are not supported for the path_t type variables.

Assignment operation

The assignment (=) operator allows one path_t variable to be assigned to another path_t variable. The original value of the variable is overwritten.

In the following example, after the assignment, p1 and p2 refer to the same file path:
path_t p1, p2;
p1 = fd_path(fd); // fd is a valid file descriptor value 
p2 = p1;

Comparison operation

Only equality (==) and inequality (!=) operators are allowed for the path_t variables. The result of the equality operator is true (1) if both represent the same absolute file path or false (0) otherwise.

The inequality operator is the exact compliment of this behavior. No other comparison operators (>=, >, <, or =<) are allowed for the path_t type variables.

Printing file path type variables

A path_t type variable can be printed with “%p” format specifier in the printf() function.

This printing of file path involves a time-consuming file search operation in the corresponding file system. Hence, it must be judiciously used in Vue scripts.

Note: For transient files, which might no longer exist when the printf() message, can get printed; a null string is printed as file path.
An associative array that has the path_t type variables as key or value (or both) can be printed by using the print() function.
printf(“file path=[%p]\n”, __file->path); 
my_aso[0] = fd_path(fd); // fd is valid file descriptor value 
print(my_aso);
Limitations file path type variables
  • Array of the path_t variables cannot be declared.
  • The path_t variables cannot be used as members of struct or union.
  • A pointer to the path_t variable is not allowed.
  • Typecasting of the path_t variable to any other type or typecasting any other type to the path_t type is not allowed.
  • No arithmetic operator (+, -, *, /, ++, --, and so on) can be used with the path_t type variable.