[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[MacOS X] finding the orig file of an alias

pere.noel

8/3/2006 1:39:00 AM


for the time being i'm using the finder thru AppleScript and then aeosa
in order to find the original path of an alias.

that's time consuming ))

does exist a direct rubyish way to do that (as in perl for ex.) ?
--
une bévue
14 Answers

Logan Capaldo

8/3/2006 1:48:00 AM

0


On Aug 2, 2006, at 9:40 PM, Une bévue wrote:

>
> for the time being i'm using the finder thru AppleScript and then
> aeosa
> in order to find the original path of an alias.
>
> that's time consuming ))
>
> does exist a direct rubyish way to do that (as in perl for ex.) ?
> --
> une bévue
>

You might be able to use RubyCocoa to do it a little more directly.

Dave Howell

8/3/2006 10:00:00 PM

0


On Aug 3, 2006, at 0:53, Yvon Thoraval wrote:

> from ruby side.
>
> if writing :
>
> fm=OSX::NSFileManager.defaultManager
>
> i get :
>
> NameError: uninitialized constant OSX::NSFileManager
>

That's odd. I got this:

irb(main):002:0> require 'osx/aeosa'
=> true
irb(main):003:0> require 'osx/cocoa'
=> true
irb(main):004:0> fm=OSX::NSFileManager.defaultManager
=> #<OSX::NSFileManager:0x2fc3e0 class='NSFileManager' id=0x434470>
irb(main):005:0>

Did you require 'osx/cocoa'?



Dave Howell

8/3/2006 10:10:00 PM

0


On Aug 3, 2006, at 0:53, Yvon Thoraval wrote:

> first, how to get the constant : "kCFURLPOSIXPathStyle" ? (I've put
> 0...)
> second how to call the method "CFURLCreateWithFileSystemPath" ?

Oh, yea, I forgot to mention that the fastest place to find answers to
these questions would be on the rubycocoa-talk mailing list....



pere.noel

8/3/2006 10:51:00 PM

0

Dave Howell <groups+2006@howell.seattle.wa.us> wrote:

>
> Oh, yea, I forgot to mention that the fastest place to find answers to
> these questions would be on the rubycocoa-talk mailing list....

they have a tendancy, fo such a question, to direct me by Cocoa-Dev ))
--
une bévue

pere.noel

8/3/2006 10:53:00 PM

0

Dave Howell <groups+2006@howell.seattle.wa.us> wrote:

> irb(main):004:0> fm=OSX::NSFileManager.defaultManager
> => #<OSX::NSFileManager:0x2fc3e0 class='NSFileManager' id=0x434470>
> irb(main):005:0>

ok thanx

> Did you require 'osx/cocoa'?

generally speaking yes, both of them (rubycocoa and aeosa).

but in a small trying script i might have forgot this "small detail" )))
--
une bévue

pere.noel

8/3/2006 11:17:00 PM

0

Dave Howell <groups+2006@howell.seattle.wa.us> wrote:

> Did you require 'osx/cocoa'?

not at all, i'm sure about that ))

because, when :
require 'osx/cocoa'

i get an error within my text editor (TextMate) or at terminal :

LoadError: no such file to load -- rubycocoa
method gem_original_require
in custom_require.rb at line 27
method require
in custom_require.rb at line 27
at top level
in cocoa.rb at line 11
method require
in custom_require.rb at line 27
at top level
in read-alias.rb at line 5

when using "require 'osx/cocoa'" within XCode : no prob...
--
une bévue

Dave Howell

8/4/2006 7:12:00 AM

0


On Aug 3, 2006, at 16:20, Une bévue wrote:

> Dave Howell <groups+2006@howell.seattle.wa.us> wrote:
>
>> Did you require 'osx/cocoa'?
>
> not at all, i'm sure about that ))
>
> because, when :
> require 'osx/cocoa'
>
> i get an error within my text editor (TextMate) or at terminal :
>
> LoadError: no such file to load -- rubycocoa

> when using "require 'osx/cocoa'" within XCode : no prob...

Hmm. I suspect if you hunt around in ~/Library/Frameworks or
/Library/Frameworks, you'll find the RubyCocoa framework. Which is to
say, nowhere on your command-line path directories, but exactly where
Cocoa apps expect to find such things.

Based on the misery I've experienced in this situation, were I you, I
would now try to wipe every last trace of RubyCocoa off my system, then
do a new install in order to get *one* copy of RubyCocoa that's visible
to all the different ways you can run Ruby.

If you don't wipe it first, then you can easily get in a situation
where the command line is running a *different* version of RubyCocoa
than XCode, and that's hideous to debug.

Trust me on that one.


Dave Howell

8/4/2006 7:54:00 AM

0


On Aug 4, 2006, at 0:36, Yvon Thoraval wrote:
> i've tried several times having the same setup for ruby from command
> line and from XCode, and i've learned today darwinports isn't the
> best...
>
> what kind of install would you advice ?
>
> from cvs sources ?
>
> PS : on RubyCocoa list they advice me to use dp )))

Yes, people are always telling me about the lovely powers of
Darwinports/Fink/CVS/Gem and on and on. I don't believe them any more,
though. (Well, RubyGems has worked reasonably well for those things
that are available as gems.)

My current RubyCocoa (and Ruby 1.8.4) was installed by downloading a
tar.gz file or some such thing, and running
./configure
make
make install

Whatever that's called. Is that the best way? I have no idea. But it
did let me put things exactly where I wanted them, which for me, meant
that all my Ruby junk is in the highly visible /Library/Ruby, not in
/usr/local/whatever or /sw/someplace or /opt/secret/hiding/spot.
(Although I did get to discover that some part of the RubyCocoa
installer couldn't cope with installing from a path with spaces in it.
That's been fixed.)

And it seems to work, which is more than I can say for 66% of my
attempted Fink installs and 100% of my DarwinPorts attempts. I haven't
tried any CVS-ing yet, because I'm allergic to unripe software in
general.


Phillip Hutchings

8/4/2006 8:12:00 AM

0

I can't help you with calling the CF functions, the rubycocoa list
might know more

> i seems that "OSX::NSFileManager.defaultManager" couldn't do the
> trick...

Unfortunately Cocoa can't actually handle aliases itself, you need to
use other functions. Google for 'Cocoa alias resolve', there's a few
informative pages.

--
Phillip Hutchings
http://www.sit...

pere.noel

8/4/2006 10:41:00 AM

0

Phillip Hutchings <sitharus@sitharus.com> wrote:

>
> Unfortunately Cocoa can't actually handle aliases itself, you need to
> use other functions. Google for 'Cocoa alias resolve', there's a few
> informative pages.

fine thanx, i've found something by googleing...

this is at <http://bdistributed.com/Projects/BD...

they have implemented a class following Apple's rcomandation :
<http://developer.apple.com/documentation/Cocoa/Conceptual/Low...
gmt/Tasks/ResolvingAliases.html>

(that's the BDAlias#fullPath method calling #fullPathRelativeToPath:nil)

here is my little test :

require 'osx/cocoa'

OSX.ns_import('BDAlias')
f=OSX::BDAlias.alloc.initWithPath("/Users/yvon/work/RubyCocoa/MacSOUPSwi
tcher/map/read-alias/search/for/the/original/file/read-alias.pl")
p "f.class=#{f.class}"
# => "f.class=OSX::BDAlias"
p "f.fullPath=#{f.fullPath}"
# =>
"f.fullPath=/Users/yvon/work/RubyCocoa/MacSOUPSwitcher/map/read-alias/se
arch/for/the/original/file/read-alias.pl"

using BDAlias from ruby works very well however the return path isn't
the path of the file pointed by the alias rather the path of the alias
itself )))

i've compared ObjC version of BDAlias versus Apple's recomandation :
looks good...

then, i don't understand why this desapointing result...

something i misunderstood ???
--
une bévue