{"id":98075,"date":"2018-02-22T07:00:00","date_gmt":"2018-02-22T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=98075"},"modified":"2019-03-13T01:01:28","modified_gmt":"2019-03-13T08:01:28","slug":"20180222-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180222-00\/?p=98075","title":{"rendered":"Why does IsPathRelative return FALSE for paths that are drive-relative?"},"content":{"rendered":"<p>MSDN distinguishes between <a HREF=\"https:\/\/msdn.microsoft.com\/en-us\/library\/aa365247(VS.85).aspx#fully_qualified_vs._relative_paths\">fully-qualified and relative paths<\/a>. According to that discussion: <\/p>\n<blockquote CLASS=\"q\">\n<p>A file name is relative to the current directory if it does not begin with one of the following: <\/p>\n<ul>\n<li>A UNC name,<\/li>\n<li>A disk designator with a backslash,<\/li>\n<li>A single backslash, for example,     &#8220;\\directory&#8221; or &#8220;\\file.txt&#8221;.     This is also referred to as an <i>absolute path<\/i>.<\/li>\n<\/ul>\n<p>If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter. <\/p>\n<p>A path is also said to be relative if it contains &#8220;double-dots&#8221;; that is, two periods together in one component of the path. <\/p>\n<p>Relative paths can combine both example types, for example &#8220;C:..\\tmp.txt&#8221;. <\/p>\n<\/blockquote>\n<p>Okay, so what exactly is the definition of a relative path? <\/p>\n<p>It&#8217;s sort of like art. You know it when you see it. <\/p>\n<p>There are some things that are clearly absolute paths. These are known as fully-qualified paths. They specify both a volume designator and a path relative to the root of that volume. <\/p>\n<p>There are also some things that are clearly relative paths, like <code>dir\\file.txt<\/code>. <\/p>\n<p>And then there are these weird intermediate cases that everybody understands but nobody really knows how to classify like <code>C:..\\dir\\file.txt<\/code>. <\/p>\n<p>Here&#8217;s a table of possibilities. <\/p>\n<table CLASS=\"cp3\" CELLPADDING=\"3\" CELLSPACING=\"0\" BORDER=\"1\" STYLE=\"border-collapse: collapse\">\n<tr>\n<th>Example<\/th>\n<th>Classification<\/th>\n<th>IsPathRelative?<\/th>\n<\/tr>\n<tr>\n<td><code>\\\\Server\\Share\\Dir\\File.txt<\/code><\/td>\n<td>UNC absolute<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><code>C:\\Dir\\File.txt<\/code><\/td>\n<td>Drive absolute<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><code>C:Dir\\File.txt<\/code><\/td>\n<td>Drive relative<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><code>\\Dir\\File.txt<\/code><\/td>\n<td>Rooted<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><code>Dir\\File.txt<\/code><\/td>\n<td>Relative<\/td>\n<td>Yes<\/td>\n<\/tr>\n<\/table>\n<p>The first two rows and the last row are not controversial. The third and fourth rows, on the other hand, are problematic. They live in this shadowy world, half-absolute and half-relative. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s complicated.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-98075","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It&#8217;s complicated.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/98075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=98075"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/98075\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=98075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=98075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=98075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}