1Tcl_SplitPath(3)            Tcl Library Procedures            Tcl_SplitPath(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl_SplitPath,  Tcl_JoinPath,  Tcl_GetPathType  -  manipulate platform-
9       dependent file paths
10

SYNOPSIS

12       #include <tcl.h>
13
14       Tcl_SplitPath(path, argcPtr, argvPtr)
15
16       char *
17       Tcl_JoinPath(argc, argv, resultPtr)
18
19       Tcl_PathType
20       Tcl_GetPathType(path)
21

ARGUMENTS

23       const char *path (in)                      File path in a  form  appro‐
24                                                  priate for the current plat‐
25                                                  form (see the filename  man‐
26                                                  ual   entry  for  acceptable
27                                                  forms for path names).
28
29       int *argcPtr (out)                         Filled  in  with  number  of
30                                                  path elements in path.
31
32       const char ***argvPtr (out)                *argvPtr  will  be filled in
33                                                  with the address of an array
34                                                  of  pointers  to the strings
35                                                  that are the extracted  ele‐
36                                                  ments  of  path.  There will
37                                                  be *argcPtr valid entries in
38                                                  the  array,  followed  by  a
39                                                  NULL entry.
40
41       int argc (in)                              Number of elements in argv.
42
43       const char *const *argv (in)               Array of  path  elements  to
44                                                  merge together into a single
45                                                  path.
46
47       Tcl_DString *resultPtr (in/out)            A pointer to an  initialized
48                                                  Tcl_DString   to  which  the
49                                                  result of Tcl_JoinPath  will
50                                                  be appended.
51______________________________________________________________________________
52
53

DESCRIPTION

55       These procedures have been superseded by the Tcl-value-aware procedures
56       in the FileSystem man page, which are more efficient.
57
58       These procedures may be used to disassemble and reassemble  file  paths
59       in  a  platform  independent manner: they provide C-level access to the
60       same functionality as the file split, file join, and file pathtype com‐
61       mands.
62
63       Tcl_SplitPath breaks a path into its constituent elements, returning an
64       array of pointers to the elements using argcPtr and argvPtr.  The  area
65       of  memory pointed to by *argvPtr is dynamically allocated; in addition
66       to the array of pointers, it also holds copies of  all  the  path  ele‐
67       ments.   It is the caller's responsibility to free all of this storage.
68       For example, suppose that you have called Tcl_SplitPath with  the  fol‐
69       lowing code:
70
71              int argc;
72              char *path;
73              char **argv;
74              ...
75              Tcl_SplitPath(string, &argc, &argv);
76
77       Then  you  should eventually free the storage with a call like the fol‐
78       lowing:
79
80              Tcl_Free((char *) argv);
81
82       Tcl_JoinPath is the inverse of Tcl_SplitPath: it takes a collection  of
83       path elements given by argc and argv and generates a result string that
84       is a properly constructed  path.  The  result  string  is  appended  to
85       resultPtr.  ResultPtr must refer to an initialized Tcl_DString.
86
87       If  the  result  of Tcl_SplitPath is passed to Tcl_JoinPath, the result
88       will refer to the same location, but may not be in the same form.  This
89       is because Tcl_SplitPath and Tcl_JoinPath eliminate duplicate path sep‐
90       arators and return a normalized form for each platform.
91
92       Tcl_GetPathType  returns  the  type  of  the  specified   path,   where
93       Tcl_PathType   is   one  of  TCL_PATH_ABSOLUTE,  TCL_PATH_RELATIVE,  or
94       TCL_PATH_VOLUME_RELATIVE.  See the filename manual entry for a descrip‐
95       tion of the path types for each platform.
96
97

KEYWORDS

99       file, filename, join, path, split, type
100
101
102
103Tcl                                   7.5                     Tcl_SplitPath(3)
Impressum