Topic 2.7

Paths

Absolute/Relative Paths

In this topic we'll be discussing absolute and relative paths and their differences. While this may seem superfluous to those of you who are computer-savvy, brushing up on this topic couldn't hurt.

Absolute Paths

An absolute, or full, path begins with a drive letter followed by a colon, such as C:.

Relative Paths

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

Using the example directory structure below, assume you used Windows Explorer to navigate to E:\PortableApps\AffinityPhotoPortable\App. After navigating to this directory, a relative path will use E:\PortableApps\AffinityPhotoPortable\App as the current directory (until you navigate to a new directory, at which point the new directory becomes the current directory). The current directory is sometimes referred to as the root directory.

E:\
  - Documents\
  + PortableApps\
    + AffinityPhotoPortable\
      + App\
        - AppInfo\
        - AffinityPhoto\
        - DefaultData\
      - Data\
      + Other\
        + Help\
          - Images\
        - Source\

If you wanted to navigate to the Data directory from the current directory (App), you could type the following in the Windows Explorer Address box:

..\Data

Windows Explorer would then navigate to E:\PortableApps\AffinityPhotoPortable\Data. A few more examples using E:\PortableApps\AffinityPhotoPortable\Data as the current directory are below:

..               = E:\PortableApps\AffinityPhotoPortable
..\..            = E:\PortableApps
..\..\Documents  = E:\PortableApps\Documents
.                = E:\PortableApps\AffinityPhoto\Data (CWD or Current Working Directory)
.\..\Other       = E:\PortableApps\AffinityPhoto\Other
A relative path cannot span disk drives. For example, if your current working directory was on drive E, you cannot use relative paths to navigate to any directory that was on the C drive.
Why relative over absolute paths?

As far as absolute paths are concerned:

  • You can move a document or a PAF directory anywhere on your computer and the data will be found when you reopen the document or PAF.
  • On most personal computers, the location of data is usually constant. That is, you typically don't move your data around much on your personal computer. In such cases, absolute paths are preferred.
  • You can reference data on other disk drives.

Using relative paths, these adjustments are necessary:

  • When moving DefaultData to Data, you must also move the files within those folders and retain the structure therein.
  • When packaging a well-developed PAF, using the aforementioned directory structure from AffinityPhotoPortable. The structure must remain intact regardless if AffinityPhotoPortable was launched from E:\PortableApps\AffinityPhotoPortable or launched from E:\AffinityPhotoProtable and so on.
UNC Paths

UNC stands for Universal (or Uniform or Unified) Naming Convention and is a syntax for accessing files and folders on a network of computers. The syntax is as follows:

\\<computer name>\<shared folder>\

This can be followed by any number of directories and terminated with a directory or file name.

For example:

\\demondevin\public\file.ext

The computer name is always preceded by a double backward slash (\\).

In UNC, the computer name is also known as the host name.

A few rules for UNC paths:

  • UNC paths cannot contain a drive letter (such as E:).
  • You cannot navigate to directories above the shared directory.

How UNC pertains to PAL is the ability to keep folder structure even when launched from a network folder. There's not much you may do as far as using it in PAL but you can make sure that it really does support UNC paths correctly. Some apps (or their portability wrapper) may corrupt data when not specially designed to cope with UNC paths, because of this the launcher is set by default on warning the user that the application may not work correctly and given a chance to exit. More about UNC Paths and PA.c Platform can be find here.