X7ROOT File Manager
Current Path:
/opt/alt/ruby18/lib64/ruby/1.8
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
1.8
/
ðŸ“
..
📄
English.rb
(5.6 KB)
📄
Env.rb
(274 B)
📄
abbrev.rb
(2.5 KB)
📄
base64.rb
(3.37 KB)
📄
benchmark.rb
(17.73 KB)
ðŸ“
bigdecimal
ðŸ“
cgi
📄
cgi-lib.rb
(6.89 KB)
📄
cgi.rb
(73.74 KB)
📄
complex.rb
(12.84 KB)
📄
csv.rb
(24.46 KB)
ðŸ“
date
📄
date.rb
(53.02 KB)
📄
date2.rb
(128 B)
📄
debug.rb
(20.61 KB)
📄
delegate.rb
(8.81 KB)
ðŸ“
digest
📄
digest.rb
(1.12 KB)
ðŸ“
dl
ðŸ“
drb
📄
drb.rb
(19 B)
📄
e2mmap.rb
(4.04 KB)
📄
erb.rb
(21.38 KB)
📄
eregex.rb
(487 B)
📄
expect.rb
(633 B)
📄
fileutils.rb
(42.23 KB)
📄
finalize.rb
(5.38 KB)
📄
find.rb
(1.84 KB)
📄
forwardable.rb
(6.16 KB)
📄
ftools.rb
(6.17 KB)
📄
generator.rb
(8.1 KB)
📄
getoptlong.rb
(14.88 KB)
📄
getopts.rb
(2.25 KB)
📄
gserver.rb
(6.43 KB)
📄
importenv.rb
(590 B)
ðŸ“
io
📄
ipaddr.rb
(21.96 KB)
ðŸ“
irb
📄
irb.rb
(7.43 KB)
📄
jcode.rb
(4.3 KB)
📄
kconv.rb
(8.12 KB)
📄
logger.rb
(17.59 KB)
📄
mailread.rb
(1.28 KB)
📄
mathn.rb
(5.42 KB)
📄
matrix.rb
(27.21 KB)
📄
md5.rb
(411 B)
📄
mkmf.rb
(50.65 KB)
📄
monitor.rb
(7.93 KB)
📄
mutex_m.rb
(2.07 KB)
ðŸ“
net
📄
observer.rb
(5.15 KB)
📄
open-uri.rb
(20.49 KB)
📄
open3.rb
(2.1 KB)
ðŸ“
openssl
📄
openssl.rb
(575 B)
ðŸ“
optparse
📄
optparse.rb
(47.12 KB)
📄
ostruct.rb
(3.35 KB)
📄
parsearg.rb
(1.55 KB)
📄
parsedate.rb
(1.33 KB)
📄
pathname.rb
(29.39 KB)
📄
ping.rb
(1.48 KB)
📄
pp.rb
(15.97 KB)
📄
prettyprint.rb
(18.33 KB)
📄
profile.rb
(90 B)
📄
profiler.rb
(1.59 KB)
📄
pstore.rb
(11.15 KB)
ðŸ“
racc
📄
rational.rb
(12.05 KB)
ðŸ“
rdoc
📄
readbytes.rb
(835 B)
📄
resolv-replace.rb
(1.55 KB)
📄
resolv.rb
(56.83 KB)
ðŸ“
rexml
ðŸ“
rinda
ðŸ“
rss
📄
rss.rb
(504 B)
📄
rubyunit.rb
(180 B)
ðŸ“
runit
📄
scanf.rb
(20.63 KB)
📄
securerandom.rb
(4.27 KB)
📄
set.rb
(27.08 KB)
📄
sha1.rb
(418 B)
ðŸ“
shell
📄
shell.rb
(4.66 KB)
📄
shellwords.rb
(3.99 KB)
📄
singleton.rb
(8.08 KB)
ðŸ“
soap
📄
sync.rb
(6.09 KB)
📄
tempfile.rb
(4.86 KB)
ðŸ“
test
📄
thread.rb
(104 B)
📄
thwait.rb
(4.32 KB)
📄
time.rb
(31.58 KB)
📄
timeout.rb
(3 KB)
📄
tmpdir.rb
(3.69 KB)
📄
tracer.rb
(2.73 KB)
📄
tsort.rb
(7.99 KB)
📄
un.rb
(4.54 KB)
ðŸ“
uri
📄
uri.rb
(710 B)
📄
weakref.rb
(2.68 KB)
ðŸ“
webrick
📄
webrick.rb
(811 B)
ðŸ“
wsdl
ðŸ“
x86_64-linux
ðŸ“
xmlrpc
ðŸ“
xsd
ðŸ“
yaml
📄
yaml.rb
(12.36 KB)
Editing: tempfile.rb
# # tempfile - manipulates temporary files # # $Id: tempfile.rb 16127 2008-04-21 09:43:44Z knu $ # require 'delegate' require 'tmpdir' # A class for managing temporary files. This library is written to be # thread safe. class Tempfile < DelegateClass(File) MAX_TRY = 10 @@cleanlist = [] # 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 string and the second as suffix string, respectively. # Otherwise it is treated as prefix string. # # If tmpdir is omitted, the temporary directory is determined by # Dir::tmpdir provided by 'tmpdir.rb'. # When $SAFE > 0 and the given tmpdir is tainted, it uses # /tmp. (Note that ENV values are tainted by default) def initialize(basename, tmpdir=Dir::tmpdir) if $SAFE > 0 and tmpdir.tainted? tmpdir = '/tmp' end lock = nil n = failure = 0 begin Thread.critical = true begin tmpname = File.join(tmpdir, make_tmpname(basename, n)) lock = tmpname + '.lock' n += 1 end while @@cleanlist.include?(tmpname) or File.exist?(lock) or File.exist?(tmpname) Dir.mkdir(lock) rescue failure += 1 retry if failure < MAX_TRY raise "cannot generate tempfile `%s'" % tmpname ensure Thread.critical = false end @data = [tmpname] @clean_proc = Tempfile.callback(@data) ObjectSpace.define_finalizer(self, @clean_proc) @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600) @tmpname = tmpname @@cleanlist << @tmpname @data[1] = @tmpfile @data[2] = @@cleanlist super(@tmpfile) # Now we have all the File/IO methods defined, you must not # carelessly put bare puts(), etc. after this. Dir.rmdir(lock) end def make_tmpname(basename, n) case basename when Array prefix, suffix = *basename else prefix, suffix = basename, '' end t = Time.now.strftime("%Y%m%d") path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}" end private :make_tmpname # Opens or reopens the file with mode "r+". def open @tmpfile.close if @tmpfile @tmpfile = File.open(@tmpname, 'r+') @data[1] = @tmpfile __setobj__(@tmpfile) end def _close # :nodoc: @tmpfile.close if @tmpfile @tmpfile = nil @data[1] = nil if @data end protected :_close # Closes the file. If the optional flag is true, unlinks the file # after closing. # # If you don't explicitly unlink the temporary file, the removal # will be delayed until the object is finalized. def close(unlink_now=false) if unlink_now close! else _close end end # Closes and unlinks the file. def close! _close @clean_proc.call ObjectSpace.undefine_finalizer(self) @data = @tmpname = nil end # Unlinks the file. On UNIX-like systems, it is often a good idea # to unlink a temporary file immediately after creating and opening # it, because it leaves other programs zero chance to access the # file. def unlink # keep this order for thread safeness begin File.unlink(@tmpname) if File.exist?(@tmpname) @@cleanlist.delete(@tmpname) @data = @tmpname = nil ObjectSpace.undefine_finalizer(self) rescue Errno::EACCES # may not be able to unlink on Windows; just ignore end end alias delete unlink # Returns the full path name of the temporary file. def path @tmpname end # Returns the size of the temporary file. As a side effect, the IO # buffer is flushed before determining the size. def size if @tmpfile @tmpfile.flush @tmpfile.stat.size else 0 end end alias length size class << self def callback(data) # :nodoc: pid = $$ lambda{ if pid == $$ path, tmpfile, cleanlist = *data print "removing ", path, "..." if $DEBUG tmpfile.close if tmpfile # keep this order for thread safeness File.unlink(path) if File.exist?(path) cleanlist.delete(path) if cleanlist print "done\n" if $DEBUG end } end # If no block is given, this is a synonym for new(). # # If a block is given, it will be passed tempfile as an argument, # and the tempfile will automatically be closed when the block # terminates. In this case, open() returns nil. def open(*args) tempfile = new(*args) if block_given? begin yield(tempfile) ensure tempfile.close end nil else tempfile end end end end if __FILE__ == $0 # $DEBUG = true f = Tempfile.new("foo") f.print("foo\n") f.close f.open p f.gets # => "foo\n" f.close! end
Upload File
Create Folder