在 Ruby on Rails 中获取空临时目录的最佳方法是什么? [英] What is the best way to get an empty temporary directory in Ruby on Rails?

查看:43
本文介绍了在 Ruby on Rails 中获取空临时目录的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Ruby on Rails 获取一个没有任何内容的临时目录的最佳方法是什么?我需要 API 是跨平台兼容的.stdlib tmpdir 将不起作用.

What is the best way to get a temporary directory with nothing in it using Ruby on Rails? I need the API to be cross-platform compatible. The stdlib tmpdir won't work.

推荐答案

Ruby 核心中的 Dir#tmpdir 函数(不是您链接的 stdlib)应该是跨平台的.

The Dir#tmpdir function in the Ruby core (not stdlib that you linked to) should be cross-platform.

要使用这个函数,你需要require 'tmpdir'.

To use this function you need to require 'tmpdir'.

这篇关于在 Ruby on Rails 中获取空临时目录的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆