class U3dCore::AdminTools
Public Class Methods
create_file(os, path, dry_run: false)
click to toggle source
# File lib/u3d_core/admin_tools.rb, line 36 def self.create_file(os, path, dry_run: false) if dry_run UI.message "'#{source_path}' would create file at '#{path}'" return end if os == :win path = U3dCore::Helper.windows_path(path) command = "fsutil file createnew #{path.argescape} 0" else command = "touch #{path.shellescape}" end U3dCore::CommandExecutor.execute(command: command, admin: true) true end
move_file(source_path, new_path, command, dry_run: false)
click to toggle source
move one path to a new path
# File lib/u3d_core/admin_tools.rb, line 53 def self.move_file(source_path, new_path, command, dry_run: false) if source_path == new_path UI.verbose "move_file does nothing if the path won't change (#{source_path})" return false end if dry_run UI.message "'#{source_path}' would move to '#{new_path}'" else UI.important "Moving '#{source_path}' to '#{new_path}'..." U3dCore::CommandExecutor.execute(command: command, admin: true) UI.success "Successfully moved '#{source_path}' to '#{new_path}'" end true rescue StandardError => e UI.error "Unable to move '#{source_path}' to '#{new_path}': #{e}" false end
move_os_file(os, source_path, new_path, dry_run:)
click to toggle source
# File lib/u3d_core/admin_tools.rb, line 25 def self.move_os_file(os, source_path, new_path, dry_run:) if os == :win source_path = U3dCore::Helper.windows_path(source_path) new_path = U3dCore::Helper.windows_path(new_path) command = "move #{source_path.argescape} #{new_path.argescape}" else command = "mv #{source_path.shellescape} #{new_path.shellescape}" end move_file(source_path, new_path, command, dry_run: dry_run) end