I want to create a hidden folder for logging information in Ruby, is there a way I can create a hidden folder, and keep it locked with a password, while at the same time logging information to a file inside of it?
Example:
module LogEmail
def log(email)
username = Etc.getlogin
Dir.mkdir <hidden-dir> unless File.Exists?(<hidden-dir>)
separator = "[#{Date.today} #{Time.now.strftime('%T')}] ----------"
File.open("c:/users/#{username}/<hidden-folder>/<log>", 'a+') { |s| s.puts(separator, email) }
end
end
Is this possible?
I succeeded in creating a hidden folder using a shell command.
module LogEmail
def log(email)
username = Etc.getlogin
dir = "c:/users/#{username}/log"
if File.exists?(dir)
separator = "[#{Date.today} #{Time.now.strftime('%T')}] ----------"
File.open("#{dir}/email_log.LOG", 'a+') { |s| s.puts(separator, email) }
else
Dir.mkdir(dir)
`attrib +h #{dir}` #<= Creates a hidden folder.
separator = "[#{Date.today} #{Time.now.strftime('%T')}] ----------"
File.open("#{dir}/email_log.LOG", 'a+') { |s| s.puts(separator, email) }
end
end
end