Dir.mktmpdir for 1.8

Dir.mktmpdir e$B$re(B 1.8 e$B$KF~$l$?$$$s$G$9$,!"$I$&$G$7$g$&e(B?

e$B$=$l$O$=$l$H$7$F!"e(B1.8 e$B$G5!G=3HD%$9$k$K$OC/$NN;2r$rF@$l$P$$$$e(B
e$B$s$G$7$?$C$1e(B?

NEWS e$B$r=q$/$H$$$&$N$O3P$($F$$$k$s$G$9$,!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:31462] Dir.mktmpdir for 1.8”
on Sat, 18 Aug 2007 02:07:36 +0900, Tanaka A. [email protected]
writes:

|Dir.mktmpdir e$B$re(B 1.8 e$B$KF~$l$?$$$s$G$9$,!"$I$&$G$7$g$&e(B?

e$B;d$OH?BP$7$^$;$s!#e(B

|e$B$=$l$O$=$l$H$7$F!"e(B1.8 e$B$G5!G=3HD%$9$k$K$OC/$NN;2r$rF@$l$P$$$$e(B
|e$B$s$G$7$?$C$1e(B?

e$B@UG$<T$Oe(Bknue$B$5$s$G$9$M!#e(B

In article E1IMCUq-00083X-Uo@x31,
Yukihiro M. [email protected] writes:

|e$B$=$l$O$=$l$H$7$F!"e(B1.8 e$B$G5!G=3HD%$9$k$K$OC/$NN;2r$rF@$l$P$$$$e(B
|e$B$s$G$7$?$C$1e(B?

e$B@UG$<T$Oe(Bknue$B$5$s$G$9$M!#e(B

e$B5nG/$+$i$Ne(B knu e$B$5$s$N%a!<%k$r$5$i$C$F!"e(B[ruby-dev:29919]
(e$B$He(B [ruby-dev:29979]) e$B$rFI$_D>$7$?7k2L!"e(B

  • e$B8=:_e(B 1.8 e$B$OE`7kCf$G$J$/!"e(B
  • e$BDI2C$J$N$G>e0L8_49$G!"e(B
  • trunk e$B$K$O$9$G$KF~$C$F$$$F!"e(B
  • e$B$$$^$N$H$3$mH?BP0U8+$b$J$$!"e(B
    e$B$N$G!"F~$l$^$7$?!#e(B

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!%V%i%s%A%]%j%7!<$K5-:$N>r7o$rK~$?$7$F$$$l$P$h$/!“E`7k4|4V30$Ke(B
e$B;d$+$i8DJL$NN;>5$r<h$kI,MW$O$”$j$^$;$s!#e(B

e$B$O$$!"N;2r$G$9!#e(B
(e$B%V%i%s%A%]%j%7!<$+$iN;>5$,I,MW$J;~$K$Oe(B - e$BA[Dj$7$F$$$k$N$Oe(B
securerandom.rb e$B$NDI2C$G$9$,e(B - e$BN;>5$r$*4j$$$9$k$3$H$K$J$j$^e(B
e$B$9$,e(B)

e$B!!e(BTempfile#make_tmpname (private)e$B$N$h$&$K%U%!%$%kL>@[email protected],$re(B
e$B%*!<%P!<%i%$%I$9$k<jCJ$,$J$$$3$H$,B?>/5$$K$J$j$^$9$,!":n$C$?e(B
e$B0l;~%G%#%l%/%H%j$NCf$K9%$-$JL>A0$N%G%#%l%/%H%j$r:n$l$P$$$$$N$Ge(B
e$BLdBj$O$J$5$=$&$G$9$M!#e(B

prefix e$B$O0z?t$G;XDj$G$-$k$N$G!“LdBj$Oe(B suffix e$B$G$9$,!”%G%#%le(B
e$B%/%H%j$Ne(B suffix e$B$r;XDj$9$kI,MW@-$OGv$$$@$m$&$H$$$&H=CG$G$9!#e(B
e$B%G%#%l%/%H%j$K3HD%;R$r$D$1$?$$%1!<%9$O$“$^$j$J$$$G$”$m$&$H$$e(B
e$B$&$+!#e(B

e$B$b$7!“$D$1$?$/$J$C$?$i!”$=$&$G$9$M$'!":#9M$($^$7$?$,e(B prefix
e$B$N$H$3$m$Ke(B [prefix, suffix] e$B$H;XDj$9$k$H$+$G$9$+$M!#I,MW@-$,e(B
e$B46$8$i$l$F$+$i$NOC$K$J$j$^$9$,!“3HD%$KL5M}$,$”$k$H$$$&$3$H$Oe(B
e$B$J$5$=$&$G$9!#e(B

At Sat, 18 Aug 2007 21:42:42 +0900,
Tanaka A. wrote:

In article E1IMCUq-00083X-Uo@x31,
Yukihiro M. [email protected] writes:

|それはそれとして、1.8 で機能拡張するには誰の了解を得ればいい
|んでしたっけ?

責任者はknuさんですね。

 ブランチポリシーに記載の条件を満たしていればよく、凍結期間外に
私から個別の了承を取る必要はありません。

去年からの knu さんのメールをさらって、[ruby-dev:29919]
(と [ruby-dev:29979]) を読み直した結果、

  • 現在 1.8 は凍結中でなく、
  • è¿½åŠ ãªã®ã§ä¸Šä½äº’æ›ã§ã€
  • trunk にはすでに入っていて、
  • いまのところ反対意見もない、
    ので、入れました。

 個人的にも欲しい機能でした。

 Tempfile#make_tmpname (private)のようにファイル名生成部分を
オーバーライドする手段がないことが多少気になりますが、作った
一時ディレクトリの中に好きな名前のディレクトリを作ればいいので
問題はなさそうですね。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

In article [email protected],
“Akinori MUSHA” [email protected] writes:

e$B!!Nc$H$7$F!"e(B Mac OS X e$B$G$O%G%#%l%/%H%j$K$b3HD%;R$rIU$1$F<oJL$Ne(B
e$BH=Dj$KMQ$$$F$$$^$9!#e(B

e$B!!%"%W%j%1!<%7%g%s$Oe(B .app, Keynote e$B=qN`$Oe(B .key, e$BB?9q8lL>$r;}$De(B
e$B%U%)%k%@$Oe(B .localized e$BEy$G$9!#e(B

e$B!!$3$&$7$?!V%U%!%$%k!W$N0l;~%3%T!<$r:n$C$F=hM}$7$?$j$9$k$H$-$O!"e(B
e$B%5%U%#%C%/%9$r;XDj$G$-$J$$$H$=$N$^$^$G$O;H$($^$;$s!#e(B

e$B$*$)!"$$$-$J$jI,MW@-$r<B46$7$^$7$?!#e(B
e$B$D$1$^$7$g$&!#$F$$$&$+$D$1$^$7$?!#e(B

e$B!!$J$k$[$I!#e(B[prefix, suffix] e$B$G==J,$+$b$7$l$^$;$s$M!#e(BTempfile e$B$be(B
e$B$=$&$7$^$7$g$&$+!#e(B

e$B!!$D$$$G$Ke(B $prefix.$$.$n e$B$H$$$&@8@.5,B’$b$$$^$$$Ae(B(. e$B$r;H$C$F$$$ke(B,
e$BMp?t$r;H$C$F$$$J$$e(B, e$BEye(B)e$B$J$N$GJQ$($?$$$,!“$4CzG+$K%I%-%e%a%s%H$Ke(B
“basename.pid.n” e$B$J$s$FL@5-$7$F$7$^$C$F$$$k$+$i$J$”!D!#e(B

e$B;d$N463P$@$H!“$3$l$OJQ$($FJ86g$,=P$k2DG=@-$O$”$^$j$J$$N`$N5se(B
e$BF0$G$9$N$G!"JQ$($F$b$$$$$s$8$c$J$$$+$H;W$$$^$9$,!#e(B

At Tue, 21 Aug 2007 17:33:06 +0900,
Tanaka A. wrote:

In article [email protected],
“Akinori MUSHA” [email protected] writes:

 ブランチポリシーに記載の条件を満たしていればよく、凍結期間外に
私から個別の了承を取る必要はありません。

はい、了解です。
(ブランチポリシーから了承が必要な時には - 想定しているのは
securerandom.rb ã®è¿½åŠ ã§ã™ãŒ - 了承をお願いすることになりま
すが)

 わかりました。MLでの議論を読み返しておきます。

 Tempfile#make_tmpname (private)のようにファイル名生成部分を
オーバーライドする手段がないことが多少気になりますが、作った
一時ディレクトリの中に好きな名前のディレクトリを作ればいいので
問題はなさそうですね。

prefix は引数で指定できるので、問題は suffix ですが、ディレ
クトリの suffix を指定する必要性は薄いだろうという判断です。
ディレクトリに拡張子をつけたいケースはあまりないであろうとい
うか。

 例として、 Mac OS X ではディレクトリにも拡張子を付けて種別の
判定に用いています。

 アプリケーションは .app, Keynote 書類は .key, 多国語名を持つ
フォルダは .localized 等です。

 こうした「ファイル」の一時コピーを作って処理したりするときは、
サフィックスを指定できないとそのままでは使えません。

もし、つけたくなったら、そうですねぇ、今考えましたが prefix
のところに [prefix, suffix] と指定するとかですかね。必要性が
感じられてからの話になりますが、拡張に無理があるということは
なさそうです。

 なるほど。[prefix, suffix] で十分かもしれませんね。Tempfile も
そうしましょうか。

 ついでに $prefix.$$.$n という生成規則もいまいち(. を使っている,
乱数を使っていない, 等)なので変えたいが、ご丁寧にドキュメントに
“basename.pid.n” なんて明記してしまっているからなあ…。

Index: tempfile.rb

— tempfile.rb (revision 13119)
+++ tempfile.rb (working copy)
@@ -15,9 +15,15 @@
@@cleanlist = []
@@lock = Mutex.new

  • Creates a temporary file of mode 0600 in the temporary directory

  • whose name is basename.pid.n and opens with mode “w+”. A Tempfile

  • object works just like a File object.

  • Creates a temporary file of mode 0600 in the temporary directory,

  • opens it with mode “w+”, and returns a Tempfile object which

  • represents the created temporary file. A Tempfile object can be

  • treated just like a normal File object.

  • The basename parameter is used to determine the name of a

  • temporary file. If an Array is given, the first element is used

  • as prefix and the second as suffix, respectively. Otherwise it is

  • treated as a string and used as prefix.

    If tmpdir is omitted, the temporary directory is determined by

    Dir::tmpdir provided by ‘tmpdir.rb’.

@@ -65,7 +71,12 @@
end

def make_tmpname(basename, n)

  • sprintf(‘%s.%d.%d’, basename, $$, n)
  • case basename
  • when Array
  •  sprintf('%s.%d.%d%s', basename[0], $$, n, basename[1])
    
  • else
  •  sprintf('%s.%d.%d', basename, $$, n)
    
  • end
    end
    private :make_tmpname


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”