Module: OnlyofficeFileHelper::CreateMethods
- Included in:
- FileHelper
- Defined in:
- lib/onlyoffice_file_helper/create_methods.rb
Overview
Methods used to create something
Instance Method Summary collapse
-
#create_file_with_content(file_path: '/tmp/temp_file.ext', content: '') ⇒ String
Create file with content.
-
#create_file_with_size(file_path: '/tmp/temp_file.ext', size: '1G') ⇒ String
Create empty file with size.
- #create_folder(path) ⇒ Object
Instance Method Details
#create_file_with_content(file_path: '/tmp/temp_file.ext', content: '') ⇒ String
Create file with content
16 17 18 19 20 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 16 def create_file_with_content(file_path: '/tmp/temp_file.ext', content: '') File.open(file_path, 'w') { |f| f.write(content) } OnlyofficeLoggerHelper.log("Created file: #{file_path} with content: #{content}") file_path end |
#create_file_with_size(file_path: '/tmp/temp_file.ext', size: '1G') ⇒ String
Create empty file with size
26 27 28 29 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 26 def create_file_with_size(file_path: '/tmp/temp_file.ext', size: '1G') `fallocate -l #{size} #{file_path}` file_path end |
#create_folder(path) ⇒ Object
6 7 8 9 10 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 6 def create_folder(path) FileUtils.mkdir_p(path) unless File.directory?(path) rescue Errno::EEXIST true end |