The address for this web page is:   http://fishcaro.crosswinds.net/day_17_pathnames_nse.htm
On to the next lesson!
Back to the COURSE SYLLABUS

17. PATHNAMES

You have already encountered several instances where you need to specify LOCATION information:

In both instances, the location information is given by the URL (Uniform Resource Locator). In order to write correct URLs, you must understand how directory structures work. This is today's topic.

INDEX CARD #17:

DIRECTORIES (17a)

What is a DIRECTORY? A directory is a "place" to store stuff. It's organized like an upside-down tree: it starts with the roots; branches come out of the roots; each branch may have other branches coming from it; and so on. (Refer to the diagram below this index card.) Because of the tree analogy, the top-most directory is called the ROOT; it is written as a forward slash (/).
A directory can contain other directories (called subdirectories), and files.
What is a PATHNAME? Are there different types of pathnames? A pathname is the notation used to point to a particular file or directory. There are two types of pathnames: absolute and relative.
Here's an example to help explain the difference. Someone calls you on the telephone, and asks for directions to Carol's house (who lives next door). You give a long list of directions (absolute pathname). Now, someone knocks on your front door and asks you how to get to Carol's house (she's popular today). All you need to say is: "She lives right next door." (relative pathname)
Directions that are given FROM THE ROOT are called "absolute."
Directions that are given FROM WHERE YOU CURRENTLY ARE are called "relative."

ABSOLUTE vs. RELATIVE PATHNAMES (17b)

What is an ABSOLUTE PATHNAME? An absolute pathname is a set of instructions that starts at the root. Absolute pathnames are easy to recognize: they always begin with the forward slash (/). For example, the absolute pathname

/SCHOOL/HTML/web_course.htm
is interpreted like this:
-- start at the root (this is indicated by the forward slash)
-- choose the folder labeled "SCHOOL"
-- choose the subfolder labeled "HTML"
-- choose the file labeled "web_course.htm"
What is a RELATIVE PATHNAME? A relative pathname gives directions from the current working directory. When building a web site, relative pathnames are usually used, because the files you need are usually close by.
If a pathname doesn't begin with a forward slash, then it's assumed to be a relative pathname.
To go UP a level from where you are, use two dots (periods) in the pathname: ".."
To get from CALCULUS to web_course.htm, you'd use this relative pathname:
../HTML/web_course.htm

Printable version of Index Card 17a

Printable version of Index Card 17b

WORKSHEET #17: Make sure you can do the following:

Here are a couple practice problems. (Don't click on the solution until you've tried each yourself!)

ASSIGNMENT #17:

On to the next lesson!
Back to the COURSE SYLLABUS
© 2000 Carol J.V. Fisher    All Rights Reserved