libarchive-ruby-swig 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,8 @@
22
22
  #include "error.h"
23
23
 
24
24
  Entry::Entry(struct archive_entry *entry)
25
- {
26
- _entry = entry;
27
- }
25
+ : _entry(entry)
26
+ {}
28
27
 
29
28
  Entry::~Entry()
30
29
  {
@@ -36,7 +35,12 @@ Entry::~Entry()
36
35
 
37
36
  bool Entry::is_file()
38
37
  {
39
- return S_ISREG(archive_entry_filetype(_entry));
38
+ if(S_ISREG(archive_entry_filetype(_entry)) &&
39
+ !this->is_hardlink()) {
40
+ return true;
41
+ }
42
+
43
+ return false;
40
44
  }
41
45
 
42
46
  bool Entry::is_directory()
@@ -69,6 +73,14 @@ bool Entry::is_socket()
69
73
  return S_ISSOCK(archive_entry_filetype(_entry));
70
74
  }
71
75
 
76
+ bool Entry::is_hardlink()
77
+ {
78
+ if(archive_entry_hardlink(_entry) != 0)
79
+ return true;
80
+
81
+ return false;
82
+ }
83
+
72
84
  unsigned int Entry::filetype()
73
85
  {
74
86
  return archive_entry_filetype(_entry);
@@ -30,6 +30,7 @@ class Entry
30
30
  bool is_character_special();
31
31
  bool is_fifo();
32
32
  bool is_socket();
33
+ bool is_hardlink();
33
34
 
34
35
  unsigned int filetype();
35
36
  void set_filetype(unsigned int filetype);
@@ -122,6 +122,16 @@ Entry *Writer::new_entry_helper()
122
122
 
123
123
  void Writer::write_header(Entry *entry)
124
124
  {
125
+ if(entry->nlink() > 1) {
126
+ std::string path = _hardlinks[entry->dev()][entry->ino()];
127
+ if(path.empty()) {
128
+ _hardlinks[entry->dev()][entry->ino()] =
129
+ std::string(entry->pathname());
130
+ } else {
131
+ entry->set_hardlink(path.c_str());
132
+ }
133
+ }
134
+
125
135
  if(archive_write_header(_ar, entry->_entry) != ARCHIVE_OK) {
126
136
  std::string error_msg = archive_error_string(_ar);
127
137
  throw Error(error_msg);
@@ -16,6 +16,8 @@ class Entry;
16
16
 
17
17
  #ifndef SWIG
18
18
  #include <ruby.h>
19
+ #include <string>
20
+ #include <map>
19
21
  #endif
20
22
 
21
23
  namespace Archive
@@ -101,6 +103,7 @@ class Writer
101
103
  char *_buf;
102
104
  int _buf_size;
103
105
 
106
+ std::map<unsigned long, std::map<unsigned long, std::string> > _hardlinks;
104
107
  };
105
108
 
106
109
  #endif
@@ -83,6 +83,13 @@ module Archive
83
83
  def is_socket
84
84
  end
85
85
 
86
+ ##
87
+ #
88
+ # Is Entry a hardlink?
89
+ #
90
+ def is_hardlink
91
+ end
92
+
86
93
  ##
87
94
  #
88
95
  # Returns the filetype bits for entry.
data/lib/libarchive_rs.rb CHANGED
@@ -28,6 +28,7 @@ module Archive
28
28
  alias :character_special? :is_character_special
29
29
  alias :fifo? :is_fifo
30
30
  alias :socket? :is_socket
31
+ alias :hardlink? :is_hardlink
31
32
 
32
33
  alias :filetype= :set_filetype
33
34
  alias :devmajor= :set_devmajor
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libarchive-ruby-swig
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 4
10
- version: 0.5.4
9
+ - 6
10
+ version: 0.5.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Koch
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-27 00:00:00 +02:00
18
+ date: 2011-04-16 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: libarchive-ruby-swig provides Ruby bindings to libarchive using SWIG. The gem allows you to read and write compressed archives in a variety of formats.
22
+ description: Ruby bindings to libarchive allowing reading and creation of compressed archives in a variety of formats.
23
23
  email: tobias.koch@gmail.com
24
24
  executables: []
25
25