Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Paths *referenced from

Similar presentations


Presentation on theme: "File Paths *referenced from"— Presentation transcript:

1 File Paths *referenced from http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/ And http://docs.oracle.com/javase/tutorial/essential/io/path.htmlhttp://docs.oracle.com/javase/tutorial/essential/io/path.html

2 What Is a Path? A file system stores and organizes files on some form of media, generally one or more hard drives, in such a way that they can be easily retrieved. Most file systems in use today store the files in a tree (or hierarchical) structure. At the top of the tree is one (or more) root nodes. Under the root node, there are files and directories (folders in Microsoft Windows). Each directory can contain files and subdirectories, which in turn can contain files and subdirectories, and so on, potentially to an almost limitless depth.

3 What Is a Path? The following figure shows a sample directory tree containing a single root node. Microsoft Windows supports multiple root nodes. Each root node maps to a volume, such as C:\ or D:\. The Solaris OS supports a single root node, which is denoted by the slash character,

4 A file is identified by its path through the file system, beginning from the root node. For example, the statusReport file in the previous figure is described by the following notation in the Solaris OS: /home/user2/statusReport In Microsoft Windows, statusReport is described by the following notation: C:\home\user2\statusReport

5 The character used to separate the directory names (also called the delimiter) is specific to the file system: The Solaris OS and Unix systems (most web servers use Unix) uses the forward slash (/), and Microsoft Windows uses the backslash slash (\).

6 Relative or Absolute? A path is either relative or absolute. An absolute path always contains the root element and the complete directory list required to locate the file. For example,/home/user2/statusReport is an absolute path. All of the information needed to locate the file is contained in the path string.

7 A relative path needs to be combined with another path in order to access a file. For example, user1/foo is a relative path. Without more information, a program cannot reliably locate the user1/foo directory in the file system. Relative paths use../ to move up the directory tree

8 Exercises Use the following directory tree to answer the questions in this section:

9 What is the root? D: What is the absolute path to Base? D:\Data\Final\Base What is the absolute path to Infrastructure? D:\Data\Final\Infrastructure What information is needed prior to constructing a relative path to these two files? directory tree relationship position Assume a file in Posters needs to reference Base. What would be its relative path?../Date/Final/Base Assume the file is now in Base. What is the relative path to Infrastructure? /Infrastructure

10 Use the following image of a directory tree to answer the questions on the following slides:

11 What is the root? life What is the absolute path to german_shepard.jpg? Life\animals\dogs\large\german_sgeepard.jpg dog_gallery.html needs to reference kitty.jpg. Write down the absolute and relative paths that could be used? Life\animals\cats\long_haired\kitty.jpg../cats/long_haired/kitty.jpg Why should we never use absolute paths? Microsoft Windows uses the backslash slash (\). dog_gallery.html needs to reference labrador_retriever.jpg. Write down the absolute and relative paths. medium/ labrador_retriever.jpg

12 IMPORTANT Place this powerpoint with all completed questions/answers in your myWork folder under Unit 1 When you have been taught how to create links you will be responsible for creating a link to this pptx and uploading it your class website Don’t forget…your website will be marked at the end of each unit (unless otherwise stated) for completeness, design and functionality A total of 10 APP marks will be assigned each time


Download ppt "File Paths *referenced from"

Similar presentations


Ads by Google