[llvm-commits] [llvm] r139725 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp

Francois Pichet pichet2000 at gmail.com
Wed Sep 14 16:11:00 PDT 2011


On Wed, Sep 14, 2011 at 4:27 PM, Douglas Gregor <dgregor at apple.com> wrote:
> Author: dgregor
> Date: Wed Sep 14 15:27:01 2011
> New Revision: 139725
>
> URL: http://llvm.org/viewvc/llvm-project?rev=139725&view=rev
> Log:
> Add a simple routine to determine the typical system directory for
> temporary data.
>
> Modified:
>    llvm/trunk/include/llvm/Support/PathV2.h
>    llvm/trunk/lib/Support/PathV2.cpp
>
> Modified: llvm/trunk/include/llvm/Support/PathV2.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=139725&r1=139724&r2=139725&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/PathV2.h (original)
> +++ llvm/trunk/include/llvm/Support/PathV2.h Wed Sep 14 15:27:01 2011
> @@ -187,7 +187,7 @@
>  /// @result The root directory of \a path if it has one, otherwise
>  ///               "".
>  const StringRef root_directory(StringRef path);
> -
> +
>  /// @brief Get root path.
>  ///
>  /// Equivalent to root_name + root_directory.
> @@ -264,6 +264,14 @@
>  /// @result true if \a value is a path separator character on the host OS
>  bool is_separator(char value);
>
> +/// @brief Get the typical temporary directory for the system, e.g.,
> +/// "/var/tmp" or "C:/TEMP"
> +///
> +/// @param erasedOnReboot Whether to favor a path that is erased on reboot
> +/// rather than one that potentially persists longer.
> +/// @param Result Holds the resulting path name.
> +void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result);
> +
>  /// @brief Has root name?
>  ///
>  /// root_name != ""
>
> Modified: llvm/trunk/lib/Support/PathV2.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=139725&r1=139724&r2=139725&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/PathV2.cpp (original)
> +++ llvm/trunk/lib/Support/PathV2.cpp Wed Sep 14 15:27:01 2011
> @@ -490,6 +490,36 @@
>   }
>  }
>
> +void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result) {
> +  result.clear();
> +
> +  // Check whether the temporary directory is specified by an environment
> +  // variable.
> +  const char *EnvironmentVariable;
> +#ifdef LLVM_ON_WIN32
> +  EnvironmentVariable = "TEMP";
> +#else
> +  EnvironmentVariable = "TMPDIR";
> +#endif
> +  if (char *RequestedDir = getenv(EnvironmentVariable)) {
> +    result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
> +    return;
> +  }
> +
> +  // Fall back to a system default.
> +  const char *DefaultResult;
> +#ifdef LLVM_ON_WIN32
> +  (void)erasedOnReboot;
> +  DefaultResult = "C:\TEMP";

"C:\\TEMP"




More information about the llvm-commits mailing list