Check-in [5a37bbd45d]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added link to ref.impl.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:5a37bbd45d679ad38041da678b89dd6ec99e1c814fde8f61cdce7633a91640b4
User & Date: dkf 2008-11-18 14:21:25
Context
2008-11-18
16:22
corrected the targetted version of Tcl; no new features for 8.5 are admitted check-in: be2bce2306 user: dkf tags: trunk
14:21
Added link to ref.impl. check-in: 5a37bbd45d user: dkf tags: trunk
2008-11-16
22:58
Revision through web from Alexandre Ferrieux <alexandre.ferrieux@gmail.com> Added implementation of the type dependent part. check-in: fc09503cdc user: tclhttpd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tip/210.tip.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

41


42
43
44
45
46

47
48
49
50
51
52

53









54
55
56
57
TIP:            210
Title:          Add 'tempname' Subcommand to 'file'
Version:        $Revision: 1.5 $
Author:         Bob Techentin <techentin.robert@mayo.edu>
State:          Draft
Type:           Project
Vote:           Pending
Created:        19-Jul-2004
Post-History:   
Keywords:       Tcl,filename
Tcl-Version:    8.6

~ Abstract

Programmers often need to create temporary files.  This TIP proposes
adding the new subcommand '''tempname''' to the '''file''' command,
simplifying programmer effort in creating a unique temporary file
name.

~ Rationale

Creating temporary files is a primitive and common enough operation
that the ANSI C standard defines several subroutines to assist
programmers.  The ''tmpnam()'' function generates a string that is a
valid file name that is not the name of an existing file.  The
''tmpfile()'' function returns a valid file pointer to a temporary
file that is removed automatically when it is closed or at program
termination.  Both functions are commonly used by programmers, without
worrying about the optimal location for temporary files or schemes
required to create unique file names.

Tcl has not supported temporary files, so programmers have had to
write code to generate unique file names and choose locations like
''/tmp'' or ''c://temp.''  The ''fileutil'' module of tcllib provides
a relatively sophisticated implementation of ''tempfile'', but
extension writers have not been able to rely on this code.  Modules in
Iwidgets, the Tcl plugin, tcllib, and tclx all appear to have this
sort of code, and not all are correct.

This TIP proposes to extend the '''file''' command with one subcommand

to generate temporary files and file names.  By extending the core command, application programmers and extension writers will be able to depend on this functionality for their code, without resorting to copying or depending on tcllib.



~ Specification

This TIP proposes an extension to the ''file''
command, implementing the functionality of the POSIX standard

mkstemp() function.  The new subcommand will be called ''tempfile''.  It will return an open file channel, and (optionally) the name of the temporary file.

~ Synopsis

 > '''file tempfile''' ?''template''? ?''namevar''?


Opens a unique temporary file and returns an open file channel.  If the ''template'' string is specified and non-empty, then characters will be appended to create the unique filename.  If ''namevar'' is specified, then the command will set the variable to the name of the temporary file.










~ Copyright

This document has been placed in the public domain.


|











|
|
|
<



|
|
|
<
|
|
|
|


|
|
|
|
<
|
|

|
>
|
>
>



|
|
>
|





>
|
>
>
>
>
>
>
>
>
>




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
TIP:            210
Title:          Add 'tempname' Subcommand to 'file'
Version:        $Revision: 1.6 $
Author:         Bob Techentin <techentin.robert@mayo.edu>
State:          Draft
Type:           Project
Vote:           Pending
Created:        19-Jul-2004
Post-History:   
Keywords:       Tcl,filename
Tcl-Version:    8.6

~ Abstract

Programmers often need to create temporary files. This TIP proposes adding the
new subcommand '''tempname''' to the '''file''' command, simplifying
programmer effort in creating a unique temporary file name.


~ Rationale

Creating temporary files is a primitive and common enough operation that the
ANSI C standard defines several subroutines to assist programmers. The
''tmpnam()'' function generates a string that is a valid file name that is not

the name of an existing file. The ''tmpfile()'' function returns a valid file
pointer to a temporary file that is removed automatically when it is closed or
at program termination. Both functions are commonly used by programmers,
without worrying about the optimal location for temporary files or schemes
required to create unique file names.

Tcl has not supported temporary files, so programmers have had to write code
to generate unique file names and choose locations like ''/tmp'' or
''C:\temp''. The ''fileutil'' module of tcllib provides a relatively
sophisticated implementation of ''tempfile'', but extension writers have not

been able to rely on this code. Modules in Iwidgets, the Tcl plugin, tcllib,
and TclX all appear to have this sort of code, and not all are correct.

This TIP proposes to extend the '''file''' command with one subcommand to
generate temporary files and file names. By extending the core command,
application programmers and extension writers will be able to depend on this
functionality for their code, without resorting to copying or depending on
tcllib.

~ Specification

This TIP proposes an extension to the ''file'' command, implementing the
functionality of the POSIX standard mkstemp() function. The new subcommand
will be called ''tempfile''. It will return an open file channel, and
(optionally) the name of the temporary file.

~ Synopsis

 > '''file tempfile''' ?''template''? ?''namevar''?

Opens a unique temporary file and returns an open file channel. If the
''template'' string is specified and non-empty, then characters will be
appended to create the unique filename. If ''namevar'' is specified, then the
command will set the variable to the name of the temporary file. The returned
channel will have been opened in read-write mode (but not append mode) using
the defaults for EOL translation, encoding, etc.

~ Reference Implementation

Available as Tcl Patch #999162 on SourceForge
[https://sourceforge.net/support/tracker.php?aid=999162].

~ Copyright

This document has been placed in the public domain.