Relative Paths './' and '../'

  • -->gm<--
  • Student
  • Student
  • User avatar
  • Joined: Mar 19, 2004
  • Posts: 68
  • Status: Offline

Post May 7th, 2008, 12:48 pm

Hi everyone,

When using relative? paths does anyone know the difference between './' and '../' ?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 7th, 2008, 12:48 pm

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post May 7th, 2008, 12:50 pm

. refers to the directory you're currently in
.. refers to the directory above the one you're currently in
The Beer Monocle. Classy.
  • -->gm<--
  • Student
  • Student
  • User avatar
  • Joined: Mar 19, 2004
  • Posts: 68
  • Status: Offline

Post May 7th, 2008, 1:14 pm

Thanks Spork,

Say in this example there isn't any difference between them?

If the webpage is in the root and the images are in an 'image' directory in the root.

Code: [ Select ]
<img src="images/icon_link.png" alt="" width="22" height="22" />
and
<img src="./images/icon_link.png" alt="" width="22" height="22" />
  1. <img src="images/icon_link.png" alt="" width="22" height="22" />
  2. and
  3. <img src="./images/icon_link.png" alt="" width="22" height="22" />


Why would you bother using './'?, for include files or something?

Thanks
  • -->gm<--
  • Student
  • Student
  • User avatar
  • Joined: Mar 19, 2004
  • Posts: 68
  • Status: Offline

Post May 8th, 2008, 3:19 am

I can't find a good use for './' in included files either?
Can anyone enlighten me as to when they would use './' ?
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post May 8th, 2008, 4:16 am

Maybe just an operating system relic from before there were browsers ?
Strong with this one, the sudo is.
  • -->gm<--
  • Student
  • Student
  • User avatar
  • Joined: Mar 19, 2004
  • Posts: 68
  • Status: Offline

Post May 8th, 2008, 5:50 am

Maybe, I don't really see a use for it..
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post May 8th, 2008, 6:55 pm

In older shells for UNIX/Linux systems, the dot was sometimes required in order to execute a script in the current directory. It really has no use in modern shells and is virtually unnecessary in URLs.
The Beer Monocle. Classy.
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post May 8th, 2008, 8:13 pm

-->gm<-- wrote:
Maybe, I don't really see a use for it..

I doub't you need to worry about that thing anymore. It's gotten more modern now :D
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Joined: Mar 12, 2007
  • Posts: 6228
  • Loc: South-Africa
  • Status: Offline

Post May 8th, 2008, 10:54 pm

I still use that sometimes with my .net apps actually ... very rarely though ... something like
Code: [ Select ]
Server.MapPath("./")

gives me the current directory on my host ... so if I want to create folders on my root I'll use it like
Code: [ Select ]
Server.MapPath("./" & FolderName)
Let's leave all our *plum* where it is and go live in the jungle ...

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 94 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.