seven_zip_ruby 1.2.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 24d424d3f87e77974e436f6c044a54e5783baf95
4
- data.tar.gz: f5280318feffbdc6e25222916fb1168969bd3a73
2
+ SHA256:
3
+ metadata.gz: 5825d6fc6003666a0e46c7f7d04b02166df43dedfcce9c1321c585bdb572aa83
4
+ data.tar.gz: a1c55155547c4f190d5265adb38306d433b620c15b7dfd503e995577560b3708
5
5
  SHA512:
6
- metadata.gz: 2db16fba18dfa60a526bd4b03317da8a512c541e1fefb55633f785493086047ce8334b47e839a72d470e1210a51546433d1ee6e67513c5649c3d45bc7b99676b
7
- data.tar.gz: ccaa6fec52258413febf2db20388945fe30a19d48839e7f8287a4498fbe323893250fdfb5c54c788aa8a9ea51fee2438974f1296a2453e287c8276b4a3bcb1f9
6
+ metadata.gz: 143dfc6e36e05dc5697b90129f135beb67752425564fa761d973d4635b10c62ec2719ad2daab5076afc85301dd365c0c0e8ed5b35e9fa4934d3bc8672816ba14
7
+ data.tar.gz: 164fb272a9179e26ac2d0ee1f56c189047254ccd85e93ffc6bd1f4f6e56b399611f8dd3d655d6e816a35fd09615803354b54f4dbffee3bdd6bf58dc3f841727f
@@ -2,6 +2,7 @@
2
2
  #include <array>
3
3
  #include <vector>
4
4
  #include <cassert>
5
+ #include <string>
5
6
 
6
7
  #ifndef _WIN32
7
8
  #include <dlfcn.h>
@@ -1536,7 +1537,7 @@ STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
1536
1537
  bool ret = m_archive->runRubyAction([&](){
1537
1538
  VALUE str = rb_funcall(m_stream, INTERN("read"), 1, ULONG2NUM(size));
1538
1539
  if (!NIL_P(str) && data){
1539
- std::memcpy(data, RSTRING_PTR(str), RSTRING_LEN(str));
1540
+ memcpy(data, RSTRING_PTR(str), RSTRING_LEN(str));
1540
1541
  }
1541
1542
 
1542
1543
  if (processedSize){
@@ -1766,13 +1767,33 @@ extern "C" void Init_seven_zip_archive(void)
1766
1767
  using namespace SevenZip;
1767
1768
  using namespace RubyCppUtil;
1768
1769
 
1770
+ VALUE mod = rb_define_module("SevenZipRuby");
1771
+ gSevenZipModule = mod;
1772
+
1773
+ VALUE external_lib_dir = rb_const_get(mod, INTERN("EXTERNAL_LIB_DIR"));
1774
+ std::string external_lib_dir_str(RSTRING_PTR(external_lib_dir), RSTRING_LEN(external_lib_dir));
1775
+
1769
1776
  #ifdef _WIN32
1770
- gSevenZipHandle = LoadLibrary("./7z.dll");
1777
+ const int len = MultiByteToWideChar(CP_UTF8, 0, external_lib_dir_str.c_str(), external_lib_dir_str.length(),
1778
+ NULL, 0);
1779
+ if (len == 0) {
1780
+ rb_warning("MultiByteToWideChar error.");
1781
+ return;
1782
+ }
1783
+ std::vector<wchar_t> external_lib_dir_vec(len);
1784
+ MultiByteToWideChar(CP_UTF8, 0, external_lib_dir_str.c_str(), external_lib_dir_str.length(),
1785
+ &external_lib_dir_vec[0], external_lib_dir_vec.size());
1786
+ const std::wstring external_lib_dir_wstr(&external_lib_dir_vec[0], len);
1787
+
1788
+ const std::wstring dll_path = external_lib_dir_wstr + L"/7z.dll";
1789
+ gSevenZipHandle = LoadLibraryW(dll_path.c_str());
1771
1790
  if (!gSevenZipHandle){
1772
- gSevenZipHandle = LoadLibrary("./7z64.dll");
1791
+ const std::wstring dll_path2 = external_lib_dir_wstr + L"/7z64.dll";
1792
+ gSevenZipHandle = LoadLibraryW(dll_path2.c_str());
1773
1793
  }
1774
1794
  #else
1775
- gSevenZipHandle = dlopen("./7z.so", RTLD_NOW);
1795
+ std::string dll_path = external_lib_dir_str + "/7z.so";
1796
+ gSevenZipHandle = dlopen(dll_path.c_str(), RTLD_NOW);
1776
1797
  #endif
1777
1798
  if (!gSevenZipHandle){
1778
1799
  rb_warning("7z library is not found.");
@@ -1790,9 +1811,6 @@ extern "C" void Init_seven_zip_archive(void)
1790
1811
  }
1791
1812
 
1792
1813
 
1793
- VALUE mod = rb_define_module("SevenZipRuby");
1794
- gSevenZipModule = mod;
1795
-
1796
1814
  VALUE cls;
1797
1815
 
1798
1816
  // arg_count is needed by MSVC 2010...
@@ -2,19 +2,26 @@
2
2
 
3
3
  require("seven_zip_ruby/version")
4
4
 
5
- external_lib = (RUBY_PLATFORM.downcase.match(/mswin|mingw/) ? "7z.dll" : "7z.so")
6
- dir = $:.find do |i|
7
- next File.file?(File.join(i, "seven_zip_ruby", external_lib))
8
- end
9
- raise "Failed to find 7z.dll or 7z.so" unless (dir)
5
+ module SevenZipRuby
6
+ def self.find_external_lib_dir
7
+ external_lib = (RUBY_PLATFORM.downcase.match(/mswin|mingw/) ? "7z.dll" : "7z.so")
8
+ dir = $LOAD_PATH.find do |i|
9
+ path = File.expand_path(File.join(i, "seven_zip_ruby", external_lib))
10
+ next File.file?(path)
11
+ end
12
+ raise "Failed to find 7z.dll or 7z.so" unless dir
10
13
 
11
- Dir.chdir(File.join(dir, "seven_zip_ruby"))do
12
- begin
13
- version = RUBY_VERSION.match(/\d+\.\d+/)
14
- require("seven_zip_ruby/#{version}/seven_zip_archive")
15
- rescue LoadError
16
- require("seven_zip_ruby/seven_zip_archive")
14
+ return File.join(dir, "seven_zip_ruby")
17
15
  end
16
+
17
+ EXTERNAL_LIB_DIR = self.find_external_lib_dir.encode(Encoding::UTF_8)
18
+ end
19
+
20
+ begin
21
+ version = RUBY_VERSION.match(/\d+\.\d+/)
22
+ require("seven_zip_ruby/#{version}/seven_zip_archive")
23
+ rescue LoadError
24
+ require("seven_zip_ruby/seven_zip_archive")
18
25
  end
19
26
  raise "Failed to initialize SevenZipRuby" unless (defined?(SevenZipRuby::SevenZipReader))
20
27
 
@@ -477,7 +477,7 @@ module SevenZipRuby
477
477
  path = arg_path.expand_path(base_dir)
478
478
  path.mkpath
479
479
  set_file_attribute(path.to_s, arg.attrib) if (arg.attrib)
480
- path.utime(arg.atime || path.atime, arg.mtime || path.mtime)
480
+ path.utime(arg.atime || path.atime, arg.mtime || path.mtime) rescue nil
481
481
  end
482
482
  next ret
483
483
 
@@ -488,7 +488,7 @@ module SevenZipRuby
488
488
  unless (arg[:info].anti?)
489
489
  path = Pathname(arg[:info].path).expand_path(base_dir)
490
490
  set_file_attribute(path.to_s, arg[:info].attrib) if (arg[:info].attrib)
491
- path.utime(arg[:info].atime || path.atime, arg[:info].mtime || path.mtime)
491
+ path.utime(arg[:info].atime || path.atime, arg[:info].mtime || path.mtime) rescue nil
492
492
  end
493
493
  end
494
494
  end
@@ -1,3 +1,3 @@
1
1
  module SevenZipRuby
2
- VERSION = "1.2.5"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.0.0'
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
26
  if (RUBY_ENGINE == "rbx")
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seven_zip_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masamitsu MURASE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -812,8 +812,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
812
812
  - !ruby/object:Gem::Version
813
813
  version: '0'
814
814
  requirements: []
815
- rubyforge_project:
816
- rubygems_version: 2.6.8
815
+ rubygems_version: 3.1.2
817
816
  signing_key:
818
817
  specification_version: 4
819
818
  summary: This is a ruby gem library to read and write 7zip files.