Mercurial > hg
changeset 20980:6fb4c94ae300
vfs: add "mkstemp()"
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 09 Mar 2014 01:03:28 +0900 |
parents | ad5b61370514 |
children | 4fdd1172d37e |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/scmutil.py Sun Mar 09 01:03:28 2014 +0900 +++ b/mercurial/scmutil.py Sun Mar 09 01:03:28 2014 +0900 @@ -10,7 +10,7 @@ import util, error, osutil, revset, similar, encoding, phases, parsers import pathutil import match as matchmod -import os, errno, re, glob +import os, errno, re, glob, tempfile if os.name == 'nt': import scmwindows as scmplatform @@ -193,6 +193,15 @@ def mkdir(self, path=None): return os.mkdir(self.join(path)) + def mkstemp(self, suffix='', prefix='tmp', dir=None, text=False): + fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, + dir=self.join(dir), text=text) + dname, fname = util.split(name) + if dir: + return fd, os.path.join(dir, fname) + else: + return fd, fname + def readdir(self, path=None, stat=None, skip=None): return osutil.listdir(self.join(path), stat, skip)