Return the path to a temp clean configuration dir, for tests and safe mode.
544034
def get_clean_conf_dir():
    
    if sys.platform.startswith("win"):
        current_user = ''
    else:
        current_user = '-' + str(getpass.getuser())

    conf_dir = osp.join(str(tempfile.gettempdir()),
                        'pytest-spyder{0!s}'.format(current_user),
                        SUBFOLDER)
    return conf_dir
1308443
private Path getTempDir() {
    if (this.tempDir == null) {
      if (this.dir != null) {
        this.tempDir = dir;
      } else {
        this.tempDir = getProject().getBaseDir().toPath();
      }
    }
    return tempDir;
  }
1237819
def _cleanup_tempdir(tempdir):
    """"""
    try:
        shutil.rmtree(tempdir)
    except OSError as err:
        if err.errno != errno.ENOENT:
            raise
876337
def cleanup_tmpdir(dirname):
    """"""
    if dirname is not None and os.path.exists(dirname):
        shutil.rmtree(dirname)
337545
def get_temp_dir(keep=False):
    

    dname = tempfile.mkdtemp(prefix="scapy")

    if not keep:
        conf.temp_files.append(dname)

    return dname
732827
def _clear_temp_dir():
    
    tempdir = get_tempdir()
    for fname in os.listdir(tempdir):
        try:
            os.remove( os.path.join(tempdir, fname) )
        except Exception:
            pass
138171
def clean_path(root, path, subdir=False):
    '''
    
    '''
    if not os.path.isabs(root):
        return ''
    if not os.path.isabs(path):
        path = os.path.join(root, path)
    path = os.path.normpath(path)
    if subdir:
        if path.startswith(root):
            return path
    else:
        if os.path.dirname(path) == os.path.normpath(root):
            return path
    return ''
54865
def config_dir(mkcustom=False):
    
    from acorn.utility import reporoot
    from acorn.base import testmode
    from os import path
    alternate = path.join(path.abspath(path.expanduser("~")), ".acorn")
    if testmode or (not path.isdir(alternate) and not mkcustom):
        return path.join(reporoot, "acorn", "config")
    else:
        if mkcustom:# pragma: no cover
            #This never gets reached when we are in testmode because we don't
            #want to clobber the user's local config cache.
            from os import mkdir
            mkdir(alternate)
        return alternate
329894
def get_tmpdir():
    
    global __tmpdir
    if __tmpdir is not None:
        return __tmpdir

    __tmpdir = tempfile.mkdtemp(prefix='.tmp.glerbl.', dir=".")
    atexit.register(__clean_tmpdir)

    return __tmpdir
539972
def full_path(self):
		
		return self.normalize_path(self.directory_sep().join((self.start_path(), self.session_path())))
1117355
public static PathImpl getTmpWorkDir()
  {
    String userName = System.getProperty("user.name");
    
    PathImpl path;
    // Windows uses /temp as a work dir
    if (com.caucho.v5.util.CauchoUtil.isWindows()
        && ! CurrentTime.isTest())
      path = VfsOld.lookup("file:/c:/tmp/" + userName);
    else
      path = VfsOld.lookup("file:/tmp/" + userName);
    
    return path;
  }
90308
def _cache_directory(self):
        
        if settings.unit_testing_mode or settings.use_test_cache:
            return os.path.join(settings.cache_directory.replace("Fortpy", "Fortpy_Testing"), self.py_tag)
        else:
            return os.path.join(settings.cache_directory, self.py_tag)
663288
def cleanup_environment():
    
    SERV.terminate()
    shutil.rmtree(TMP_PATH)
    if os.path.exists(TMP_PATH):
        os.rmdir(TMP_PATH)

    global TMP_PATH
    TMP_PATH = None
1048898
def getpath(cmd, name=None, url=None, cfg="~/.jcvirc", warn="exit"):
    
    p = which(cmd)  # if in PATH, just returns it
    if p:
        return p

    PATH = "Path"
    config = RawConfigParser()
    cfg = op.expanduser(cfg)
    changed = False
    if op.exists(cfg):
        config.read(cfg)

    assert name is not None, "Need a program name"

    try:
        fullpath = config.get(PATH, name)
    except NoSectionError:
        config.add_section(PATH)
        changed = True
    except:
        pass

    try:
        fullpath = config.get(PATH, name)
    except NoOptionError:
        msg = "=== Configure path for {0} ===\n".format(name, cfg)
        if url:
            msg += "URL: {0}\n".format(url)
        msg += "[Directory that contains `{0}`]: ".format(cmd)
        fullpath = input(msg).strip()
        config.set(PATH, name, fullpath)
        changed = True

    path = op.join(op.expanduser(fullpath), cmd)
    if warn == "exit":
        try:
            assert is_exe(path), \
                "***ERROR: Cannot execute binary `{0}`. ".format(path)
        except AssertionError as e:
            sys.exit("{0!s}Please verify and rerun.".format(e))

    if changed:
        configfile = open(cfg, "w")
        config.write(configfile)
        logging.debug("Configuration written to `{0}`.".format(cfg))

    return path
785965
def temp_dir(remover=shutil.rmtree):
	
	temp_dir = tempfile.mkdtemp()
	try:
		yield temp_dir
	finally:
		remover(temp_dir)
643017
private File getTmpDir(ProbeTestRun testRun) {
		File tmpDir = new File(configuration.getWorkspace() + "/tmp/" + testRun.getVersion());
		
		if (!tmpDir.exists()) {
			tmpDir.mkdirs();
		}
		
		return tmpDir;
	}
829777
def get_config_path():
    """"""
    dir_path = (os.getenv('APPDATA') if os.name == "nt"
                else os.path.expanduser('~'))
    return os.path.join(dir_path, '.vtjp')