[#31320] Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

124 messages 2007/08/01
[#31321] Re: Import RubyGems to Ruby 1.9 — Nobuyoshi Nakada <nobu@...> 2007/08/01

なかだです。

[#31329] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/08/01

-----BEGIN PGP SIGNED MESSAGE-----

[#31918] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31970] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/08

-----BEGIN PGP SIGNED MESSAGE-----

[#32023] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/11

まつもと ゆきひろです

[#32062] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32066] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32068] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32069] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32070] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32073] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32079] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/16

-----BEGIN PGP SIGNED MESSAGE-----

[#32080] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/16

まつもと ゆきひろです

[#32132] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#32081] Re: Import RubyGems to Ruby 1.9 — Takahiro Kambe <taca@...> 2007/10/16

In message <471447D5.5050902@sarion.co.jp>

[#32087] Re: Import RubyGems to Ruby 1.9 — "Akinori MUSHA" <knu@...> 2007/10/17

 Rubygems は、基本的に他のパッケージシステムから包みやすい作り

[#32104] Re: Import RubyGems to Ruby 1.9 — akira yamada <akira@...> 2007/10/20

Tuesday 16 October 2007 14:09:13 に NAKAMURA, Hiroshi さんは書きました:

[#32109] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/20

-----BEGIN PGP SIGNED MESSAGE-----

[#31332] Re: Import RubyGems to Ruby 1.9 — Tadayoshi Funaba <tadf@...> 2007/08/01

> ちなみに「ruby/1.9.1の標準添付からどのライブラリを外すか?」という議論も

[#31858] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/25

-----BEGIN PGP SIGNED MESSAGE-----

[#31872] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/27

-----BEGIN PGP SIGNED MESSAGE-----

[#31905] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/29

-----BEGIN PGP SIGNED MESSAGE-----

[#31906] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/29

まつもと ゆきひろです

[#31910] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31920] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/30

まつもと ゆきひろです

[#31323] Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...>

むらけんです.

16 messages 2007/08/01
[#31326] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31327] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...> 2007/08/01

むらけんです.

[#31328] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31525] いくつかのバグ報告と提案(5点) — eklerni <eklerni@...>

From:eklerni

13 messages 2007/08/20

[#31539] strtod の精度 — Satoshi Nakagawa <snakagawa@...>

中川といいます。

27 messages 2007/08/20
[#31542] Re: strtod の精度 — Yukihiro Matsumoto <matz@...> 2007/08/20

まつもと ゆきひろです

[ruby-dev:31416] Dir.mktmpdir

From: Tanaka Akira <akr@...>
Date: 2007-08-14 12:05:30 UTC
List: ruby-dev #31416
テンポラリディレクトリを作るメソッドを用意するといいと思うん
ですが、どうでしょう?

tmpdir.rb で Dir.mktmpdir というのを定義するのはどうでしょう
か。

* permission は 0700 にする
* ブロックつきで呼んだときは後で消す
** そのときちゃんと FileUtils.remove_entry_secure を使う

Index: lib/tmpdir.rb
===================================================================
--- lib/tmpdir.rb	(リビジョン 12928)
+++ lib/tmpdir.rb	(作業コピー)
@@ -4,6 +4,8 @@
 # $Id$
 #
 
+require 'fileutils'
+
 class Dir
 
   @@systmpdir = '/tmp'
@@ -42,4 +44,60 @@
     end
     File.expand_path(tmp)
   end
+
+  # Dir.mktmpdir creates a temporary directory.
+  #
+  # The directory is created with 0700 permission
+  # under Dir.tmpdir.
+  # The name of the directory is prefixed
+  # with <i>prefix</i> argument.
+  # If <i>prefix</i> is not given,
+  # the prefix "d" is used.
+  #
+  # If a block is given,
+  # it is yielded with the path of the directory.
+  # The directory is removed before Dir.mktmpdir returns.
+  #
+  #  Dir.mktmpdir {|dir|
+  #    # use the directory...
+  #    open("#{dir}/foo", "w") { ... }
+  #  }
+  #
+  # If a block is not given,
+  # The path of the directory is returned.
+  # In this case, Dir.mktmpdir doesn't remove the directory.
+  #
+  #  dir = Dir.mktmpdir
+  #  begin
+  #    # use the directory...
+  #    open("#{dir}/foo", "w") { ... }
+  #  ensure
+  #    # remove the directory.
+  #    FileUtils.remove_entry_secure dir
+  #  end
+  #
+  def Dir.mktmpdir(prefix="d")
+    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
+      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

なお、実装して気がつきましたが、現在は SEGV するようです。
1.8 なら動きます。

% ./ruby -Ilib -rtmpdir -e 'Dir.mktmpdir {|x| p x }'
"/tmp/d20070814-6062-p2zi10"
/home/akr/ruby/yarvo0/ruby/lib/fileutils.rb:696: -- control
frame ----------
c:0006 p:---- s:0027 b:0027 l:000026 d:000026 CFUNC  :euid
c:0005 p:0213 s:0024 b:0024 l:000023 d:000023 METHOD
/home/akr/ruby/yarvo0/ruby/lib/fileutils.rb:696
c:0004 p:0150 s:0014 b:0013 l:000012 d:000012 METHOD
/home/akr/ruby/yarvo0/ruby/lib/tmpdir.rb:97
c:0003 p:0013 s:0005 b:0005 l:000004 d:000004 TOP    -e:1
c:0002 p:---- s:0003 b:0003 l:000002 d:000002 FINISH
:inherited
c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------ 
---------------------------
DBG> : "/home/akr/ruby/yarvo0/ruby/lib/fileutils.rb:696:in
DBG> : `remove_entry_secure'"
DBG> : "/home/akr/ruby/yarvo0/ruby/lib/tmpdir.rb:97:in
DBG> : `mktmpdir'"
DBG> : "-e:1:in `<main>'"
-- backtrace of native function call (Use addr2line) --
0x80ec513
0x8105e96
0x8105f2d
0x80bccb5
0xffffe420
0x8073a49
0x80952a1
0x80e98fd
0x80eb5bb
0x80ea47d
0x80e5bb8
0x80e7f55
0x80e86f1
0x805a1c5
0x805a258
0x805716e
0x80570c9
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x80570ef
0x8057128
0xb7e2e974
0x8057001
-------------------------------------------------------
[BUG] Segmentation fault
ruby 1.9.0 (2007-08-14) [i686-linux]
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next