mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
bc735bbe22
- unified makefile project for the whole repos - new separate project for tests
80 lines
1.4 KiB
Ruby
80 lines
1.4 KiB
Ruby
require 'rubygems'
|
|
require 'rake' # for FileList
|
|
require 'constants'
|
|
require 'fileutils'
|
|
|
|
|
|
class FileWrapper
|
|
|
|
def get_expanded_path(path)
|
|
return File.expand_path(path)
|
|
end
|
|
|
|
def basename(path, extension=nil)
|
|
return File.basename(path, extension) if extension
|
|
return File.basename(path)
|
|
end
|
|
|
|
def exist?(filepath)
|
|
return true if (filepath == NULL_FILE_PATH)
|
|
return File.exist?(filepath)
|
|
end
|
|
|
|
def directory?(path)
|
|
return File.directory?(path)
|
|
end
|
|
|
|
def dirname(path)
|
|
return File.dirname(path)
|
|
end
|
|
|
|
def directory_listing(glob)
|
|
return Dir.glob(glob)
|
|
end
|
|
|
|
def rm_f(filepath, options={})
|
|
FileUtils.rm_f(filepath, options)
|
|
end
|
|
|
|
def rm_r(filepath, options={})
|
|
FileUtils.rm_r(filepath, options={})
|
|
end
|
|
|
|
def cp(source, destination, options={})
|
|
FileUtils.cp(source, destination, options)
|
|
end
|
|
|
|
def compare(from, to)
|
|
return FileUtils.compare_file(from, to)
|
|
end
|
|
|
|
def open(filepath, flags)
|
|
File.open(filepath, flags) do |file|
|
|
yield(file)
|
|
end
|
|
end
|
|
|
|
def read(filepath)
|
|
return File.read(filepath)
|
|
end
|
|
|
|
def touch(filepath, options={})
|
|
FileUtils.touch(filepath, options)
|
|
end
|
|
|
|
def write(filepath, contents, flags='w')
|
|
File.open(filepath, flags) do |file|
|
|
file.write(contents)
|
|
end
|
|
end
|
|
|
|
def readlines(filepath)
|
|
return File.readlines(filepath)
|
|
end
|
|
|
|
def instantiate_file_list(files=[])
|
|
return FileList.new(files)
|
|
end
|
|
|
|
end
|