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

NAME

8       Tcl_TranslateFileName  -  convert  file name to native form and replace
9       tilde with home directory
10

SYNOPSIS

12       #include <tcl.h>
13
14       char *
15       Tcl_TranslateFileName(interp, name, bufferPtr)
16

ARGUMENTS

18       Tcl_Interp *interp (in)              Interpreter in which to report  an
19                                            error, if any.
20
21       const char *name (in)                File  name, which may start with a
22                                            “~”.
23
24       Tcl_DString *bufferPtr (in/out)      If needed, this dynamic string  is
25                                            used  to  store the new file name.
26                                            At the time of the call it  should
27                                            be  uninitialized  or  free.   The
28                                            caller   must   eventually    call
29                                            Tcl_DStringFree  to  free  up any‐
30                                            thing stored here.
31______________________________________________________________________________
32

DESCRIPTION

34       This utility procedure translates a file name  to  a  platform-specific
35       form which, after being converted to the appropriate encoding, is suit‐
36       able for passing to the local operating system.  In particular, it con‐
37       verts network names into native form and does tilde substitution.
38
39       However,  with  the  advent  of  the  newer Tcl_FSGetNormalizedPath and
40       Tcl_FSGetNativePath, there is no longer any need to use this procedure.
41       In  particular, Tcl_FSGetNativePath performs all the necessary transla‐
42       tion and encoding conversion, is virtual-filesystem aware,  and  caches
43       the  native  result  for  faster  repeated calls.  Finally Tcl_FSGetNa‐
44       tivePath does not require you to free anything afterwards.
45
46       If Tcl_TranslateFileName has to do tilde substitution or translate  the
47       name  then  it  uses  the  dynamic string at *bufferPtr to hold the new
48       string it generates.  After Tcl_TranslateFileName  returns  a  non-NULL
49       result,  the  caller must eventually invoke Tcl_DStringFree to free any
50       information placed in *bufferPtr.  The caller need not know whether  or
51       not Tcl_TranslateFileName actually used the string;  Tcl_TranslateFile‐
52       Name initializes *bufferPtr even if it does not use it, so the call  to
53       Tcl_DStringFree will be safe in either case.
54
55       If  an  error occurs (e.g. because there was no user by the given name)
56       then NULL is returned and an error message will be left in  the  inter‐
57       preter's result.  When an error occurs, Tcl_TranslateFileName frees the
58       dynamic string itself so that the caller need not call Tcl_DStringFree.
59
60       The caller is responsible for making sure that the interpreter's result
61       has its default empty value when Tcl_TranslateFileName is invoked.
62

SEE ALSO

64       filename(n)
65

KEYWORDS

67       file name, home directory, tilde, translate, user
68
69
70
71Tcl                                   8.1             Tcl_TranslateFileName(3)
Impressum