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) ⇒ Void
Gracefully create folder.
Instance Method Details
#create_file_with_content(file_path: '/tmp/temp_file.ext', content: '') ⇒ String
Create file with content
19 20 21 22 23 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 19 def create_file_with_content(file_path: '/tmp/temp_file.ext', content: '') File.write(file_path, 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
29 30 31 32 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 29 def create_file_with_size(file_path: '/tmp/temp_file.ext', size: '1G') `fallocate -l #{size} #{file_path}` file_path end |
#create_folder(path) ⇒ Void
Gracefully create folder. Do not fail if already exists
9 10 11 12 13 |
# File 'lib/onlyoffice_file_helper/create_methods.rb', line 9 def create_folder(path) FileUtils.mkdir_p(path) unless File.directory?(path) rescue Errno::EEXIST true end |