[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: File, relative path handling.

Warren Brown

9/8/2003 5:00:00 PM

Hugh,

> Has anyone come up with a method for converting
> an absolute filesystem path into a relative
> path, given the path to relate to?

Well, this doesn't handle Windows drive letters, but it handles the
rest:

# Convert the given absolute path into a path
# relative to the second given absolute path.
def relativepath(abspath,relativeto)
path = abspath.split(File::SEPARATOR)
rel = relativeto.split(File::SEPARATOR)
while (path.length > 0) && (path.first == rel.first)
path.shift
rel.shift
end
('..' + File::SEPARATOR) * (rel.length - 1) + path.join(File::SEPARATOR)
end

I hope this helps.

- Warren Brown


5 Answers

Sean O'Dell

9/8/2003 6:36:00 PM

0

Warren Brown wrote:

> Hugh,
>
>
>>Has anyone come up with a method for converting
>>an absolute filesystem path into a relative
>>path, given the path to relate to?
>
>
> Well, this doesn''t handle Windows drive letters, but it handles the
> rest:
>
> # Convert the given absolute path into a path
> # relative to the second given absolute path.
> def relativepath(abspath,relativeto)
> path = abspath.split(File::SEPARATOR)
> rel = relativeto.split(File::SEPARATOR)
> while (path.length > 0) && (path.first == rel.first)
> path.shift
> rel.shift
> end
> (''..'' + File::SEPARATOR) * (rel.length - 1) + path.join(File::SEPARATOR)
> end

Your relative path routine is MUCH more efficient than mine, geez. I
still don''t "think" with everything Ruby has to offer. I''m still too
much of a "got-no-libs" C/C++ person. =)

Sean O''Dell

Robert Klemme

9/9/2003 8:03:00 AM

0


I suggest to put that on the Wiki - if it''s not already there.

robert

"Warren Brown" <wkb@airmail.net> schrieb im Newsbeitrag
news:002001c3762a$36d81260$803888cf@warrenpc...
> Hugh,
>
> > Has anyone come up with a method for converting
> > an absolute filesystem path into a relative
> > path, given the path to relate to?
>
> Well, this doesn''t handle Windows drive letters, but it handles the
> rest:
>
> # Convert the given absolute path into a path
> # relative to the second given absolute path.
> def relativepath(abspath,relativeto)
> path = abspath.split(File::SEPARATOR)
> rel = relativeto.split(File::SEPARATOR)
> while (path.length > 0) && (path.first == rel.first)
> path.shift
> rel.shift
> end
> (''..'' + File::SEPARATOR) * (rel.length - 1) +
path.join(File::SEPARATOR)
> end
>
> I hope this helps.
>
> - Warren Brown
>
>

Hugh Sasse

9/9/2003 10:22:00 AM

0

Mark Rae

5/18/2007 12:11:00 PM

0

"Eir??kur Fannar Torfason" <Eir??kur Fannar
Torfason@discussions.microsoft.com> wrote in message
news:2398F061-01BF-4E49-A99D-F7C4F279C798@microsoft.com...

> One of the reasons is that its more secure.

In what way(s) is Windows authentication more secure than SQL Server
authentication...?


--
http://www.m...

Eiríkur Fannar Torfason

5/18/2007 3:31:00 PM

0

I expect you'll correct me if I'm wrong, but it's my understanding that with
SQL server authentication, the credentials are sent over the network for each
connection attempt as opposed to a token when windows authentication is used.
It's also my understanding that the password is encrypted using a very weak
encryption algorithm, at least with SQL server 2000 which is the version that
the majority of our customers are running. But I'll happily listen to anyone
with expert knowledge on SQL Server security. In fact, that's exactly what we
did when we made our original decision. We listened to a very helpful,
intelligent man from Microsoft Consulting Services who told us that from a
security point of view, windows authentication was the way to go.

None of this however has anything to do with my original post.

"Mark Rae" wrote:

> "Eiríkur Fannar Torfason" <Eiríkur Fannar
> Torfason@discussions.microsoft.com> wrote in message
> news:2398F061-01BF-4E49-A99D-F7C4F279C798@microsoft.com...
>
> > One of the reasons is that its more secure.
>
> In what way(s) is Windows authentication more secure than SQL Server
> authentication...?
>
>
> --
> http://www.m...
>
>