1Tcl_TranslateFileName(3) Tcl Library Procedures Tcl_TranslateFileName(3)
2
3
4
5______________________________________________________________________________
6
8 Tcl_TranslateFileName - convert file name to native form and replace
9 tilde with home directory
10
12 #include <tcl.h>
13
14 char *
15 Tcl_TranslateFileName(interp, name, bufferPtr)
16
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
33
35 This utility procedure translates a file name to a platform-specific
36 form which, after being converted to the appropriate encoding, is suit‐
37 able for passing to the local operating system. In particular, it con‐
38 verts network names into native form and does tilde substitution.
39
40 However, with the advent of the newer Tcl_FSGetNormalizedPath and
41 Tcl_GetNativePath, there is no longer any need to use this procedure.
42 In particular, Tcl_GetNativePath performs all the necessary translation
43 and encoding conversion, is virtual-filesystem aware, and caches the
44 native result for faster repeated calls. Finally Tcl_GetNativePath
45 does not require you to free anything afterwards.
46
47 If Tcl_TranslateFileName has to do tilde substitution or translate the
48 name then it uses the dynamic string at *bufferPtr to hold the new
49 string it generates. After Tcl_TranslateFileName returns a non-NULL
50 result, the caller must eventually invoke Tcl_DStringFree to free any
51 information placed in *bufferPtr. The caller need not know whether or
52 not Tcl_TranslateFileName actually used the string; Tcl_TranslateFile‐
53 Name initializes *bufferPtr even if it does not use it, so the call to
54 Tcl_DStringFree will be safe in either case.
55
56 If an error occurs (e.g. because there was no user by the given name)
57 then NULL is returned and an error message will be left in the inter‐
58 preter's result. When an error occurs, Tcl_TranslateFileName frees the
59 dynamic string itself so that the caller need not call Tcl_DStringFree.
60
61 The caller is responsible for making sure that the interpreter's result
62 has its default empty value when Tcl_TranslateFileName is invoked.
63
64
66 filename
67
68
70 file name, home directory, tilde, translate, user
71
72
73
74Tcl 8.1 Tcl_TranslateFileName(3)