Skip to content

Commit

Permalink
Workaround for argument/path encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
larsch committed Mar 1, 2017
1 parent 2e7c88f commit db7eab6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bin/ocra
@@ -1,13 +1,14 @@
#!/usr/bin/env ruby
# -*- ruby -*-
# encoding: UTF-8

module Ocra
# Path handling class. Ruby's Pathname class is not used because it
# is case sensitive and doesn't handle paths with mixed path
# separators.
class Pathname
def Pathname.pwd
Pathname.new(Dir.pwd)
Pathname.new(Dir.pwd.encode('UTF-8'))
end

def Pathname.pathequal(a, b)
Expand All @@ -22,7 +23,7 @@ module Ocra
ABSOLUTE_PAT = /\A([A-Z]:)?#{SEPARATOR_PAT}/i

def initialize(path)
@path = path
@path = path && path.encode('UTF-8')
end

def to_native
Expand Down Expand Up @@ -86,7 +87,7 @@ module Ocra
end

def entries
Dir.entries(@path).map { |e| self / e }
Dir.entries(@path).map { |e| self / e.encode('UTF-8') }
end

# Recursively find all files which match a specified regular
Expand Down Expand Up @@ -438,7 +439,7 @@ EOF
end

@options[:files].map! { |path|
path = path.tr('\\','/')
path = path.encode('UTF-8').tr('\\','/')
if File.directory?(path)
# If a directory is passed, we want all files under that directory
path = "#{path}/**/*"
Expand Down

0 comments on commit db7eab6

Please sign in to comment.