rfuse_symbolic_fs 0.0.1 → 0.0.2
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/lib/rfuse_symbolic_fs_opts.rb +5 -3
- metadata +4 -6
- data/lib/amaras_fs.rb +0 -144
- data/lib/test_fuse.rb +0 -74
@@ -9,7 +9,7 @@ class RFuseSymbolicFSOpts
|
|
9
9
|
# Return a structure describing the options.
|
10
10
|
#
|
11
11
|
def self.parse(args)
|
12
|
-
@VERSION = "0.0.
|
12
|
+
@VERSION = "0.0.2"
|
13
13
|
|
14
14
|
# The options specified on the command line will be collected in *options*.
|
15
15
|
# We set default values here.
|
@@ -53,7 +53,7 @@ class RFuseSymbolicFSOpts
|
|
53
53
|
end
|
54
54
|
|
55
55
|
opts.on("--input N", String, "Folder FS will point to") do |n|
|
56
|
-
options.input = n
|
56
|
+
options.input = File.expand_path( n )
|
57
57
|
end
|
58
58
|
|
59
59
|
|
@@ -63,8 +63,10 @@ class RFuseSymbolicFSOpts
|
|
63
63
|
|
64
64
|
if (options.mountpoint == "") and (options.input == "") and (options.leftovers.size==2)
|
65
65
|
options.mountpoint = options.leftovers[0]
|
66
|
-
options.input = options.leftovers[1]
|
66
|
+
options.input = File.expand_path( options.leftovers[1] )
|
67
67
|
end
|
68
|
+
|
69
|
+
|
68
70
|
return options
|
69
71
|
end # parse()
|
70
72
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfuse_symbolic_fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morgan Prior
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-28 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -44,10 +44,8 @@ extra_rdoc_files: []
|
|
44
44
|
|
45
45
|
files:
|
46
46
|
- bin/rfuse_symbolic_fs
|
47
|
-
- lib/amaras_fs.rb
|
48
47
|
- lib/rfuse_symbolic_fs.rb
|
49
48
|
- lib/rfuse_symbolic_fs_opts.rb
|
50
|
-
- lib/test_fuse.rb
|
51
49
|
has_rdoc: true
|
52
50
|
homepage: http://amaras-tech.co.uk/software/rfuse_symbolic_fs
|
53
51
|
licenses: []
|
data/lib/amaras_fs.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
|
3
|
-
class AmarasFS
|
4
|
-
|
5
|
-
def initialize(*args)
|
6
|
-
start_time = Time.now
|
7
|
-
begin
|
8
|
-
@root = args[0]
|
9
|
-
|
10
|
-
@partitions = Array.new
|
11
|
-
(1...(args.size)).each_with_index do |x, index|
|
12
|
-
@partitions << args[x]
|
13
|
-
#puts args[x]
|
14
|
-
end
|
15
|
-
puts
|
16
|
-
puts
|
17
|
-
|
18
|
-
puts
|
19
|
-
puts "Starting Linking"
|
20
|
-
@partitions.each do |y|
|
21
|
-
build_links( @root, y )
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
rescue => e
|
27
|
-
puts
|
28
|
-
puts "ERROR caught Exception"
|
29
|
-
puts $!
|
30
|
-
puts e.inspect
|
31
|
-
puts e.backtrace
|
32
|
-
puts
|
33
|
-
end
|
34
|
-
puts "Run Time #{start_time - Time.now}"
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def build_links( root, y , spacer=' ')
|
42
|
-
#puts "build_links( root, y )"
|
43
|
-
puts "#{spacer}build_links( #{root}, #{y})"
|
44
|
-
|
45
|
-
files = Dir.glob(y + '/*')
|
46
|
-
|
47
|
-
pp files
|
48
|
-
|
49
|
-
#puts "Iterating of SubFiles"
|
50
|
-
files.each do |x|
|
51
|
-
|
52
|
-
#TODO validation that link does not already exist
|
53
|
-
|
54
|
-
new_link = x.dup
|
55
|
-
new_link[y] = ""
|
56
|
-
new_link = root + new_link
|
57
|
-
|
58
|
-
puts
|
59
|
-
puts "#{spacer}Thinking about linking #{new_link} "
|
60
|
-
#puts " sub file #{x}"
|
61
|
-
|
62
|
-
#Verify that new_link does not exists
|
63
|
-
if not File.exist?( new_link )
|
64
|
-
puts "#{spacer}Mode :1 INFO : File.symlink(#{x}, #{new_link} )"
|
65
|
-
File.symlink(x, new_link)
|
66
|
-
|
67
|
-
elsif ( ( File.symlink?(new_link)) and ( File.readlink(new_link) == x))
|
68
|
-
#readlink rasies exception if called on non links so check is a link first
|
69
|
-
#Link exists but points to location we tried to set
|
70
|
-
puts "#{spacer}Mode :2 INFO : Link Exists & correct"
|
71
|
-
elsif ( ( File.symlink?(new_link)) and ( not File.readlink(new_link) == x ))
|
72
|
-
test_folder(new_link)
|
73
|
-
|
74
|
-
puts "#{spacer}Mode :3 ERROR : #{new_link} already exists"
|
75
|
-
puts "#{spacer} This section requires programming"
|
76
|
-
|
77
|
-
current_pointer = File.readlink(new_link)
|
78
|
-
|
79
|
-
puts "current_pointer #{current_pointer}"
|
80
|
-
puts " #{root}"
|
81
|
-
puts " #{x}"
|
82
|
-
puts " #{y}"
|
83
|
-
|
84
|
-
pos = current_pointer.rindex(File::SEPARATOR)
|
85
|
-
extra_bit = current_pointer[pos...(current_pointer.size)]
|
86
|
-
|
87
|
-
puts "extra_bit #{extra_bit}"
|
88
|
-
|
89
|
-
#/A/1/x
|
90
|
-
#/A/1/Y
|
91
|
-
#/B/1/z
|
92
|
-
#
|
93
|
-
# current_pointer = /A/1
|
94
|
-
|
95
|
-
#current pointer already has the extra_bit
|
96
|
-
new_root = root + extra_bit
|
97
|
-
next_pointer = x + extra_bit
|
98
|
-
|
99
|
-
puts "File Maintenance"
|
100
|
-
|
101
|
-
FileUtils.rm( new_root )
|
102
|
-
FileUtils.mkdir( new_root )
|
103
|
-
|
104
|
-
build_links(new_root , x, spacer+' ')
|
105
|
-
build_links(new_root , current_pointer, spacer+' ')
|
106
|
-
|
107
|
-
|
108
|
-
elsif File.directory?(new_link)
|
109
|
-
#new_link already exists as folder
|
110
|
-
# this implies it already exists on another drive
|
111
|
-
# just recurse on this lower level
|
112
|
-
puts "#{spacer}Mode :4 INFO : Doing recursive call to build links"
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
new_root = x.dup
|
117
|
-
new_root[y] = ""
|
118
|
-
new_root = root + new_root
|
119
|
-
|
120
|
-
build_links(new_root, x, spacer+' ' )
|
121
|
-
else
|
122
|
-
#Link does exist and points to different Location
|
123
|
-
# What could have caused this?
|
124
|
-
# 1) Data has been completely moved to another Drive
|
125
|
-
# 2) Drive was running out of room and this folder has been split across 2 or more drives
|
126
|
-
#
|
127
|
-
# To resolve this copy current link location if it exists save location for later
|
128
|
-
# Create this folder and link in contnents from new drive then repeat for original location
|
129
|
-
|
130
|
-
puts "#{spacer}Mode :5 ERROR : #{new_link} already exists"
|
131
|
-
puts "#{spacer} This section requires programming"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
|
137
|
-
def test_folder(path)
|
138
|
-
puts "File #{File.file?(path)}"
|
139
|
-
puts "Folder #{File.directory?(path)}"
|
140
|
-
puts "Symlink #{File.symlink?(path)}"
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
data/lib/test_fuse.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require 'fusefs'
|
3
|
-
|
4
|
-
class HelloDir
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@base_dir = '/Users/morgy/Movies'
|
8
|
-
end
|
9
|
-
|
10
|
-
def contents(path)
|
11
|
-
n_path = File.expand_path( @base_dir + path )
|
12
|
-
Dir.chdir(n_path)
|
13
|
-
|
14
|
-
files = Dir.glob('*')
|
15
|
-
files << 'hello.txt'
|
16
|
-
files << 'metadata_never_index'
|
17
|
-
end
|
18
|
-
|
19
|
-
def file?(path)
|
20
|
-
if path == '/hello.txt'
|
21
|
-
return true
|
22
|
-
end
|
23
|
-
|
24
|
-
if path == '/metadata_never_index'
|
25
|
-
return true
|
26
|
-
end
|
27
|
-
|
28
|
-
if File.exists?(@base_dir + path )
|
29
|
-
#puts "file? #{@base_dir}#{path} "
|
30
|
-
if File.directory?(@base_dir + path )
|
31
|
-
return false
|
32
|
-
else
|
33
|
-
return true
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def directory?(path)
|
40
|
-
File.directory?(@base_dir + path)
|
41
|
-
end
|
42
|
-
|
43
|
-
def read_file(path)
|
44
|
-
puts "read file #{path}"
|
45
|
-
if path == '/hello.txt'
|
46
|
-
return "Hello, World!\n"
|
47
|
-
end
|
48
|
-
puts "exists?"
|
49
|
-
if File.exists?( @base_dir + path )
|
50
|
-
puts " true #{@base_dir}#{path}"
|
51
|
-
return File.new(@base_dir + path , "r").read
|
52
|
-
else
|
53
|
-
puts " fail #{@base_dir}#{path}"
|
54
|
-
end
|
55
|
-
return "ERROR, file not found\n"
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def size(path)
|
60
|
-
if File.exists?( @base_dir + path )
|
61
|
-
return File.size( @base_dir + path )
|
62
|
-
else
|
63
|
-
return 16
|
64
|
-
end
|
65
|
-
#read_file(path).size
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
hellodir = HelloDir.new
|
70
|
-
FuseFS.set_root( hellodir )
|
71
|
-
|
72
|
-
# Mount under a directory given on the command line.
|
73
|
-
FuseFS.mount_under ARGV.shift
|
74
|
-
FuseFS.run
|