summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-07-22 20:02:39 +0000
committerDevang Patel <dpatel@apple.com>2008-07-22 20:02:39 +0000
commitc5552c44a03c1ef90ca7184b13b1a6f30bbe196f (patch)
tree9d3682d423a6a5cd2eee13a4e9a1b054602cd42e /llvm/lib/System/Unix
parenta2fbefc1593b69b5a4cfc525da899cff242ca2cd (diff)
downloadbcm5719-llvm-c5552c44a03c1ef90ca7184b13b1a6f30bbe196f.tar.gz
bcm5719-llvm-c5552c44a03c1ef90ca7184b13b1a6f30bbe196f.zip
While creating temp. file on disk, if the current filename points to a existing directory then create new temp. file inside the directory.
llvm-svn: 53929
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Path.inc10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc
index 1de594b8664..a0def8d5125 100644
--- a/llvm/lib/System/Unix/Path.inc
+++ b/llvm/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;
OpenPOWER on IntegriCloud