io-afc 0.0.3.2 → 0.0.3.3
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.
- data/.gitignore +23 -0
- data/.yardopts +2 -0
- data/ext/io/afc/extconf.rb +3 -0
- data/ext/io/afc/ioafc.cpp +31 -5
- data/ext/io/afc/ioafc.h +15 -2
- data/io-afc.gemspec +1 -1
- data/lib/io/afc/version.rb +1 -1
- data/lib/io/afc.rb +29 -31
- metadata +10 -16
- data/Gemfile.lock +0 -38
- data/pkg/io-afc-0.0.3.1.gem +0 -0
- data/pkg/io-afc-0.0.3.2.gem +0 -0
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.DS_Store
|
19
|
+
*.swp
|
20
|
+
mkmf.log
|
21
|
+
*.o
|
22
|
+
*.bundle
|
23
|
+
Makefile
|
data/.yardopts
ADDED
data/ext/io/afc/extconf.rb
CHANGED
@@ -3,5 +3,8 @@ require 'mkmf'
|
|
3
3
|
$CPPFLAGS="`pkg-config --cflags libimobiledevice-1.0`"
|
4
4
|
$LDFLAGS="`pkg-config --libs libimobiledevice-1.0`"
|
5
5
|
pkg_config("libimobiledevice-1.0")
|
6
|
+
have_header("libimobiledevice/house_arrest.h")
|
7
|
+
have_func("lockdownd_service_descriptor_free")
|
8
|
+
have_func("lockdownd_get_device_udid")
|
6
9
|
|
7
10
|
create_makefile("io/afc/afc_base")
|
data/ext/io/afc/ioafc.cpp
CHANGED
@@ -66,7 +66,9 @@ static void rb_raise_SystemCallErrorAFC(afc_error_t err)
|
|
66
66
|
{AFC_E_READ_ERROR , ENOTDIR},
|
67
67
|
{AFC_E_WRITE_ERROR , EIO},
|
68
68
|
{AFC_E_UNKNOWN_PACKET_TYPE , EIO},
|
69
|
+
#ifdef AFC_E_INVALID_ARG
|
69
70
|
{AFC_E_INVALID_ARG , EINVAL},
|
71
|
+
#endif
|
70
72
|
{AFC_E_OBJECT_NOT_FOUND , ENOENT},
|
71
73
|
{AFC_E_OBJECT_IS_DIR , EISDIR},
|
72
74
|
{AFC_E_DIR_NOT_EMPTY , ENOTEMPTY},
|
@@ -121,8 +123,10 @@ IoAFC::IoAFC()
|
|
121
123
|
_blocksize = 4096;
|
122
124
|
_idev = NULL;
|
123
125
|
_control = NULL;
|
126
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
124
127
|
_house_arrest = NULL;
|
125
|
-
|
128
|
+
#endif
|
129
|
+
_port = LOCKDOWND_INVALID_PORT;
|
126
130
|
_afc = NULL;
|
127
131
|
}
|
128
132
|
|
@@ -139,12 +143,16 @@ void IoAFC::teardown()
|
|
139
143
|
{
|
140
144
|
DBG("- IO::AFC: %p\n", _afc);
|
141
145
|
if (_afc) afc_client_free(_afc);
|
146
|
+
#ifdef HAVE_LOCKDOWND_SERVICE_DESCRIPTOR_FREE
|
142
147
|
if (_port) lockdownd_service_descriptor_free(_port);
|
148
|
+
#endif
|
149
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
143
150
|
if (_house_arrest) house_arrest_client_free(_house_arrest);
|
151
|
+
#endif
|
144
152
|
if (_control) lockdownd_client_free(_control);
|
145
153
|
if (_idev) idevice_free(_idev);
|
146
154
|
_afc = NULL;
|
147
|
-
_port =
|
155
|
+
_port = LOCKDOWND_INVALID_PORT;
|
148
156
|
_house_arrest = NULL;
|
149
157
|
_control = NULL;
|
150
158
|
_idev = NULL;
|
@@ -195,8 +203,9 @@ void IoAFC::init(VALUE rb_device_uuid, VALUE rb_appid)
|
|
195
203
|
teardown();
|
196
204
|
rb_raise(rb_eConnectFailed, "Failed to start %s service.", _service_name);
|
197
205
|
}
|
198
|
-
|
206
|
+
|
199
207
|
if (appid) {
|
208
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
200
209
|
// check document foider?
|
201
210
|
house_arrest_client_new(_idev, _port, &_house_arrest);
|
202
211
|
if (!_house_arrest) {
|
@@ -231,13 +240,21 @@ void IoAFC::init(VALUE rb_device_uuid, VALUE rb_appid)
|
|
231
240
|
rb_raise(rb_eConnectFailed, "Error: %s", _errmsg.c_str());
|
232
241
|
}
|
233
242
|
plist_free(dict);
|
243
|
+
#else
|
244
|
+
teardown();
|
245
|
+
rb_raise(rb_eStandardError, "Document sharing servce is not supported. Please use more recent libimobiledevice.");
|
246
|
+
#endif
|
234
247
|
}
|
235
248
|
|
249
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
236
250
|
if (_house_arrest) {
|
237
251
|
afc_client_new_from_house_arrest_client(_house_arrest, &_afc);
|
238
252
|
} else {
|
253
|
+
#endif
|
239
254
|
afc_client_new(_idev, _port, &_afc);
|
255
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
240
256
|
}
|
257
|
+
#endif
|
241
258
|
|
242
259
|
if (!_afc) {
|
243
260
|
teardown();
|
@@ -417,7 +434,7 @@ VALUE IoAFC::mkdir(VALUE rb_path)
|
|
417
434
|
VALUE IoAFC::get_device_udid()
|
418
435
|
{
|
419
436
|
checkHandle();
|
420
|
-
|
437
|
+
#ifdef HAVE_LOCKDOWND_GET_DEVICE_UDID
|
421
438
|
char* udid = NULL;
|
422
439
|
lockdownd_error_t le = lockdownd_get_device_udid(_control, &udid);
|
423
440
|
if (le!=LOCKDOWN_E_SUCCESS) {
|
@@ -429,6 +446,9 @@ VALUE IoAFC::get_device_udid()
|
|
429
446
|
::free(udid);
|
430
447
|
}
|
431
448
|
return result;
|
449
|
+
#else
|
450
|
+
rb_raise(rb_eStandardError, "get_device_udid() is not supported. Please use more recent libimobiledevice.");
|
451
|
+
#endif
|
432
452
|
}
|
433
453
|
|
434
454
|
|
@@ -468,7 +488,7 @@ VALUE IoAFC::enum_applications()
|
|
468
488
|
{
|
469
489
|
checkHandle();
|
470
490
|
|
471
|
-
|
491
|
+
LOCKDOWND_PORT port = LOCKDOWND_INVALID_PORT;
|
472
492
|
lockdownd_error_t le = lockdownd_start_service(_control, INSTALLATION_PROXY_SERVICE_NAME, &port);
|
473
493
|
if ((le!=LOCKDOWN_E_SUCCESS) || (port==0)) {
|
474
494
|
rb_raise(rb_eConnectFailed, "Failed to start %s service.", INSTALLATION_PROXY_SERVICE_NAME);
|
@@ -477,14 +497,18 @@ VALUE IoAFC::enum_applications()
|
|
477
497
|
instproxy_client_t client = NULL;
|
478
498
|
instproxy_error_t ie = instproxy_client_new(_idev, port, &client);
|
479
499
|
if ((ie!=INSTPROXY_E_SUCCESS) || (client==NULL)) {
|
500
|
+
#ifdef HAVE_LOCKDOWND_SERVICE_DESCRIPTOR_FREE
|
480
501
|
lockdownd_service_descriptor_free(port);
|
502
|
+
#endif
|
481
503
|
rb_raise(rb_eRuntimeError, "instproxy_client_new() failed - %d", ie);
|
482
504
|
}
|
483
505
|
|
484
506
|
plist_t client_opts = instproxy_client_options_new();
|
485
507
|
if (client_opts==NULL) {
|
486
508
|
instproxy_client_free(client);
|
509
|
+
#ifdef HAVE_LOCKDOWND_SERVICE_DESCRIPTOR_FREE
|
487
510
|
lockdownd_service_descriptor_free(port);
|
511
|
+
#endif
|
488
512
|
rb_raise(rb_eRuntimeError, "instproxy_client_options_new() failed");
|
489
513
|
}
|
490
514
|
|
@@ -493,7 +517,9 @@ VALUE IoAFC::enum_applications()
|
|
493
517
|
ie = instproxy_browse(client, client_opts, &apps);
|
494
518
|
instproxy_client_options_free(client_opts);
|
495
519
|
instproxy_client_free(client);
|
520
|
+
#ifdef HAVE_LOCKDOWND_SERVICE_DESCRIPTOR_FREE
|
496
521
|
lockdownd_service_descriptor_free(port);
|
522
|
+
#endif
|
497
523
|
if (ie!=INSTPROXY_E_SUCCESS) {
|
498
524
|
rb_raise(rb_eRuntimeError, "instproxy_browse() failed - %d", ie);
|
499
525
|
}
|
data/ext/io/afc/ioafc.h
CHANGED
@@ -19,9 +19,22 @@
|
|
19
19
|
#include <libimobiledevice/libimobiledevice.h>
|
20
20
|
#include <libimobiledevice/lockdown.h>
|
21
21
|
#include <libimobiledevice/afc.h>
|
22
|
-
#include <libimobiledevice/house_arrest.h>
|
23
22
|
#include <libimobiledevice/installation_proxy.h>
|
24
23
|
|
24
|
+
#ifdef HAVE_LIBIMOBILEDEVICE_HOUSE_ARREST_H
|
25
|
+
#include <libimobiledevice/house_arrest.h>
|
26
|
+
#else
|
27
|
+
typedef void* house_arrest_client_t;
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifdef HAVE_LOCKDOWND_SERVICE_DESCRIPTOR_FREE
|
31
|
+
typedef lockdownd_service_descriptor_t LOCKDOWND_PORT;
|
32
|
+
# define LOCKDOWND_INVALID_PORT (NULL)
|
33
|
+
#else
|
34
|
+
typedef uint16_t LOCKDOWND_PORT;
|
35
|
+
# define LOCKDOWND_INVALID_PORT 0
|
36
|
+
#endif
|
37
|
+
|
25
38
|
|
26
39
|
#define DBG(...) //printf(__VA_ARGS__)
|
27
40
|
|
@@ -34,7 +47,7 @@ protected:
|
|
34
47
|
off_t _blocksize; //= 4096
|
35
48
|
idevice_t _idev;
|
36
49
|
lockdownd_client_t _control;
|
37
|
-
|
50
|
+
LOCKDOWND_PORT _port;
|
38
51
|
afc_client_t _afc;
|
39
52
|
house_arrest_client_t _house_arrest;
|
40
53
|
|
data/io-afc.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/suzumura-ss/ruby-io-afc"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files =
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
data/lib/io/afc/version.rb
CHANGED
data/lib/io/afc.rb
CHANGED
@@ -23,8 +23,9 @@ public
|
|
23
23
|
|
24
24
|
##
|
25
25
|
# Connect to iOS-Device and yield block with handle if specified.
|
26
|
-
# @
|
27
|
-
# @option [
|
26
|
+
# @param [Hash] opt options for connect device.
|
27
|
+
# @option opt [String] :uuid Target UUID. if nil, connect to default device.
|
28
|
+
# @option opt [String] :appid Mount application's document folder if specified.
|
28
29
|
# @return [IO::AFC or block-result]
|
29
30
|
def self.connect(opt={}, &block)
|
30
31
|
dev = self.new(opt[:udid], opt[:appid])
|
@@ -43,21 +44,20 @@ public
|
|
43
44
|
##
|
44
45
|
# Get storage info.
|
45
46
|
# @return [Hash]
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# :Model=>"iPod5,1"}
|
47
|
+
# @example
|
48
|
+
# afc.statfs
|
49
|
+
# => {:FSBlockSize=>4096,
|
50
|
+
# :FSFreeBytes=>27478216704,
|
51
|
+
# :FSTotalBytes=>30178787328,
|
52
|
+
# :Model=>"iPod5,1"}
|
53
53
|
def statfs
|
54
54
|
dict_to_hash(super)
|
55
55
|
end
|
56
56
|
|
57
57
|
##
|
58
58
|
# Open file.
|
59
|
-
# @param [String] path for target file.
|
60
|
-
# @param [IO::Constants] mode for open mode.
|
59
|
+
# @param [String] path pathname for target file.
|
60
|
+
# @param [IO::Constants] mode for open mode.
|
61
61
|
def open(path, mode = IO::RDONLY, &block)
|
62
62
|
raise ArgumentError, "block is required." unless block_given?
|
63
63
|
File.open_file(self, path, mode, &block)
|
@@ -65,25 +65,23 @@ public
|
|
65
65
|
|
66
66
|
##
|
67
67
|
# Get file/directory attribytes.
|
68
|
-
# @param [String] path.
|
68
|
+
# @param [String] path pathname for get attributes.
|
69
69
|
# @return [Hash]
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
# :st_blocks=>11256,
|
86
|
-
# :st_size=>5763072}
|
70
|
+
# @example
|
71
|
+
# afc.getattr("/Safari")
|
72
|
+
# => {:st_birthtime=>2012-12-17 12:28:23 +0900,
|
73
|
+
# :st_mtime=>2013-06-22 20:32:01 +0900
|
74
|
+
# :st_ifmt=>"S_IFDIR",
|
75
|
+
# :st_nlink=>2,
|
76
|
+
# :st_blocks=>0,
|
77
|
+
# :st_size=>102}
|
78
|
+
# afc.getattr("/Safari/goog-phish-shavar.db")
|
79
|
+
# => {:st_birthtime=>2013-06-21 02:31:17 +0900,
|
80
|
+
# :st_mtime=>2013-06-21 02:31:18 +0900,
|
81
|
+
# :st_ifmt=>"S_IFREG",
|
82
|
+
# :st_nlink=>1,
|
83
|
+
# :st_blocks=>11256,
|
84
|
+
# :st_size=>5763072}
|
87
85
|
def getattr(path)
|
88
86
|
r = dict_to_hash(super(path))
|
89
87
|
[:st_birthtime, :st_mtime].each{|k|
|
@@ -94,7 +92,7 @@ public
|
|
94
92
|
|
95
93
|
##
|
96
94
|
# Check exist
|
97
|
-
# @param [String] path.
|
95
|
+
# @param [String] path pathname for check exists.
|
98
96
|
# @return [String or nil] return type or nil.
|
99
97
|
def exist?(path)
|
100
98
|
begin
|
@@ -106,7 +104,7 @@ public
|
|
106
104
|
|
107
105
|
##
|
108
106
|
# Read symlink.
|
109
|
-
# @param [String] path.
|
107
|
+
# @param [String] path pathname for read symlink.
|
110
108
|
# @return [String or nil] return symlink-target.
|
111
109
|
def readlink(path)
|
112
110
|
getattr(path)[:LinkTarget]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-afc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -51,23 +51,22 @@ extensions:
|
|
51
51
|
- ext/io/afc/extconf.rb
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
+
- .gitignore
|
55
|
+
- .yardopts
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
54
60
|
- ext/io/afc/build.xcconfig
|
55
61
|
- ext/io/afc/extconf.rb
|
56
62
|
- ext/io/afc/ioafc.cpp
|
57
63
|
- ext/io/afc/ioafc.h
|
58
64
|
- ext/io/afc/ruby_wrapper.h
|
59
|
-
- Gemfile
|
60
|
-
- Gemfile.lock
|
61
65
|
- io-afc.gemspec
|
62
66
|
- io-afc.xcodeproj/project.pbxproj
|
67
|
+
- lib/io/afc.rb
|
63
68
|
- lib/io/afc/file.rb
|
64
69
|
- lib/io/afc/version.rb
|
65
|
-
- lib/io/afc.rb
|
66
|
-
- LICENSE.txt
|
67
|
-
- pkg/io-afc-0.0.3.1.gem
|
68
|
-
- pkg/io-afc-0.0.3.2.gem
|
69
|
-
- Rakefile
|
70
|
-
- README.md
|
71
70
|
- spec/afc_file_spec.rb
|
72
71
|
- spec/afc_spec.rb
|
73
72
|
- spec/basicio_filectrl_spec.rb
|
@@ -87,18 +86,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
86
|
- - ! '>='
|
88
87
|
- !ruby/object:Gem::Version
|
89
88
|
version: '0'
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
hash: 378568250842512408
|
93
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
90
|
none: false
|
95
91
|
requirements:
|
96
92
|
- - ! '>='
|
97
93
|
- !ruby/object:Gem::Version
|
98
94
|
version: '0'
|
99
|
-
segments:
|
100
|
-
- 0
|
101
|
-
hash: 378568250842512408
|
102
95
|
requirements: []
|
103
96
|
rubyforge_project:
|
104
97
|
rubygems_version: 1.8.25
|
@@ -112,3 +105,4 @@ test_files:
|
|
112
105
|
- spec/basicio_fileio_spec.rb
|
113
106
|
- spec/basicio_spec.rb
|
114
107
|
- spec/spec_helper.rb
|
108
|
+
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
io-afc (0.0.3.2)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
coderay (1.0.9)
|
10
|
-
diff-lcs (1.2.4)
|
11
|
-
method_source (0.8.1)
|
12
|
-
pry (0.9.12.2)
|
13
|
-
coderay (~> 1.0.5)
|
14
|
-
method_source (~> 0.8)
|
15
|
-
slop (~> 3.4)
|
16
|
-
pry-nav (0.2.3)
|
17
|
-
pry (~> 0.9.10)
|
18
|
-
rake (10.0.4)
|
19
|
-
rspec (2.13.0)
|
20
|
-
rspec-core (~> 2.13.0)
|
21
|
-
rspec-expectations (~> 2.13.0)
|
22
|
-
rspec-mocks (~> 2.13.0)
|
23
|
-
rspec-core (2.13.1)
|
24
|
-
rspec-expectations (2.13.0)
|
25
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
26
|
-
rspec-mocks (2.13.1)
|
27
|
-
slop (3.4.5)
|
28
|
-
|
29
|
-
PLATFORMS
|
30
|
-
ruby
|
31
|
-
|
32
|
-
DEPENDENCIES
|
33
|
-
bundler (~> 1.3)
|
34
|
-
io-afc!
|
35
|
-
pry
|
36
|
-
pry-nav
|
37
|
-
rake
|
38
|
-
rspec
|
data/pkg/io-afc-0.0.3.1.gem
DELETED
Binary file
|
data/pkg/io-afc-0.0.3.2.gem
DELETED
Binary file
|