SplitPath.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
- '"
- '" Copyright (c) 1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: SplitPath.3,v 1.7 2002/03/09 19:17:58 dgp Exp $
- '"
- .so man.macros
- .TH Tcl_SplitPath 3 7.5 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- Tcl_SplitPath, Tcl_JoinPath, Tcl_GetPathType - manipulate platform-dependent file paths
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- fBTcl_SplitPathfR(fIpath, argcPtr, argvPtrfR)
- .sp
- char *
- fBTcl_JoinPathfR(fIargc, argv, resultPtrfR)
- .sp
- Tcl_PathType
- fBTcl_GetPathTypefR(fIpathfR)
- .SH ARGUMENTS
- .AS Tcl_DString ***argvPtr
- .AP "CONST char * CONST" *argvPtr in
- File path in a form appropriate for the current platform (see the
- fBfilenamefR manual entry for acceptable forms for path names).
- .AP int *argcPtr out
- Filled in with number of path elements in fIpathfR.
- .AP "CONST char" ***argvPtr out
- fI*argvPtrfR will be filled in with the address of an array of
- pointers to the strings that are the extracted elements of fIpathfR.
- There will be fI*argcPtrfR valid entries in the array, followed by
- a NULL entry.
- .AP int argc in
- Number of elements in fIargvfR.
- .AP "CONST char * CONST" *argv in
- Array of path elements to merge together into a single path.
- .AP Tcl_DString *resultPtr in/out
- A pointer to an initialized fBTcl_DStringfR to which the result of
- fBTcl_JoinPathfR will be appended.
- .BE
- .SH DESCRIPTION
- .PP
- These procedures have been superceded by the objectified procedures in
- the fBFileSystemfR man page, which are more efficient.
- .PP
- These procedures may be used to disassemble and reassemble file
- paths in a platform independent manner: they provide C-level access to
- the same functionality as the fBfile splitfR, fBfile joinfR, and
- fBfile pathtypefR commands.
- .PP
- fBTcl_SplitPathfR breaks a path into its constituent elements,
- returning an array of pointers to the elements using fIargcPtrfR and
- fIargvPtrfR. The area of memory pointed to by fI*argvPtrfR is
- dynamically allocated; in addition to the array of pointers, it also
- holds copies of all the path elements. It is the caller's
- responsibility to free all of this storage.
- For example, suppose that you have called fBTcl_SplitPathfR with the
- following code:
- .CS
- int argc;
- char *path;
- char **argv;
- &...
- Tcl_SplitPath(string, &argc, &argv);
- .CE
- Then you should eventually free the storage with a call like the
- following:
- .CS
- Tcl_Free((char *) argv);
- .CE
- .PP
- fBTcl_JoinPathfR is the inverse of fBTcl_SplitPathfR: it takes a
- collection of path elements given by fIargcfR and fIargvfR and
- generates a result string that is a properly constructed path. The
- result string is appended to fIresultPtrfR. fIResultPtrfR must
- refer to an initialized fBTcl_DStringfR.
- .PP
- If the result of fBTcl_SplitPathfR is passed to fBTcl_JoinPathfR,
- the result will refer to the same location, but may not be in the same
- form. This is because fBTcl_SplitPathfR and fBTcl_JoinPathfR
- eliminate duplicate path separators and return a normalized form for
- each platform.
- .PP
- fBTcl_GetPathTypefR returns the type of the specified fIpathfR,
- where fBTcl_PathTypefR is one of fBTCL_PATH_ABSOLUTEfR,
- fBTCL_PATH_RELATIVEfR, or fBTCL_PATH_VOLUME_RELATIVEfR. See the
- fBfilenamefR manual entry for a description of the path types for
- each platform.
- .SH KEYWORDS
- file, filename, join, path, split, type