From a27a6623449d00af838ba87319454d92dc3014c0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 16 Aug 2014 23:38:05 +0000 Subject: rely on filesystem encoding This avoids compatibility problems as File.expand_path respects the "filesystem" encoding of Ruby. I'm not 100% sure this is correct, as Ruby encoding support still confuses me, but this fixes a problem where I attempted to add UTF-8 filename with non-US-ASCII characters in it on ruby-trunk. --- bin/dtas-cueedit | 2 -- bin/dtas-enq | 3 +-- bin/dtas-player | 5 ++--- bin/dtas-tl | 4 ++-- lib/dtas/unix_client.rb | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/dtas-cueedit b/bin/dtas-cueedit index 3677e7a..04922ef 100755 --- a/bin/dtas-cueedit +++ b/bin/dtas-cueedit @@ -24,8 +24,6 @@ def tmpfile(file, suffix) end ARGV.each do |file| - # Unix paths are encoding agnostic - file = file.b file =~ /\.flac\z/i or warn "Unsupported suffix, assuming FLAC" tmp = tmpfile(file, '.cue') begin diff --git a/bin/dtas-enq b/bin/dtas-enq index c18b684..4ab3c04 100755 --- a/bin/dtas-enq +++ b/bin/dtas-enq @@ -5,8 +5,7 @@ require 'dtas/unix_client' c = DTAS::UNIXClient.new ARGV.each do |path| - # Unix paths are encoding agnostic - path = File.expand_path(path.b) + path = File.expand_path(path) res = c.req_ok(%W(enq #{path})) puts "#{path} #{res}" end diff --git a/bin/dtas-player b/bin/dtas-player index 0c2d53e..49a0445 100755 --- a/bin/dtas-player +++ b/bin/dtas-player @@ -4,10 +4,9 @@ Thread.abort_on_exception = $stderr.sync = $stdout.sync = true require 'yaml' require 'dtas/player' -sock = (ENV["DTAS_PLAYER_SOCK"] || - File.expand_path("~/.dtas/player.sock")).b +sock = (ENV["DTAS_PLAYER_SOCK"] || File.expand_path("~/.dtas/player.sock")) state = (ENV["DTAS_PLAYER_STATE"] || - File.expand_path("~/.dtas/player_state.yml")).b + File.expand_path("~/.dtas/player_state.yml")) [ sock, state ].each do |file| dir = File.dirname(file) next if File.directory?(dir) diff --git a/bin/dtas-tl b/bin/dtas-tl index 6214ca9..6963108 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -31,7 +31,7 @@ when "clear" when "addhead" ARGV.shift ARGV.reverse.each do |path| - path = File.expand_path(path.b) + path = File.expand_path(path) res = c.req(%W(tl add #{path})) puts "#{path} #{res}" end @@ -40,7 +40,7 @@ when "addtail" track_ids = get_track_ids(c) last_id = track_ids.pop ARGV.each do |path| - path = File.expand_path(path.b) + path = File.expand_path(path) req = %W(tl add #{path}) req << last_id.to_s if last_id res = c.req(req) diff --git a/lib/dtas/unix_client.rb b/lib/dtas/unix_client.rb index d2ae7b8..40dedcc 100644 --- a/lib/dtas/unix_client.rb +++ b/lib/dtas/unix_client.rb @@ -13,7 +13,7 @@ class DTAS::UNIXClient # :nodoc: include DTAS::XS def self.default_path - (ENV["DTAS_PLAYER_SOCK"] || File.expand_path("~/.dtas/player.sock")).b + (ENV["DTAS_PLAYER_SOCK"] || File.expand_path("~/.dtas/player.sock")) end def initialize(path = self.class.default_path) -- cgit v1.2.3-24-ge0c7