resolve path/directory/file name

Prev Next

Function Names

resolve path name, resolve directory name, resolve file name

Description

This function resolves specified directory path and file names (containing wildcard symbols in various directory and/or file names) to existing path and file names where
1. The full path name will be checked.

  • For resolve file name, the last name must be a file name.
  • For resolve file name, the last name must be a directory name.
  • For resolve path name, the last name may either be a file or directory name.

2. If path contains wildcard symbols (Attention: '*' and '?' only), then the matching name will be identified.
If 2 or more matches are found, then an exception will be asserted because the path is ambiguous.
3. If the path begins with a lone tilde symbol ('~/...', '~\...'), then the tilde will be replaced by the user home directory.
4. Wildcards along the full directory path are allowed, e.g. "C:\Prgram Files\*\*\Lib\Support Library*". B4P will search through the different
subdirectories accordingly.

Note:In interactive mode, B4P will automatically capture all 'cd' / 'chdir' / changing drive commands and take care of changing the directores in the B4P process, too. Reason: Operating System commands executed happen in child processes and changing direcctories have no effect on their parent processes.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
string path name

This path name may contain wildcard symbols which will be resolved.

Default value: Current working directory

Return value

TypeDescription
string Fully resolveld path name

All wildcards have been resolved.

Examples

      if ( system info[operating system] = Windows)
      {
          echo( resolve path name( "C:\Program*\*\*4P.exe" ) ); // Look for B4p Program
      }
      else
      {
          echo( resolve path name( "/usr/*l/*n/*4p" ) ); // Look for /usr/local/bin/b4p
      }
      echo( resolve path name( "~/" ) );    // Your home directory
      echo( resolve path name( "~/.." ) );  // Parent directory of home directory

Output

C:\Program Files\B4P\B4P.exe
C:\Users\zur-b\
C:\Users\
Try it yourself: Open LIB_Function_resolve_path_name.b4p in B4P_Examples.zip. Decompress before use.

See also

search files
directory listing