Sha256: b4a1aba64a71530978dce65829d90df1a29ba6b7b939d73c00791bbe8b5b6dd7

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 Bytes

Contents

# -*- coding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#

if Helper.os_windows?
  require "fileutils"

  module FileUtils
    # マルチバイト文字を含むパスを認識出来ないため
    def self.cp(src, dst, opt = nil)
      open(src, "rb") do |fp|
        File.binwrite(dst, fp.read)
      end
    end
  end

  class File
    # 何故かエンコーディングエラーが出るため
    def self.binwrite(path, data)
      open(path, "wb") do |fp|
        fp.write(data)
      end
    end

    # -Dfile.encoding=UTF-8 を指定するとなぜか File.mtime がマルチバイト文字を含むパスを認識出来ないため
    def self.mtime(path)
      java_path = java.nio.file.FileSystems.default.getPath(path)
      java_file_time = java.nio.file.Files.getLastModifiedTime(java_path)
      Time.parse(java_file_time.to_s).getlocal("+09:00")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
narou-1.7.1 lib/extensions/jruby.rb
narou-1.6.4 lib/extensions/jruby.rb
narou-1.6.3 lib/extensions/jruby.rb
narou-1.6.1 lib/extensions/jruby.rb
narou-1.6.0 lib/extensions/jruby.rb