TIP #431: ADD 'TEMPDIR' SUBCOMMAND TO 'FILE'
==============================================
Version: $Revision: 1.1 $
Author: Kevin Pasko <kevin.a.pasko_at_gmail.com>
State: Draft
Type: Project
Tcl-Version: 8.6.3
Vote: Pending
Created: Wednesday, 10 September 2014
URL: http://purl.org/tcl/tip/431.html
WebEdit: http://purl.org/tcl/tip/edit/431
Post-History:
-------------------------------------------------------------------------
ABSTRACT
==========
This TIP proposes adding a new *tempdir* subcommand to the *file*
command, simplifying the effort required in creating uniquely named
temporary directories at the scripting level.
RATIONALE
===========
Due to the non-atomic nature of the *file mkdir* command it is
currently impossible to create uniquely named temporary directories at
the script level without the possibility of race conditions.
SPECIFICATION
===============
The *file tempdir* command shall implement the functionality of the
POSIX standard mkdtemp() function. With no arguments *file tempdir*
shall create a uniquely named temporary directory in the native
operating system's temporary directory, with naming convention
"*tcl_*/XXXXXX/" where each /X/ is a randomly selected character
(following the *file tempfile* naming convention). Successful
completion of *file tempdir* shall return the absolute path of the
created directory, otherwise an error shall be thrown.
*file tempdir* shall have an optional argument, /template/, to modify
the created directory's path and name. The /template/ shall be
decomposed into (up to) two parts: the directory's path and rootname.
If either part is absent, relevant defaults (e.g., according to the
native operating system) shall be used. The entire temporary name shall
then be formed from the path, the root, and a generated unique string
of (typically) six characters.
The command syntax should be defined as:
*file tempdir* ?/template/?
CONSIDERATIONS
================
* The subcommand *tempdir* could be a candidate, later, for
returning the native file system's temporary directory. Naming
the subcommand something else such as *mktempdir* is another
option, though strays from the *file tempfile* naming convention.
* For future extensibility the *template* argument to *file
tempdir* (since it is optional) could be specified in the key /
value format, *-template*, changing the command syntax to:
*file tempdir* ?/options.../?
REFERENCE IMPLEMENTATION
==========================
An example of temporary directory creation has already been developed
into the Tcl core, at the C level, within the platform specific layers
of the *load* command. The principal work remaining is to expose this
via a Tcl command.
COPYRIGHT
===========
This document has been placed in the public domain.
-------------------------------------------------------------------------
TIP AutoGenerator - written by Donal K. Fellows
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core