LabWindows/CVI

Content Type
Programming Language
Current manual

SplitPath

SplitPath

void SplitPath (char pathname[], char driveName[], char directoryName[], char fileName[]);

Purpose

Splits a pathname into the drive name, the directory name, and the filename.

Example Code

char pathName[MAX_PATHNAME_LEN];
char driveName[MAX_DRIVENAME_LEN];
char dirName[MAX_DIRNAME_LEN];
char fileName[MAX_FILENAME_LEN];
SplitPath (pathName, driveName, dirName, fileName);
/* If pathName contains

c:\cvi\samples\apps\update.c

then

driveName contains "c:"
dirName contains "\cvi\samples\apps\"
fileName contains "update.c"

If pathName is

\computer\share\dirname\foo.c

then

drive name is ""
directory name is "\computer\share\dirname\"
filename is "foo.c" */

Note    MAX_PATHNAME_LEN is only reliable for ANSI single byte strings. For UTF-8 strings, call the IsUTF8PathLengthValid function to confirm that the file path is within the operating system character limit.

Parameters

Input
Name Type Description
pathname char [] Pathname to split.
Output
Name Type Description
driveName char [] A buffer to contain the drive name.

driveName can be NULL. If not NULL, it must be of size MAX_DRIVENAME_LEN or greater.

The buffer is filled with an empty string if the pathname is a UNC path, such as \computer\share\file.c.

(Linux) On operating systems without drive names, such as Linux, SplitPath always fills driveName with an empty string.

directoryName char [] A buffer to contain the directory name.

directoryName can be NULL. If not NULL, it must be of size MAX_DIRNAME_LEN or greater.
fileName char [] A buffer to contain the file name.

fileName can be NULL. If not NULL, it must be of size MAX_FILENAME_LEN or greater.

Return Value

None.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later

Examples

Refer to the following examples that use the SplitPath function:

  • apps\uirview\uirview.cws

    Open example
  • userint\treeimage.cws

    Open example
  • userint\treesort.cws

    Open example
  • userint\custctrl\hyperlinkctrl\simple.cws

    Open example
Was this information helpful?