From: Joe Swatosh Date: 2012-04-07T14:14:38+09:00 Subject: [ruby-core:44177] Re: [Backport #1975] Backport Dir.mktmpdir ------=_Part_949_18813258.1333775604459 Content-Type: multipart/alternative; boundary="----=_Part_950_11023545.1333775604459" ------=_Part_950_11023545.1333775604459 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Friday, August 21, 2009 7:17:28 PM UTC-7, Tanaka Akira wrote: > > In article <4a8e914c6160_2100affe60043c6@redmine.ruby-lang.org>, > Kirk Haines writes: > > > Dir.mktmpdir exists in 1.8 HEAD and 1.8.7, and is used in the test suite > for Backport #1168, so it needs to be backported to 1.8.6 to facilitate use > of the existing test suite. > > It is possible to copy Dir.mktmpdir to the test suite. > > When I needed Dir.mktmpdir for bootstraptest/runner.rb in > 1.9 which may be run by 1.8.6, I copied it. > -- > Tanaka Akira > Sorry for reviving such a long dead thread, but it is the only thing that I've been able to find that seems remotely related. I'm working on a project that is using Dir.mktmpdir. I'd like to maintain some backward compatibility with 1.8.6 and to that end was thinking of adding something simple like: unless Dir.respond_to?(:mktmpdir) def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil) case prefix_suffix when nil prefix = "d" suffix = "" when String prefix = prefix_suffix suffix = "" when Array prefix = prefix_suffix[0] suffix = prefix_suffix[1] else raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}" end tmpdir ||= Dir.tmpdir t = Time.now.strftime("%Y%m%d") n = nil begin path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}" path << "-#{n}" if n path << suffix Dir.mkdir(path, 0700) rescue Errno::EEXIST n ||= 0 n += 1 retry end if block_given? begin yield path ensure FileUtils.remove_entry_secure path end else path end end end Just a copy-paste from tmpdir.rb from the lib of a 1.8.7 installation wrapped in a respond_to? into one of my project's files. What I want to know is how to properly attribute the code in our project from the 1.8.7 lib? There is no statement in the file, and I can find nothing in the installation or several searches with google. Can't reuse this code unless I can acknowledge where it comes from, please let me know how to to this correctly. Thanks, -- Joe ------=_Part_950_11023545.1333775604459 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Friday, August 21, 2009 7:17:28 PM UTC-7, Tanaka Akira wrote:In article <4a8e914c6= 160_2100affe60043c6@redmine.ruby-lang.org>,
  Kirk Hain= es <redmine@r= uby-lang.org> writes:

> Dir.mktmpdir exists in 1.8 HEAD and 1.8= .7, and is used in the test suite for Backport #1168, so it needs to be bac= kported to 1.8.6 to facilitate use of the existing test suite.

It is = possible to copy Dir.mktmpdir to the test suite.

When I needed Dir.mk= tmpdir for bootstraptest/runner.rb in
1.9 which may be run by 1.8.6, I c= opied it.
--
Tanaka Akira

Sorry for reviving su= ch a long dead thread, but it is the only thing that I've been able to find= that seems remotely related. I'm working on a project that is using D= ir.mktmpdir. I'd like to maintain some backward compatibility with 1.8= .6 and to that end was thinking of adding something simple like:
=
unless Dir.respond_to?(:mktmpdir)
  def = Dir.mktmpdir(prefix_suffix=3Dnil, tmpdir=3Dnil)
    cas= e prefix_suffix
    when nil
    &n= bsp; prefix =3D "d"
      suffix =3D ""
=     when String
      prefix =3D prefix_= suffix
      suffix =3D ""
   = when Array
      prefix =3D prefix_suffix[0]
      suffix =3D prefix_suffix[1]
  &nb= sp; else
      raise ArgumentError, "unexpected pr= efix_suffix: #{prefix_suffix.inspect}"
    end
    tmpdir ||=3D Dir.tmpdir
    t =3D Time.= now.strftime("%Y%m%d")
    n =3D nil
  &= nbsp; begin
      path =3D "#{tmpdir}/#{prefix}#{t= }-#{$$}-#{rand(0x100000000).to_s(36)}"
      path = << "-#{n}" if n
      path << suffix
      Dir.mkdir(path, 0700)
   = rescue Errno::EEXIST
      n ||=3D 0
&n= bsp;     n +=3D 1
      retry
=     end

    if block_given?
      begin
        yi= eld path
      ensure
    &nbs= p;   FileUtils.remove_entry_secure path
     = end
    else
      path
=
    end
  end
end
<= br>
Just a copy-paste from tmpdir.rb from the lib of a 1.8.7 inst= allation wrapped in a respond_to? into one of my project's files. What I wa= nt to know is how to properly attribute the code in our project from the 1.= 8.7 lib? There is no statement in the file, and I can find nothing in the i= nstallation or several searches with google.

Can't= reuse this code unless I can acknowledge where it comes from, please let m= e know how to to this correctly.

Thanks,
--
Joe
------=_Part_950_11023545.1333775604459-- ------=_Part_949_18813258.1333775604459--