"Fully-qualified path" is synonymous with "absolute path"
- "Fully-qualified" and "absolute path" mean the same thing - a path that is not relative to an implied or specified context.
- Every path is either a fully-qualified path or else it is a relative path
- Every location on a file system has a multitude of paths that could be used to refer to it, including numerous fully-qualified paths:
- C:\temp.txt
- C:\Program Files\..\temp.txt
- C:\Program Files\Microsoft\..\..\temp.txt
- etc.
- Conceptually speaking, one of those fully-qualified paths is the simplest, most straightforward way of specifying that resource - that's your canonical path.
For a file or directory, does fully-qulified path exist only one thing? -like canonical path.
No, a fully-qualified path is any path which is not a relative path (not relative to the current directory of the implied or specified context). Multiple, but distinct, fully-qualified paths could refer to the same location on the filesystem. Reread:
but substitute "fully-qualified" everywhere it says "absolute".
To be clear, some people will also use the term "relative path" to also refer to a path with a "relative reference" (double dots
..
) within it. For example, some might might called C:\Program Files\Microsoft\\..\temp.txt
a "relative path" because of the double dots, but I would call it an fully-qualified path with a relative reference. Hopefully, it will be clear from the conversation what they mean when they say "relative path" (a path that is relative to a context or a path with a relative reference in it).Are both of them totally same concepts?
No, as indicated in the other SO question, there are lots ways to specify a fully-qualified path (absolute path) to a location, but only one of those fully-qualified paths is considered to be the canonical path to that location.
One more thing, Is a UNC path belong to fully-qualified path too?
Yes, UNC paths are not relative paths; they are fully-qualified paths. - http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx#fully_qualified_vs._relative_paths
Is a symbolic link or a hard link belong to Fully qualified path?
Its an independent concept. A path (regardless of whether it is relative or full-qualified) leads to a location in the filesystem. The entity at that location could be one of many things: a normal file, a directory, a symbolic link, a hard link, a device, a named pipe, etc. A symbolic links or a hard link has meta-data that leads to the data you were actually looking for at that location.
Analogy Time
You can think of paths and links in the terms of directions to someone's house:
- a relative path is directions from your current location
- a fully-qualified path is directions from town-hall, regardless of where you are
- In our strange little town of Unixville, everyone agrees and understands implicitly that "fully-qualified directions" always start at town-hall, strangely enough, a buidling that everyone calls "
/
". - The next town over (Windowsville) has multiple town halls (one for each part of town), called
C:\
,D:\
,E:\
, etc. - Different people might give you different directions (paths) to get to the same house, even if they all start from the same starting point (townhall) - some directions will be more direct than others.
- In our strange little town of Unixville, everyone agrees and understands implicitly that "fully-qualified directions" always start at town-hall, strangely enough, a buidling that everyone calls "
- a canonical path is the fully-qualified directions that is the simplest, most straightforward means to get from townhall to the desired house
- a symbolic link is like a empty lot with a note that gives directions to a forwarding address
- the type of directions that led you here (whether they were relative directions, fully-qualified directions, or even the canonical fully-qualified directions) has no bearing on whether it leads to a house or any empty lot with forwarding direction here
- there's a strange case where one of the streets in your direction is actually a symbolic link (a detour? a portal?) - the analogy falls apart here if we look too closely at it, so lets just ignore it :-)
- a hard link is a house accessible from two or more different addresses.
- Think of a house on the corner of Elm Street and Main Street. The post office mistakenly gave it two addresses :
10 Elm Str
and20 Main Str
. No matter which address you go to, you end up at the same house. - In our strange little town, these hard-link houses can have multiple addresses and the addresses don't have to be anywhere near each other.
- No matter which of its addresses you go to, its the same house. Its not a copy, its not a forwarding address. Just magically, once you go inside, you end up in the same house, regardless of which address you used to get there.
- the directions that led you to the house (no matter which address was used or whether the directions were relative directions, fully-qualified directions, or even the canonical fully-qualified directions) has no bearing on whether the house at that address is a hard-link house or not
- Think of a house on the corner of Elm Street and Main Street. The post office mistakenly gave it two addresses :
Addendum
EditI asked someone who maintains Naming Files, Paths, and Namespaces page to let me know this. And he replied me.Is this also Fully-qualified path? C:\directory..\directory\file.txt
I wonder what terms the maintainer of that page would use to differentiate between
..\file.txt
andC:\directory\..\directory\file.txt
since he calls them both relative path. I agree that double dots are a relative reference, but I wouldn't tag the whole path as relative because it has double dots in the middle of it. In his terminology, there doesn't seem to be a difference between fully-qualified and canonical. (Therein, I suppose, lies the source of your question).
I come from a Unix and Java background, so perhaps that makes the difference. As I learned it:
- relative/partially-qualified - location cannot be determined without the associated context providing information, e.g. the current working directory, the current drive, the drive's current directory, the shell PATH setting, the Java CLASSPATH setting, or the referencing URL.
- absolute/fully-qualified - location is independent of the the associated context, i.e. the location is the same regardless of the current working directory, the current drive, the drive's current directory, the shell PATH setting, the Java CLASSPATH setting, or the referencing URL.
- canonical - the simplest fully-qualified, i.e. no double-dots
So
- ..\file.txt - relative
- C:\directory\..\directory\file.txt - fully-qualified
- C:\directory\file.txt - fully-qualified and canonical
That section of the MSDN page isn't clear on
C:\directory\..\directory\file.txt
: IfC:\directory\..\directory\file.txt
is considered relative and won't work with Windows API that say they need a fully-qualified (but not necessarily canonical?) path, I'd suggest that page needs to make that clearer.Fully-qualfied vs RelativeA file name is relative to the current directory if it does not begin with one of the following:... * A disk designator with a backslash, for example "C:\" or "d:\". ...
Since
C:\directory\..\directory\file.txt
starts with a disk designator with a blackslash, this path is fully-qualified, not relative.A path is also said to be relative if it contains "double-dots"; that is, two periods together in one component of the path. This special specifier is used to denote the directory above the current directory, otherwise known as the "parent directory". Examples of this format are as follows:
- "..\tmp.txt" specifies a file named tmp.txt located in the parent of the current directory.
- "....\tmp.txt" specifies a file that is two directories above the current directory.
- "..\tempdir\tmp.txt" specifies a file named tmp.txt located in a directory named tempdir that is a peer directory to the current directory.
I interpreted the phrase contains double dots to mean leading double dots. The examples show only leading double dots. The terminology "current directory" usually means process's current working directory or the drive's current directory, which has bearing only when talking about leading double dots. I can, however, see how the section could be interpreted the other way.
Regardless, everyone grows up different and context is king, so I guess everyone will need to be careful of the nuances when reading docs or discussing with engineers of different backgrounds on what they mean by "fully-qualified" vs "relative"
No comments:
Post a Comment