aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-22 08:51:40 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-22 08:51:40 +0000
commitda54a4589af5cbe9a53f8baf3f9474c91e673b4c (patch)
treeb328922b605c9e065c4600fec8c020c41ca024b7 /lib/fileutils.rb
parent6221d16ffbcc601a88342f35dee9c539709cf900 (diff)
downloadruby-da54a4589af5cbe9a53f8baf3f9474c91e673b4c.tar.gz
* lib/fileutils.rb (FileUtils#fu_get_uid, fu_get_gid): Do not
convert an integer back and forth. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r--lib/fileutils.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 58e3f1d684..8c522ced55 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -977,20 +977,26 @@ module FileUtils
def fu_get_uid(user) #:nodoc:
return nil unless user
- user = user.to_s
- if /\A\d+\z/ =~ user
- then user.to_i
- else Etc.getpwnam(user).uid
+ case user
+ when Integer
+ user
+ when /\A\d+\z/
+ user.to_i
+ else
+ Etc.getpwnam(user).uid
end
end
private_module_function :fu_get_uid
def fu_get_gid(group) #:nodoc:
return nil unless group
- group = group.to_s
- if /\A\d+\z/ =~ group
- then group.to_i
- else Etc.getgrnam(group).gid
+ case group
+ when Integer
+ group
+ when /\A\d+\z/
+ group.to_i
+ else
+ Etc.getgrnam(group).gid
end
end
private_module_function :fu_get_gid