RAliasFile 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/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
- * sendfile 0.0.1 - 2006.08.30 <yvon_thoraval@mac.com>
1
+ * raliasfile 0.0.1 - 2006.08.30 <yvon_thoraval@mac.com>
2
+
3
+ - Initial release
4
+
5
+ * raliasfile 0.0.1 - 2006.08.30 <yvon_thoraval@mac.com>
2
6
 
3
7
  - Initial release
data/ext/extconf.rb CHANGED
@@ -3,21 +3,13 @@
3
3
  require 'mkmf'
4
4
 
5
5
  case RUBY_PLATFORM
6
- when /powerpc-darwin8.7.0/
6
+ when /powerpc-darwin8\.\d\.\d/
7
7
  $CFLAGS << " -I /System/Library/Frameworks/Carbon.framework/Headers "
8
8
  $CFLAGS << " -I /System/Library/Frameworks/CoreFoundation.framework/Headers "
9
- $CFLAGS << " -I /System/Library/Frameworks/CoreServices.framework/Headers "
10
- #$CFLAGS << " -I /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers "
11
- $CFLAGS << " -I /System/Library/Frameworks/Foundation.framework/Headers "
12
- $CFLAGS << " -I /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers "
13
9
  $CFLAGS << " -fnested-functions "
14
- #$LDFLAGS << " -framework OSServices"
10
+
15
11
  $LDFLAGS << " -framework CoreFoundation "
16
12
  $LDFLAGS << " -framework Carbon "
17
- #$LDFLAGS << " -framework CoreFoundation Carbon"
18
- $LDFLAGS << " -framework CoreServices "
19
- #$LDFLAGS << " -framework CoreFoundation CoreServices"
20
- $LDFLAGS << " -framework Foundation "
21
13
 
22
14
  # Give it a name
23
15
  extension_name = 'raliasfile'
data/ext/raliasfile.c CHANGED
@@ -1,19 +1,41 @@
1
1
  //
2
2
  // RAliasFile.c
3
3
  //
4
+ /*
5
+ * Resolve an alias file returning the path of alias target from
6
+ * alias path.
7
+ * Provides additionnal info on both the alias file itself and
8
+ * the target file/folder.
9
+ *
10
+ * Print-out version number :
11
+ * RAliasFile.version
12
+ *
13
+ * Typical use from Ruby :
14
+ * raf=RAliasFile.new("/absolute/path/to/alias/file")
15
+ *
16
+ * raf.alias_path # => returns the given input alias path
17
+ * raf.path_exists? # => returns true if the alias path does exists on the file system, false otherwise
18
+ * raf.is_alias_file? # => returns true if the alias is truly an alias file one, false otherwise
19
+ * raf.is_alias_broken? # => returns true if alias is broken, false otherwise
20
+ * raf.resolved_path # => returns the path of the alias target
21
+ * raf.was_aliased? # => returns true if the alias is a correct alias file, false otherwise
22
+ * raf.is_folder_alias? # => returns true if the target of the alias is a folder, false otherwise
23
+ * raf.is_file_alias? # => returns true if the target of the alias is a file, false otherwise
24
+ */
4
25
 
5
26
  #include <CoreFoundation/CoreFoundation.h>
6
27
  #include <Carbon/Carbon.h>
7
28
  #include <CFURL.h>
8
29
  #include <ruby.h>
9
30
 
10
- VALUE RAliasFile = Qnil;
11
31
  VALUE cRAliasFile;
12
- VALUE alias_path;
13
32
 
33
+ /*
34
+ * #initialize :
35
+ * Initialize all internal variables
36
+ */
14
37
  VALUE m_raliasfile_init(VALUE self, VALUE alias_path)
15
38
  {
16
- //printf("From C => alias_path : %s\n", StringValuePtr(alias_path));
17
39
  char resolved_path[256] = "";
18
40
  VALUE is_alias_file=Qfalse;
19
41
  VALUE path_exists=Qfalse;
@@ -73,59 +95,102 @@ VALUE m_raliasfile_init(VALUE self, VALUE alias_path)
73
95
  return self;
74
96
  }
75
97
 
76
- VALUE m_set_alias_path(VALUE self, VALUE _alias_path) {
77
- alias_path = _alias_path;
98
+ /*
99
+ * #alias_path= :
100
+ * set alias path to _alias_path
101
+ */
102
+ VALUE m_set_alias_path(VALUE self, VALUE alias_path) {
78
103
  rb_iv_set(self, "@alias_path", alias_path);
79
104
  }
80
105
 
106
+ /*
107
+ * #path_exists? :
108
+ * returns true if the path given for the alias file is on the file system, false otherwise
109
+ */
81
110
  VALUE m_path_exists(VALUE self) {
82
111
  return rb_iv_get(self, "@path_exists");
83
112
  }
84
113
 
114
+ /*
115
+ * #alias_path :
116
+ * returns the input path given for the alias file
117
+ */
85
118
  VALUE m_alias_path(VALUE self) {
86
119
  return rb_iv_get(self, "@alias_path");
87
120
  }
88
121
 
122
+ /*
123
+ * #is_alias_file? :
124
+ * returns true if the alias file is truly an alias file, false otherwise
125
+ */
89
126
  VALUE m_alias_file(VALUE self) {
90
127
  return rb_iv_get(self, "@is_alias_file");
91
128
  }
92
129
 
130
+ /*
131
+ * #is_alias_broken? :
132
+ * returns true if the alias file is broken (dead target), false otherwise
133
+ */
93
134
  VALUE m_alias_broken(VALUE self) {
94
135
  return rb_iv_get(self, "@is_alias_broken");
95
136
  }
96
137
 
138
+ /*
139
+ * #resolved_path :
140
+ * returns the path of the alias target
141
+ */
97
142
  VALUE m_resolved_path(VALUE self) {
98
143
  return rb_iv_get(self, "@resolved_path");
99
144
  }
100
145
 
146
+ /*
147
+ * #was_aliased? :
148
+ * returns true if the alias file was aliased, false otherwise
149
+ */
101
150
  VALUE m_was_aliased(VALUE self) {
102
151
  return rb_iv_get(self, "@was_aliased");
103
152
  }
104
153
 
154
+ /*
155
+ * #is_folder_alias? :
156
+ * returns true if the alias file points to a folder target, false otherwise
157
+ */
105
158
  VALUE m_is_folder(VALUE self) {
106
159
  return rb_iv_get(self, "@folder");
107
160
  }
108
161
 
162
+ /*
163
+ * #is_file_alias? :
164
+ * returns true if the alias file points to a file target, false otherwise
165
+ */
109
166
  VALUE m_is_file(VALUE self) {
110
167
  return rb_iv_get(self, "@data_file");
111
168
  }
112
169
 
170
+ /*
171
+ * #version :
172
+ * returns the version of this class
173
+ */
113
174
  VALUE m_version(VALUE self) {
114
- char *version = "0.0.1";
175
+ char *version = "0.0.2";
115
176
  return rb_str_new2(version);
116
177
  }
117
178
 
179
+
180
+ /*
181
+ * Inits methods attached to this class
182
+ */
118
183
  void Init_raliasfile() {
119
184
  cRAliasFile = rb_define_class("RAliasFile", rb_cObject);
120
- rb_define_method(RAliasFile, "initialize", m_raliasfile_init, 1);
121
- rb_define_method(RAliasFile, "path_exists?", m_path_exists, 0);
122
- rb_define_method(RAliasFile, "is_alias_file?", m_alias_file, 0);
123
- rb_define_method(RAliasFile, "is_alias_broken?", m_alias_broken, 0);
124
- rb_define_method(RAliasFile, "alias_path=", m_set_alias_path, 1);
125
- rb_define_method(RAliasFile, "alias_path", m_alias_path, 0);
126
- rb_define_method(RAliasFile, "resolved_path", m_resolved_path, 0);
127
- rb_define_method(RAliasFile, "was_aliased?", m_was_aliased, 0);
128
- rb_define_method(RAliasFile, "is_folder_alias?", m_is_folder, 0);
129
- rb_define_method(RAliasFile, "is_file_alias?", m_is_file, 0);
130
- rb_define_method(RAliasFile, "version", m_version, 0);
185
+ rb_define_method(cRAliasFile, "initialize", m_raliasfile_init, 1);
186
+ rb_define_method(cRAliasFile, "path_exists?", m_path_exists, 0);
187
+ rb_define_method(cRAliasFile, "is_alias_file?", m_alias_file, 0);
188
+ rb_define_method(cRAliasFile, "is_alias_broken?", m_alias_broken, 0);
189
+ rb_define_method(cRAliasFile, "alias_path=", m_set_alias_path, 1);
190
+ rb_define_method(cRAliasFile, "alias_path", m_alias_path, 0);
191
+ rb_define_method(cRAliasFile, "resolved_path", m_resolved_path, 0);
192
+ rb_define_method(cRAliasFile, "was_aliased?", m_was_aliased, 0);
193
+ rb_define_method(cRAliasFile, "is_folder_alias?", m_is_folder, 0);
194
+ rb_define_method(cRAliasFile, "is_file_alias?", m_is_file, 0);
195
+ rb_define_singleton_method(cRAliasFile, "version", m_version, 0);
131
196
  }
data/raliasfile.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'rubygems'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = 'RAliasFile'
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2"
10
10
  # s.platform = Gem::Platform::RUBY::OSX
11
11
  # s.platform = Gem::Platform::OSX
12
12
  s.summary = "C ext to Ruby aimed to resolve alias file on Mac OS X 10.4+"
@@ -30,4 +30,28 @@ end
30
30
  if $0==__FILE__
31
31
  Gem.manage_gems
32
32
  Gem::Builder.new(spec).build
33
- end
33
+ end
34
+
35
+ =begin
36
+ .../raliasfile%> ruby raliasfile.gemspec
37
+ Successfully built RubyGem
38
+ Name: RAliasFile
39
+ Version: 0.0.1
40
+ File: RAliasFile-0.0.1.gem
41
+
42
+ .../raliasfile%> sudo gem install RAliasFile-0.0.1.gem
43
+ Password:
44
+ Building native extensions. This could take a while...
45
+ ruby extconf.rb install RAliasFile-0.0.1.gem
46
+ creating Makefile
47
+
48
+ make
49
+ gcc -fno-common -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I /System/Library/Frameworks/Carbon.framework/Headers -I /System/Library/Frameworks/CoreFoundation.framework/Headers -I /System/Library/Frameworks/CoreServices.framework/Headers -I /System/Library/Frameworks/Foundation.framework/Headers -I /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers -fnested-functions -I. -I/opt/local/lib/ruby/1.8/powerpc-darwin8.7.0 -I/opt/local/lib/ruby/1.8/powerpc-darwin8.7.0 -I. -O -pipe -I/opt/local/include -c raliasfile.c
50
+ cc -dynamic -bundle -undefined suppress -flat_namespace -L/opt/local/lib -framework CoreFoundation -framework Carbon -framework CoreServices -framework Foundation -L"/opt/local/lib" -o raliasfile.bundle raliasfile.o -lruby -lpthread -ldl -lobjc
51
+
52
+ make install
53
+ /usr/bin/install -c -m 0755 raliasfile.bundle /opt/local/lib/ruby/gems/1.8/gems/RAliasFile-0.0.1/lib
54
+
55
+ make clean
56
+ Successfully installed RAliasFile, version 0.0.1
57
+ =end
Binary file
@@ -34,16 +34,17 @@ to_alias.each {|a| `osascript make_alias.scpt "#{a}" "#{File.basename(a)}" "#{AL
34
34
 
35
35
  # array of sample pathes
36
36
  aliases=[]
37
- aliases << "#{ALS_DIR}/broken" # broken alias from target folder
38
- aliases << "#{ALS_DIR}/broken.txt" # broken alias from target file
39
- aliases << "#{ALS_DIR}/good" # good alias from target folder
40
- aliases << "#{ALS_DIR}/good.txt" # good alias from target file
41
- aliases << "#{ORG_DIR}/good" # wrong alias being a folder
42
- aliases << "#{ORG_DIR}/good.txt" # wrong alias being a file
43
- aliases << "#{ALS_DIR}/bid/good" # wrong path to alias being a folder
44
- aliases << "#{ALS_DIR}/bid/good.txt" # wrong path to alias being a file
37
+ aliases << "#{ALS_DIR}/broken" # broken given "alias" from target folder
38
+ aliases << "#{ALS_DIR}/broken.txt" # broken given "alias" from target file
39
+ aliases << "#{ALS_DIR}/good" # good given "alias" from target folder
40
+ aliases << "#{ALS_DIR}/good.txt" # good given "alias" from target file
41
+ aliases << "#{ORG_DIR}/good" # wrong given "alias" being a folder
42
+ aliases << "#{ORG_DIR}/good.txt" # wrong given "alias" being a file
43
+ aliases << "#{ALS_DIR}/bid/good" # wrong path to given "alias" being a folder
44
+ aliases << "#{ALS_DIR}/bid/good.txt" # wrong path to given "alias" being a file
45
45
 
46
46
  # "resolve" every sample pathes exploring all the methods
47
+ puts "RAliasFile.version="+RAliasFile.version.to_s
47
48
  aliases.each {|al|
48
49
  a=RAliasFile.new(al)
49
50
  puts "\n"
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: RAliasFile
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
6
+ version: 0.0.2
7
7
  date: 2006-08-30 00:00:00 +02:00
8
8
  summary: C ext to Ruby aimed to resolve alias file on Mac OS X 10.4+
9
9
  require_paths: