libgfapi-ruby 0.0.2 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/glusterfs.rb +3 -2
- data/lib/glusterfs/file.rb +25 -0
- data/lib/glusterfs/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0669cfea34e893de481678cc8e1b9a67e795cbf4
|
4
|
+
data.tar.gz: 1b71461efff897518ebcfa0dc06c7e3c2f9c3e29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba03a9428231f95351eb74732df8c33240453bc59a3a051aadae9f5d9c074ce5ecb698fcc7bc55a280de11498aaa810b959fb72e9e322d139d1ede07057f4921
|
7
|
+
data.tar.gz: 04db7ce3f2046076f6af679d02eea68f17a0da9ac086031321fe6c0aa97dc81f72f0524fb0f1952ebec100d7f6da6cecf12a34a9b6e151584de700b6d100d323
|
data/README.md
CHANGED
@@ -31,10 +31,13 @@ GlusterFS.init fs
|
|
31
31
|
GlusterFS.mkdir fs, '/some_dir', 0755
|
32
32
|
|
33
33
|
# Write a file
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
file = File.open('/some/file')
|
35
|
+
size = GlusterFS::File.write(fs, '/gfs/file/path', file)
|
36
|
+
puts "Written #{size} bytes"
|
37
|
+
|
38
|
+
# Read a file
|
39
|
+
file = GlusterFS::File.read(fs, '/gfs/file/path')
|
40
|
+
contents = file.read
|
38
41
|
|
39
42
|
# Destroy virtual mount
|
40
43
|
GlusterFS.fini fs
|
data/lib/glusterfs.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "glusterfs/version"
|
2
|
+
require "glusterfs/file"
|
2
3
|
require "ffi"
|
3
4
|
|
4
5
|
module GlusterFS
|
@@ -310,8 +311,8 @@ module GlusterFS
|
|
310
311
|
int glfs_write_async (glfs_fd_t *fd, const void *buf, size_t count, int flags,
|
311
312
|
glfs_io_cbk fn, void *data) __THROW;
|
312
313
|
=end
|
313
|
-
attach_function :read, :glfs_read, [:pointer, :
|
314
|
-
attach_function :write, :glfs_write, [:pointer, :
|
314
|
+
attach_function :read, :glfs_read, [:pointer, :pointer, :uint, :int], :uint
|
315
|
+
attach_function :write, :glfs_write, [:pointer, :pointer, :uint, :int], :uint
|
315
316
|
# TODO async
|
316
317
|
|
317
318
|
=begin
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
class GlusterFS::File
|
3
|
+
class << self
|
4
|
+
def read(fs, path, buf_size = 4092)
|
5
|
+
fd = GlusterFS.open(fs, path, 0)
|
6
|
+
temp = Tempfile.new(path.gsub('/', '-'))
|
7
|
+
buff = FFI::MemoryPointer.new(:char, buf_size)
|
8
|
+
res = 1
|
9
|
+
while res > 0
|
10
|
+
res = GlusterFS.read(fd, buff, buf_size, 0)
|
11
|
+
temp.write(buff.get_bytes(0, res)) if res > 0
|
12
|
+
end
|
13
|
+
GlusterFS.close(fd)
|
14
|
+
temp.rewind
|
15
|
+
temp
|
16
|
+
end
|
17
|
+
|
18
|
+
def write(fs, path, file, perms = 0644)
|
19
|
+
fd = GlusterFS.creat(fs, path, 2, perms)
|
20
|
+
res = GlusterFS.write(fd, file.read, file.size, 0)
|
21
|
+
GlusterFS.close(fd)
|
22
|
+
res
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/glusterfs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgfapi-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Varaneckas
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
67
|
- lib/glusterfs.rb
|
68
|
+
- lib/glusterfs/file.rb
|
68
69
|
- lib/glusterfs/version.rb
|
69
70
|
- libgfapi-ruby.gemspec
|
70
71
|
homepage: https://github.com/spajus/libgfapi-ruby
|