From: Devang Patel Date: Tue, 22 Jul 2008 20:02:39 +0000 (+0000) Subject: While creating temp. file on disk, if the current filename points to a existing direc... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ce8fdf105c313aa35b93e5a77ae5461e27ddebb0;p=oota-llvm.git While creating temp. file on disk, if the current filename points to a existing directory then create new temp. file inside the directory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53929 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 1de594b8664..a0def8d5125 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -746,8 +746,14 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) { // Append an XXXXXX pattern to the end of the file for use with mkstemp, // mktemp or our own implementation. char *FNBuffer = (char*) alloca(path.size()+8); - path.copy(FNBuffer,path.size()); - strcpy(FNBuffer+path.size(), "-XXXXXX"); + if (isDirectory()) { + std::string dirPath = getDirname(); + strcpy(FNBuffer, dirPath.c_str()); + strcpy(FNBuffer+dirPath.size(), "XXXXXX"); + } else { + path.copy(FNBuffer,path.size()); + strcpy(FNBuffer+path.size(), "-XXXXXX"); + } #if defined(HAVE_MKSTEMP) int TempFD;