Temporary Directory Specification
Temporary Directory Specification

Allow the user to set the area for intermediate files


Declare temp file directory (temp_file_prefix)
Variable declaration
Notes
This variable is injected to make sure that the notion of a temporary space is mutable.
Segment Source
 179: /* Prefix for temporary file names. */
 180: static char *temp_file_prefix;
 181: 

Insert user message text
Segment Element
Text insertion

 235:   -T DIRECT        use DIRECT for temporary files, not $TMPDIR or %s\n\

Segment Element
Argument insertion

 248:               , DEFAULT_TMPDIR);

Extend tempname()

Convert the constant temporary directory to a mutable one.
Segment Element
Code modification

 405:   int len = strlen (temp_file_prefix);

Segment Element
Code modification

 412:            temp_file_prefix,

Segment Element
Code modification

 413:            (len && temp_file_prefix[len - 1] != '/') ? "/" : "",

Initialize TempDir variables
Code insertion
Segment Source
1738:   temp_file_prefix = getenv ("TMPDIR");
1739:   if (temp_file_prefix == NULL)
1740:     temp_file_prefix = DEFAULT_TMPDIR;
1741: 

Parse TempDir option (-T)
Code insertion
Segment Source
1987:                   case 'T':
1988:                     if (s[1])
1989:                       temp_file_prefix = ++s;
1990:                     else
1991:                       {
1992:                         if (i < argc - 1)
1993:                           temp_file_prefix = argv[++i];
1994:                         else
1995:                           error (SORT_FAILURE, 0,
1996:                                  _("option `-T' requires an argument"));
1997:                       }
1998:                     goto outer;
1999:                     /* break; */