Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File and Dir exists? replaced with exist? #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions check.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ hints = []

begin

hints << "You might want to config your environment within the file 'config.rb' (see 'config_sample.rb' for a starting point)" unless File.exists?("config.rb")
hints << "You might want to config your environment within the file 'config.rb' (see 'config_sample.rb' for a starting point)" unless File.exist?("config.rb")

begin
require_relative "dudle"
Expand All @@ -55,15 +55,15 @@ end



unless File.exists?("locale/de/dudle.mo")
unless File.exist?("locale/de/dudle.mo")
problems << ["If you want a language other than English, you will need a localization and therefore need to build the .mo files. Refer the README for details."]
end

unless File.writable?(".")
problems << ["Your webserver needs write access to #{File.expand_path(".")}"]
else
testdir = "this-is-a-test-directory-created-by-check.cgi-it-should-be-deleted"
if Dir.exists?(testdir) # might exist from a previous test
if Dir.exist?(testdir) # might exist from a previous test
require "fileutils"
FileUtils.rm_r(testdir)
end
Expand Down
2 changes: 1 addition & 1 deletion config_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

$conf.bots = /bot/i

if File.exists?("config.rb") || File.exists?("../config.rb")
if File.exist?("config.rb") || File.exist?("../config.rb")
require_relative "config"
end

Expand Down
12 changes: 6 additions & 6 deletions dudle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GetText.output_charset = 'utf-8'
require "locale"

if File.exists?("data.yaml") && !File.stat("data.yaml").directory?
if File.exist?("data.yaml") && !File.stat("data.yaml").directory?
$is_poll = true
GetText.bindtextdomain("dudle", :path => Dir.pwd + "/../locale/")
else
Expand Down Expand Up @@ -159,7 +159,7 @@ def initialize(params = {:revision => nil, :title => nil, :hide_lang_chooser =>


@css = ["default", "classic", "print"].collect{|f| f + ".css"}
if Dir.exists?("#{@basedir}/css/")
if Dir.exist?("#{@basedir}/css/")
Dir.open("#{@basedir}/css/").each{|f|
if f =~ /\.css$/
@css << "css/#{f}"
Expand Down Expand Up @@ -205,11 +205,11 @@ def initialize(params = {:revision => nil, :title => nil, :hide_lang_chooser =>
###################
@extensions = []
$d = self # FIXME: this is dirty, but extensions need to know table elem
if Dir.exists?("#{@basedir}/extensions/") && params[:load_extensions]
if Dir.exist?("#{@basedir}/extensions/") && params[:load_extensions]
Dir.open("#{@basedir}/extensions/").sort.each{|f|
if File.exists?("#{@basedir}/extensions/#{f}/main.rb")
if File.exist?("#{@basedir}/extensions/#{f}/main.rb")
@extensions << f
if File.exists?("#{@basedir}/extensions/#{f}/preload.rb")
if File.exist?("#{@basedir}/extensions/#{f}/preload.rb")
$current_ext_dir = f
require "#{@basedir}/extensions/#{f}/preload"
end
Expand Down Expand Up @@ -299,7 +299,7 @@ def out
@html << "</div>" # main
$conf.footer.each{|f| @html << f }
@extensions.each{|e|
if File.exists?("#{@basedir}/extensions/#{e}/main.rb")
if File.exist?("#{@basedir}/extensions/#{e}/main.rb")
$current_ext_dir = e
require "#{@basedir}/extensions/#{e}/main"
end
Expand Down
4 changes: 2 additions & 2 deletions error.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

require_relative "dudle"

if File.exists?("#{Dir.pwd}/#{File.dirname(ENV["REDIRECT_URL"])}/data.yaml")
if File.exist?("#{Dir.pwd}/#{File.dirname(ENV["REDIRECT_URL"])}/data.yaml")
$d = Dudle.new(:title => _("Error"), :hide_lang_chooser => true, :load_extensions => false, :relative_dir => "../")
else
$d = Dudle.new(:title => _("Error"), :hide_lang_chooser => true, :load_extensions => false)
end

if File.exists?($conf.errorlog)
if File.exist?($conf.errorlog)
begin
a = File.open($conf.errorlog,"r").to_a
rescue Exception => e
Expand Down
2 changes: 1 addition & 1 deletion example.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if $cgi.include?("poll")
if poll[:new_environment]
targeturl += "_#{Time.now.to_i}"

while (File.exists?(targeturl))
while (File.exist?(targeturl))
targeturl += "I"
end
VCS.branch(poll[:url],targeturl)
Expand Down
2 changes: 1 addition & 1 deletion index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if $cgi.include?("create_poll") && $cgi.include?("poll_url")
else
if $cgi["poll_url"] == ""
require "securerandom"
true while(File.exists?(pollurl = SecureRandom.urlsafe_base64($conf.random_chars)))
true while(File.exist?(pollurl = SecureRandom.urlsafe_base64($conf.random_chars)))
else
pollurl=$cgi["poll_url"]
end
Expand Down
2 changes: 1 addition & 1 deletion maintenance.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ else
$d = Dudle.new(:title => _("Maintenance"), :hide_lang_chooser => true)
end

if File.exists?("maintenance.html")
if File.exist?("maintenance.html")
$d << _("This site is currently undergoing maintenance!")
$d << File.open("maintenance.html","r").read
else
Expand Down
2 changes: 1 addition & 1 deletion not_found.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

if(ENV["REDIRECT_URL"])
require_relative "dudle"
if File.exists?(Dir.pwd + File.dirname(ENV["REDIRECT_URL"]))
if File.exist?(Dir.pwd + File.dirname(ENV["REDIRECT_URL"]))
$d = Dudle.new(:hide_lang_chooser => true, :load_extensions => false)
else
$d = Dudle.new(:hide_lang_chooser => true, :load_extensions => false, :relative_dir => "../")
Expand Down
2 changes: 1 addition & 1 deletion participate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

else

$d.html.add_atom("atom.cgi") if File.exists?("../atom.rb")
$d.html.add_atom("atom.cgi") if File.exist?("../atom.rb")

# TABLE
$d << <<HTML
Expand Down