io-afc 0.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +38 -0
- data/ext/io/afc/build.xcconfig +7 -0
- data/ext/io/afc/extconf.rb +7 -0
- data/ext/io/afc/ioafc.cpp +739 -0
- data/ext/io/afc/ioafc.h +248 -0
- data/ext/io/afc/ruby_wrapper.h +25 -0
- data/io-afc.gemspec +24 -0
- data/io-afc.xcodeproj/project.pbxproj +268 -0
- data/lib/io/afc/file.rb +27 -0
- data/lib/io/afc/version.rb +5 -0
- data/lib/io/afc.rb +115 -0
- data/pkg/io-afc-0.0.3.1.gem +0 -0
- data/pkg/io-afc-0.0.3.2.gem +0 -0
- data/spec/afc_file_spec.rb +39 -0
- data/spec/afc_spec.rb +87 -0
- data/spec/basicio_filectrl_spec.rb +50 -0
- data/spec/basicio_fileio_spec.rb +60 -0
- data/spec/basicio_spec.rb +79 -0
- data/spec/spec_helper.rb +48 -0
- metadata +114 -0
data/ext/io/afc/ioafc.h
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
//-*- coding: utf-8
|
2
|
+
//-*- vim: sw=4:ts=4:sts=4
|
3
|
+
|
4
|
+
#ifndef __INCLUDE_IO_AFC_H__
|
5
|
+
#define __INCLUDE_IO_AFC_H__
|
6
|
+
#pragma GCC visibility push(default)
|
7
|
+
|
8
|
+
#include "ruby_wrapper.h"
|
9
|
+
#include <string>
|
10
|
+
#include <vector>
|
11
|
+
|
12
|
+
// https://github.com/mcolyer/ifuse/blob/master/src/ifuse.c
|
13
|
+
#define AFC_SERVICE_NAME "com.apple.afc"
|
14
|
+
#define HOUSE_ARREST_SERVICE_NAME "com.apple.mobile.house_arrest"
|
15
|
+
|
16
|
+
// https://github.com/GNOME/gvfs/blob/master/daemon/gvfsbackendafc.c
|
17
|
+
#define INSTALLATION_PROXY_SERVICE_NAME "com.apple.mobile.installation_proxy"
|
18
|
+
|
19
|
+
#include <libimobiledevice/libimobiledevice.h>
|
20
|
+
#include <libimobiledevice/lockdown.h>
|
21
|
+
#include <libimobiledevice/afc.h>
|
22
|
+
#include <libimobiledevice/house_arrest.h>
|
23
|
+
#include <libimobiledevice/installation_proxy.h>
|
24
|
+
|
25
|
+
|
26
|
+
#define DBG(...) //printf(__VA_ARGS__)
|
27
|
+
|
28
|
+
using namespace std;
|
29
|
+
|
30
|
+
|
31
|
+
class IoAFC : public RubyWrapper<IoAFC>
|
32
|
+
{
|
33
|
+
protected:
|
34
|
+
off_t _blocksize; //= 4096
|
35
|
+
idevice_t _idev;
|
36
|
+
lockdownd_client_t _control;
|
37
|
+
lockdownd_service_descriptor_t _port;
|
38
|
+
afc_client_t _afc;
|
39
|
+
house_arrest_client_t _house_arrest;
|
40
|
+
|
41
|
+
string _device_uuid;
|
42
|
+
string _appid;
|
43
|
+
const char* _service_name;
|
44
|
+
string _errmsg;
|
45
|
+
|
46
|
+
public:
|
47
|
+
IoAFC();
|
48
|
+
virtual ~IoAFC();
|
49
|
+
|
50
|
+
protected:
|
51
|
+
inline void checkHandle()
|
52
|
+
{
|
53
|
+
if (_afc==NULL) rb_raise(rb_eIOError, "closed handle.");
|
54
|
+
}
|
55
|
+
|
56
|
+
void teardown();
|
57
|
+
void init(VALUE rb_device_uuid, VALUE rb_appid);
|
58
|
+
VALUE test_closed();
|
59
|
+
VALUE close();
|
60
|
+
uint64_t open(afc_client_t* afc, VALUE rb_path, VALUE rb_mode);
|
61
|
+
VALUE getattr(VALUE rb_path);
|
62
|
+
VALUE readdir(VALUE rb_path);
|
63
|
+
VALUE utimens(VALUE rb_path, VALUE rb_time);
|
64
|
+
VALUE statfs();
|
65
|
+
VALUE truncate(VALUE rb_path, VALUE rb_size);
|
66
|
+
VALUE symlink(VALUE rb_target, VALUE rb_linkname);
|
67
|
+
VALUE link(VALUE rb_target, VALUE rb_linkname);
|
68
|
+
VALUE unlink(VALUE rb_path);
|
69
|
+
VALUE rename(VALUE rb_from, VALUE rb_to);
|
70
|
+
VALUE mkdir(VALUE rb_path);
|
71
|
+
VALUE get_device_udid();
|
72
|
+
VALUE get_evice_display_name();
|
73
|
+
VALUE enum_applications();
|
74
|
+
|
75
|
+
public:
|
76
|
+
static void define_class();
|
77
|
+
static VALUE rb_init(VALUE self, VALUE rb_device_uuid, VALUE rb_appid)
|
78
|
+
{
|
79
|
+
get_self(self)->init(rb_device_uuid, rb_appid);
|
80
|
+
return self;
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE rb_test_closed(VALUE self)
|
84
|
+
{
|
85
|
+
return get_self(self)->test_closed();
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE rb_close(VALUE self)
|
89
|
+
{
|
90
|
+
return get_self(self)->close();
|
91
|
+
}
|
92
|
+
|
93
|
+
static uint64_t rb_open(VALUE self, afc_client_t* afc, VALUE rb_path, VALUE rb_mode)
|
94
|
+
{
|
95
|
+
return get_self(self)->open(afc, rb_path, rb_mode);
|
96
|
+
}
|
97
|
+
|
98
|
+
static VALUE rb_getattr(VALUE self, VALUE rb_path)
|
99
|
+
{
|
100
|
+
return get_self(self)->getattr(rb_path);
|
101
|
+
}
|
102
|
+
|
103
|
+
static VALUE rb_readdir(VALUE self, VALUE rb_path)
|
104
|
+
{
|
105
|
+
return get_self(self)->readdir(rb_path);
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE rb_utimens(VALUE self, VALUE rb_path, VALUE rb_time)
|
109
|
+
{
|
110
|
+
return get_self(self)->utimens(rb_path, rb_time);
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE rb_statfs(VALUE self)
|
114
|
+
{
|
115
|
+
return get_self(self)->statfs();
|
116
|
+
}
|
117
|
+
|
118
|
+
static VALUE rb_truncate(VALUE self, VALUE rb_path, VALUE rb_size)
|
119
|
+
{
|
120
|
+
return get_self(self)->truncate(rb_path, rb_size);
|
121
|
+
}
|
122
|
+
|
123
|
+
static VALUE rb_symlink(VALUE self, VALUE rb_target, VALUE rb_linkname)
|
124
|
+
{
|
125
|
+
return get_self(self)->symlink(rb_target, rb_linkname);
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE rb_link(VALUE self, VALUE rb_target, VALUE rb_linkname)
|
129
|
+
{
|
130
|
+
return get_self(self)->link(rb_target, rb_linkname);
|
131
|
+
}
|
132
|
+
|
133
|
+
static VALUE rb_unlink(VALUE self, VALUE rb_path)
|
134
|
+
{
|
135
|
+
return get_self(self)->unlink(rb_path);
|
136
|
+
}
|
137
|
+
|
138
|
+
static VALUE rb_rename(VALUE self, VALUE rb_from, VALUE rb_to)
|
139
|
+
{
|
140
|
+
return get_self(self)->rename(rb_from, rb_to);
|
141
|
+
}
|
142
|
+
|
143
|
+
static VALUE rb_mkdir(VALUE self, VALUE rb_path)
|
144
|
+
{
|
145
|
+
return get_self(self)->mkdir(rb_path);
|
146
|
+
}
|
147
|
+
|
148
|
+
static VALUE rb_get_device_udid(VALUE self)
|
149
|
+
{
|
150
|
+
return get_self(self)->get_device_udid();
|
151
|
+
}
|
152
|
+
|
153
|
+
static VALUE rb_get_device_display_name(VALUE self)
|
154
|
+
{
|
155
|
+
return get_self(self)->get_evice_display_name();
|
156
|
+
}
|
157
|
+
|
158
|
+
static VALUE rb_enum_applications(VALUE self)
|
159
|
+
{
|
160
|
+
return get_self(self)->enum_applications();
|
161
|
+
}
|
162
|
+
};
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
class IoAFCDescriptor : public RubyWrapper<IoAFCDescriptor>
|
167
|
+
{
|
168
|
+
protected:
|
169
|
+
afc_client_t _afc;
|
170
|
+
uint64_t _handle;
|
171
|
+
uint64_t _seekptr;
|
172
|
+
|
173
|
+
public:
|
174
|
+
IoAFCDescriptor();
|
175
|
+
virtual ~IoAFCDescriptor();
|
176
|
+
|
177
|
+
protected:
|
178
|
+
inline void checkHandle()
|
179
|
+
{
|
180
|
+
if (_afc==NULL) rb_raise(rb_eIOError, "closed handle.");
|
181
|
+
}
|
182
|
+
|
183
|
+
void teardown();
|
184
|
+
void init(VALUE rb_afc, VALUE rb_path, VALUE rb_mode);
|
185
|
+
VALUE test_closed();
|
186
|
+
VALUE close();
|
187
|
+
VALUE read(VALUE rb_size);
|
188
|
+
VALUE write(VALUE rb_data);
|
189
|
+
VALUE seek(VALUE rb_offset, VALUE rb_mode);
|
190
|
+
VALUE tell();
|
191
|
+
VALUE ftruncate(VALUE rb_size);
|
192
|
+
|
193
|
+
public:
|
194
|
+
static void define_class();
|
195
|
+
static VALUE rb_init(VALUE self, VALUE rb_afc, VALUE rb_path, VALUE rb_mode)
|
196
|
+
{
|
197
|
+
get_self(self)->init(rb_afc, rb_path, rb_mode);
|
198
|
+
return self;
|
199
|
+
}
|
200
|
+
|
201
|
+
static void init(VALUE self, afc_client_t afc, uint64_t handle)
|
202
|
+
{
|
203
|
+
DBG("+ IO::AFC::FD: %p, %llx\n", afc, handle);
|
204
|
+
IoAFCDescriptor* p = get_self(self);
|
205
|
+
p->_afc = afc;
|
206
|
+
p->_handle = handle;
|
207
|
+
}
|
208
|
+
|
209
|
+
static VALUE rb_test_closed(VALUE self)
|
210
|
+
{
|
211
|
+
return get_self(self)->test_closed();
|
212
|
+
}
|
213
|
+
|
214
|
+
static VALUE rb_close(VALUE self)
|
215
|
+
{
|
216
|
+
return get_self(self)->close();
|
217
|
+
}
|
218
|
+
|
219
|
+
static VALUE rb_read(VALUE self, VALUE rb_size)
|
220
|
+
{
|
221
|
+
return get_self(self)->read(rb_size);
|
222
|
+
}
|
223
|
+
|
224
|
+
static VALUE rb_write(VALUE self, VALUE rb_data)
|
225
|
+
{
|
226
|
+
return get_self(self)->write(rb_data);
|
227
|
+
}
|
228
|
+
|
229
|
+
static VALUE rb_seek(VALUE self, VALUE rb_offset, VALUE rb_mode)
|
230
|
+
{
|
231
|
+
return get_self(self)->seek(rb_offset, rb_mode);
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE rb_tell(VALUE self)
|
235
|
+
{
|
236
|
+
return get_self(self)->tell();
|
237
|
+
}
|
238
|
+
|
239
|
+
static VALUE rb_ftruncate(VALUE self, VALUE rb_size)
|
240
|
+
{
|
241
|
+
return get_self(self)->ftruncate(rb_size);
|
242
|
+
}
|
243
|
+
};
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
#pragma GCC visibility pop
|
248
|
+
#endif //__INCLUDE_IO_AFC_H__
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
|
3
|
+
// C++/RUby wrapper
|
4
|
+
template<class T> class RubyWrapper
|
5
|
+
{
|
6
|
+
public:
|
7
|
+
static void gc_mark(void* self) {};
|
8
|
+
static VALUE rb_alloc(VALUE self)
|
9
|
+
{
|
10
|
+
T* p = (T*)ruby_xmalloc(sizeof(T));
|
11
|
+
new((void*)p) T;
|
12
|
+
return Data_Wrap_Struct(self, T::gc_mark, T::rb_free, p);
|
13
|
+
}
|
14
|
+
static void rb_free(void* obj)
|
15
|
+
{
|
16
|
+
((T*)obj)->~T();
|
17
|
+
ruby_xfree(obj);
|
18
|
+
}
|
19
|
+
static T* get_self(VALUE self)
|
20
|
+
{
|
21
|
+
T* t;
|
22
|
+
Data_Get_Struct(self, T, t);
|
23
|
+
return t;
|
24
|
+
}
|
25
|
+
};
|
data/io-afc.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'io/afc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "io-afc"
|
8
|
+
spec.version = IO::AFCVersion::VERSION
|
9
|
+
spec.authors = ["Toshiyuki Suzumura"]
|
10
|
+
spec.email = ["suz.labo@amail.plala.or.jp"]
|
11
|
+
spec.description = %q{Access to the file system of iOS devices from Ruby.}
|
12
|
+
spec.summary = %q{Access to the file system of iOS devices from Ruby. Required 'libimobiledevice'.}
|
13
|
+
spec.homepage = "https://github.com/suzumura-ss/ruby-io-afc"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir["**/*"]
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.extensions = ["ext/io/afc/extconf.rb"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
// !$*UTF8*$!
|
2
|
+
{
|
3
|
+
archiveVersion = 1;
|
4
|
+
classes = {
|
5
|
+
};
|
6
|
+
objectVersion = 46;
|
7
|
+
objects = {
|
8
|
+
|
9
|
+
/* Begin PBXBuildFile section */
|
10
|
+
52AB74CE1773016900006548 /* ioafc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52AB74CB1773016900006548 /* ioafc.cpp */; };
|
11
|
+
52AB74CF1773016900006548 /* ioafc.h in Headers */ = {isa = PBXBuildFile; fileRef = 52AB74CC1773016900006548 /* ioafc.h */; };
|
12
|
+
52AB74D01773016900006548 /* ruby_wrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 52AB74CD1773016900006548 /* ruby_wrapper.h */; };
|
13
|
+
/* End PBXBuildFile section */
|
14
|
+
|
15
|
+
/* Begin PBXFileReference section */
|
16
|
+
521137E51775955E0006A03F /* basicio_filectrl_spec.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = basicio_filectrl_spec.rb; sourceTree = "<group>"; };
|
17
|
+
521137E61775955E0006A03F /* basicio_fileio_spec.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = basicio_fileio_spec.rb; sourceTree = "<group>"; };
|
18
|
+
521137E71775955E0006A03F /* spec_helper.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = spec_helper.rb; sourceTree = "<group>"; };
|
19
|
+
521137E8177607BB0006A03F /* afc_file_spec.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = afc_file_spec.rb; sourceTree = "<group>"; };
|
20
|
+
521137E9177607BB0006A03F /* afc_spec.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = afc_spec.rb; sourceTree = "<group>"; };
|
21
|
+
52419F13177300380029B2F5 /* io-afc.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "io-afc.dylib"; sourceTree = BUILT_PRODUCTS_DIR; };
|
22
|
+
52AB74CB1773016900006548 /* ioafc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ioafc.cpp; sourceTree = "<group>"; };
|
23
|
+
52AB74CC1773016900006548 /* ioafc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioafc.h; sourceTree = "<group>"; };
|
24
|
+
52AB74CD1773016900006548 /* ruby_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ruby_wrapper.h; sourceTree = "<group>"; };
|
25
|
+
52AB74D1177301B700006548 /* build.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = build.xcconfig; sourceTree = "<group>"; };
|
26
|
+
52FBF87F177353D000B30F96 /* basicio_spec.rb */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = basicio_spec.rb; sourceTree = "<group>"; };
|
27
|
+
/* End PBXFileReference section */
|
28
|
+
|
29
|
+
/* Begin PBXFrameworksBuildPhase section */
|
30
|
+
52419F10177300380029B2F5 /* Frameworks */ = {
|
31
|
+
isa = PBXFrameworksBuildPhase;
|
32
|
+
buildActionMask = 2147483647;
|
33
|
+
files = (
|
34
|
+
);
|
35
|
+
runOnlyForDeploymentPostprocessing = 0;
|
36
|
+
};
|
37
|
+
/* End PBXFrameworksBuildPhase section */
|
38
|
+
|
39
|
+
/* Begin PBXGroup section */
|
40
|
+
52419F0A177300380029B2F5 = {
|
41
|
+
isa = PBXGroup;
|
42
|
+
children = (
|
43
|
+
52FBF87E177353D000B30F96 /* spec */,
|
44
|
+
52AB74C71773016900006548 /* ext */,
|
45
|
+
52419F14177300380029B2F5 /* Products */,
|
46
|
+
);
|
47
|
+
sourceTree = "<group>";
|
48
|
+
};
|
49
|
+
52419F14177300380029B2F5 /* Products */ = {
|
50
|
+
isa = PBXGroup;
|
51
|
+
children = (
|
52
|
+
52419F13177300380029B2F5 /* io-afc.dylib */,
|
53
|
+
);
|
54
|
+
name = Products;
|
55
|
+
sourceTree = "<group>";
|
56
|
+
};
|
57
|
+
52AB74C71773016900006548 /* ext */ = {
|
58
|
+
isa = PBXGroup;
|
59
|
+
children = (
|
60
|
+
52AB74C81773016900006548 /* io */,
|
61
|
+
);
|
62
|
+
path = ext;
|
63
|
+
sourceTree = "<group>";
|
64
|
+
};
|
65
|
+
52AB74C81773016900006548 /* io */ = {
|
66
|
+
isa = PBXGroup;
|
67
|
+
children = (
|
68
|
+
52AB74C91773016900006548 /* afc */,
|
69
|
+
);
|
70
|
+
path = io;
|
71
|
+
sourceTree = "<group>";
|
72
|
+
};
|
73
|
+
52AB74C91773016900006548 /* afc */ = {
|
74
|
+
isa = PBXGroup;
|
75
|
+
children = (
|
76
|
+
52AB74CD1773016900006548 /* ruby_wrapper.h */,
|
77
|
+
52AB74CC1773016900006548 /* ioafc.h */,
|
78
|
+
52AB74CB1773016900006548 /* ioafc.cpp */,
|
79
|
+
52AB74D1177301B700006548 /* build.xcconfig */,
|
80
|
+
);
|
81
|
+
path = afc;
|
82
|
+
sourceTree = "<group>";
|
83
|
+
};
|
84
|
+
52FBF87E177353D000B30F96 /* spec */ = {
|
85
|
+
isa = PBXGroup;
|
86
|
+
children = (
|
87
|
+
521137E8177607BB0006A03F /* afc_file_spec.rb */,
|
88
|
+
521137E9177607BB0006A03F /* afc_spec.rb */,
|
89
|
+
521137E71775955E0006A03F /* spec_helper.rb */,
|
90
|
+
52FBF87F177353D000B30F96 /* basicio_spec.rb */,
|
91
|
+
521137E61775955E0006A03F /* basicio_fileio_spec.rb */,
|
92
|
+
521137E51775955E0006A03F /* basicio_filectrl_spec.rb */,
|
93
|
+
);
|
94
|
+
path = spec;
|
95
|
+
sourceTree = "<group>";
|
96
|
+
};
|
97
|
+
/* End PBXGroup section */
|
98
|
+
|
99
|
+
/* Begin PBXHeadersBuildPhase section */
|
100
|
+
52419F11177300380029B2F5 /* Headers */ = {
|
101
|
+
isa = PBXHeadersBuildPhase;
|
102
|
+
buildActionMask = 2147483647;
|
103
|
+
files = (
|
104
|
+
52AB74D01773016900006548 /* ruby_wrapper.h in Headers */,
|
105
|
+
52AB74CF1773016900006548 /* ioafc.h in Headers */,
|
106
|
+
);
|
107
|
+
runOnlyForDeploymentPostprocessing = 0;
|
108
|
+
};
|
109
|
+
/* End PBXHeadersBuildPhase section */
|
110
|
+
|
111
|
+
/* Begin PBXNativeTarget section */
|
112
|
+
52419F12177300380029B2F5 /* io-afc */ = {
|
113
|
+
isa = PBXNativeTarget;
|
114
|
+
buildConfigurationList = 52419F20177300380029B2F5 /* Build configuration list for PBXNativeTarget "io-afc" */;
|
115
|
+
buildPhases = (
|
116
|
+
52419F0F177300380029B2F5 /* Sources */,
|
117
|
+
52419F10177300380029B2F5 /* Frameworks */,
|
118
|
+
52419F11177300380029B2F5 /* Headers */,
|
119
|
+
);
|
120
|
+
buildRules = (
|
121
|
+
);
|
122
|
+
dependencies = (
|
123
|
+
);
|
124
|
+
name = "io-afc";
|
125
|
+
productName = "io-afc";
|
126
|
+
productReference = 52419F13177300380029B2F5 /* io-afc.dylib */;
|
127
|
+
productType = "com.apple.product-type.library.dynamic";
|
128
|
+
};
|
129
|
+
/* End PBXNativeTarget section */
|
130
|
+
|
131
|
+
/* Begin PBXProject section */
|
132
|
+
52419F0B177300380029B2F5 /* Project object */ = {
|
133
|
+
isa = PBXProject;
|
134
|
+
attributes = {
|
135
|
+
LastUpgradeCheck = 0500;
|
136
|
+
ORGANIZATIONNAME = suzumura_ss;
|
137
|
+
};
|
138
|
+
buildConfigurationList = 52419F0E177300380029B2F5 /* Build configuration list for PBXProject "io-afc" */;
|
139
|
+
compatibilityVersion = "Xcode 3.2";
|
140
|
+
developmentRegion = English;
|
141
|
+
hasScannedForEncodings = 0;
|
142
|
+
knownRegions = (
|
143
|
+
en,
|
144
|
+
);
|
145
|
+
mainGroup = 52419F0A177300380029B2F5;
|
146
|
+
productRefGroup = 52419F14177300380029B2F5 /* Products */;
|
147
|
+
projectDirPath = "";
|
148
|
+
projectRoot = "";
|
149
|
+
targets = (
|
150
|
+
52419F12177300380029B2F5 /* io-afc */,
|
151
|
+
);
|
152
|
+
};
|
153
|
+
/* End PBXProject section */
|
154
|
+
|
155
|
+
/* Begin PBXSourcesBuildPhase section */
|
156
|
+
52419F0F177300380029B2F5 /* Sources */ = {
|
157
|
+
isa = PBXSourcesBuildPhase;
|
158
|
+
buildActionMask = 2147483647;
|
159
|
+
files = (
|
160
|
+
52AB74CE1773016900006548 /* ioafc.cpp in Sources */,
|
161
|
+
);
|
162
|
+
runOnlyForDeploymentPostprocessing = 0;
|
163
|
+
};
|
164
|
+
/* End PBXSourcesBuildPhase section */
|
165
|
+
|
166
|
+
/* Begin XCBuildConfiguration section */
|
167
|
+
52419F1E177300380029B2F5 /* Debug */ = {
|
168
|
+
isa = XCBuildConfiguration;
|
169
|
+
buildSettings = {
|
170
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
171
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
172
|
+
CLANG_CXX_LIBRARY = "libc++";
|
173
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
174
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
175
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
176
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
177
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
178
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
179
|
+
COPY_PHASE_STRIP = NO;
|
180
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
181
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
182
|
+
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
183
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
184
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
185
|
+
"DEBUG=1",
|
186
|
+
"$(inherited)",
|
187
|
+
);
|
188
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
189
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
190
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
191
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
192
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
193
|
+
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
194
|
+
ONLY_ACTIVE_ARCH = YES;
|
195
|
+
SDKROOT = macosx;
|
196
|
+
};
|
197
|
+
name = Debug;
|
198
|
+
};
|
199
|
+
52419F1F177300380029B2F5 /* Release */ = {
|
200
|
+
isa = XCBuildConfiguration;
|
201
|
+
buildSettings = {
|
202
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
203
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
204
|
+
CLANG_CXX_LIBRARY = "libc++";
|
205
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
206
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
207
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
208
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
209
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
210
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
211
|
+
COPY_PHASE_STRIP = YES;
|
212
|
+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
213
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
214
|
+
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
215
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
216
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
217
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
218
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
219
|
+
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
220
|
+
SDKROOT = macosx;
|
221
|
+
};
|
222
|
+
name = Release;
|
223
|
+
};
|
224
|
+
52419F21177300380029B2F5 /* Debug */ = {
|
225
|
+
isa = XCBuildConfiguration;
|
226
|
+
baseConfigurationReference = 52AB74D1177301B700006548 /* build.xcconfig */;
|
227
|
+
buildSettings = {
|
228
|
+
HEADER_SEARCH_PATHS = "$(EXT_INCLUDE_PATH)";
|
229
|
+
"OTHER_LDFLAGS[arch=*]" = "$(EXT_LDFLAGS)";
|
230
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
231
|
+
};
|
232
|
+
name = Debug;
|
233
|
+
};
|
234
|
+
52419F22177300380029B2F5 /* Release */ = {
|
235
|
+
isa = XCBuildConfiguration;
|
236
|
+
baseConfigurationReference = 52AB74D1177301B700006548 /* build.xcconfig */;
|
237
|
+
buildSettings = {
|
238
|
+
HEADER_SEARCH_PATHS = "$(EXT_INCLUDE_PATH)";
|
239
|
+
"OTHER_LDFLAGS[arch=*]" = "$(EXT_LDFLAGS)";
|
240
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
241
|
+
};
|
242
|
+
name = Release;
|
243
|
+
};
|
244
|
+
/* End XCBuildConfiguration section */
|
245
|
+
|
246
|
+
/* Begin XCConfigurationList section */
|
247
|
+
52419F0E177300380029B2F5 /* Build configuration list for PBXProject "io-afc" */ = {
|
248
|
+
isa = XCConfigurationList;
|
249
|
+
buildConfigurations = (
|
250
|
+
52419F1E177300380029B2F5 /* Debug */,
|
251
|
+
52419F1F177300380029B2F5 /* Release */,
|
252
|
+
);
|
253
|
+
defaultConfigurationIsVisible = 0;
|
254
|
+
defaultConfigurationName = Release;
|
255
|
+
};
|
256
|
+
52419F20177300380029B2F5 /* Build configuration list for PBXNativeTarget "io-afc" */ = {
|
257
|
+
isa = XCConfigurationList;
|
258
|
+
buildConfigurations = (
|
259
|
+
52419F21177300380029B2F5 /* Debug */,
|
260
|
+
52419F22177300380029B2F5 /* Release */,
|
261
|
+
);
|
262
|
+
defaultConfigurationIsVisible = 0;
|
263
|
+
defaultConfigurationName = Release;
|
264
|
+
};
|
265
|
+
/* End XCConfigurationList section */
|
266
|
+
};
|
267
|
+
rootObject = 52419F0B177300380029B2F5 /* Project object */;
|
268
|
+
}
|
data/lib/io/afc/file.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'io/afc/version'
|
2
|
+
require 'io/afc/afc_base'
|
3
|
+
|
4
|
+
class IO
|
5
|
+
class AFC < AFCBase
|
6
|
+
class File < Descriptor
|
7
|
+
public
|
8
|
+
|
9
|
+
##
|
10
|
+
# Open file. / Invoke from IO::AFC#open
|
11
|
+
# @param [String] path for target file.
|
12
|
+
# @param [IO::Constants] mode for open mode. Default is IO::RDONLY.
|
13
|
+
def self.open_file(afc, path, mode = IO::RDONLY, &block)
|
14
|
+
raise ArgumentError, "block is required." unless block_given?
|
15
|
+
fd = self.new(afc, path, mode)
|
16
|
+
begin
|
17
|
+
r = yield(fd)
|
18
|
+
fd.close
|
19
|
+
rescue Exception=>e
|
20
|
+
fd.close
|
21
|
+
throw e
|
22
|
+
end
|
23
|
+
r
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|