{"id":3226,"date":"2020-10-29T16:28:48","date_gmt":"2020-10-29T08:28:48","guid":{"rendered":"https:\/\/www.aoisnow.net\/blog\/?p=3226"},"modified":"2020-10-29T16:28:48","modified_gmt":"2020-10-29T08:28:48","slug":"tont-33243-%e4%b8%ba%e4%bb%80%e4%b9%88%ef%bc%88%e6%9c%89%e6%97%b6%ef%bc%89unc%e8%b7%af%e5%be%84%e7%9a%84%e5%bc%80%e5%a4%b4%e5%85%81%e8%ae%b8%e6%9c%89%e7%9b%98%e7%ac%a6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.aoisnow.net\/blog\/archives\/3226","title":{"rendered":"TONT 33243 \u4e3a\u4ec0\u4e48\uff08\u6709\u65f6\uff09UNC\u8def\u5f84\u7684\u5f00\u5934\u5141\u8bb8\u6709\u76d8\u7b26\uff1f"},"content":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20051122-15\/?p=33243\" target=\"_blank\" rel=\"noopener\">https:\/\/devblogs.microsoft.com\/oldnewthing\/20051122-15\/?p=33243<\/a><\/p>\n<p>A little-known quirk is that the file system accepts and ignores a drive letter in front of a UNC path. For example, if you have a directory called \\\\server\\share\\directory, you can say<\/p>\n<p>\u6709\u4e2a\u9c9c\u4e3a\u4eba\u77e5\u7684\u5947\u602a\u8bbe\u8ba1\u662f\uff0c\u6587\u4ef6\u7cfb\u7edf\u63a5\u53d7\uff08\u5e76\u4f1a\u5ffd\u7565\uff09UNC \u8def\u5f84\u7684\u5f00\u5934\u5305\u542b\u76d8\u7b26\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6709\u4e2a\u76ee\u5f55\uff08\u7684\u5171\u4eab\u8def\u5f84\uff09\u662f\\\\server\\share\\directory\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165<\/p>\n<blockquote><p>dir P:\\\\server\\share\\directory<\/p><\/blockquote>\n<p>and the directory will be listed to the screen. The leading P: is ignored.<\/p>\n<p>\u76ee\u5f55\u5185\u5bb9\u4f1a\u6210\u529f\u5217\u51fa\uff0c\u5f00\u5934\u7684 P: \u88ab\u5ffd\u7565\u4e86\u3002<\/p>\n<p>Why is that?<\/p>\n<p>\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>Rewind to 1984 and the upcoming release of MS-DOS 3.1, which added networking support. Up to this point, all fully-qualified file specifications consisted of three components: A drive letter, a path, and a file name. Many programs relied on this breakdown and did things like \u201chelpfully\u201d prepend a drive letter if it looks like you \u201cforgot\u201d one. For example, if you told it to save the results to \\\\server\\share\\file.txt it would say, \u201cOh dear, that\u2019s not good, the user forgot the drive letter! I\u2019ll put the current drive in front to make things better,\u201d resulting in C:\\\\server\\share\\file.txt. Other programs would prompt you with \u201cPlease enter a drive letter\u201d, and you couldn\u2019t say \u201cNo, there\u2019s no drive letter, just take the path and use it.\u201d They insisted on a drive letter, and you darn sure better give them one.<\/p>\n<p>\u56de\u5230 1984 \u5e74\uff0cMS-DOS 3.1 \u5373\u5c06\u53d1\u5e03\uff0c\u8be5\u7248\u672c\u65b0\u589e\u4e86\u7f51\u7edc\u652f\u6301\u3002\u5230\u8fd9\u65f6\u4e3a\u6b62\uff0c\u6240\u6709\u5b8c\u5168\u9650\u5b9a\u7684\u6587\u4ef6\u89c4\u8303\u5305\u542b\u4e09\u4e2a\u7ec4\u6210\u90e8\u5206\uff1a\u76d8\u7b26\u3001\u8def\u5f84\u548c\u6587\u4ef6\u540d\u3002\u5f88\u591a\u5e94\u7528\u7a0b\u5e8f\u90fd\u4f9d\u8d56\u8fd9\u79cd\u7ec4\u5408\u65b9\u5f0f\uff0c\u5e76\u4e14\u5982\u679c\u8def\u5f84\u770b\u4e0a\u53bb\u662f\u7528\u6237\u300e\u5fd8\u4e86\u300f\u5f55\u5165\u76d8\u7b26\u7684\u8bdd\uff0c\u8fd8\u4f1a\u5728\u6700\u524d\u9762\u300e\u5e2e\u5fd9\u300f\u52a0\u4e0a\u4e00\u4e2a\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7528\u6237\u6307\u5b9a\u5c06\u6570\u636e\u4fdd\u5b58\u5230 \\\\server\\share\\file.txt\uff0c\u7a0b\u5e8f\u5c31\u4f1a\u8ba4\u4e3a\uff1a\u300e\u54ce\u5440\uff0c\u8fd9\u600e\u4e48\u884c\uff0c\u7528\u6237\u5fd8\u4e86\u5199\u76d8\u7b26\u4e86\uff01\u8ba9\u6211\u5728\u6700\u524d\u9762\u52a0\u4e0a\u5f53\u524d\u9a71\u52a8\u5668\u7684\u76d8\u7b26\uff0c\u8fd9\u6837\u5c31\u597d\u4e86\u300f\uff0c\u8def\u5f84\u5c31\u53d8\u6210\u4e86 C:\\\\server\\share\\file.txt\u3002\u53e6\u5916\u4e5f\u6709\u7a0b\u5e8f\u4f1a\u63d0\u793a\u7528\u6237\u300e\u8bf7\u8f93\u5165\u76d8\u7b26\u300f\uff0c\u800c\u7528\u6237\u65e0\u6cd5\u544a\u8bc9\u7a0b\u5e8f\u300e\u4e0d\u4e0d\uff0c\u8fd9\u4e2a\u8def\u5f84\u91cc\u6ca1\u6709\u76d8\u7b26\uff0c\u76f4\u63a5\u7528\u8fd9\u4e2a\u8def\u5f84\u5c31\u884c\u4e86\u300f\u3002\u7a0b\u5e8f\u662f\u4e00\u5b9a\u8981\u4e00\u4e2a\u76d8\u7b26\u7684\uff0c\u800c\u7528\u6237\u4e0d\u7ed9\u662f\u4e0d\u884c\u7684\u3002<\/p>\n<p>(Compare the Unix programs that \u201chelpfully\u201d rewrite \/\/server\/volume\/file as \/server\/volume\/file because they \u201cknow\u201d that consecutive slashes collapse, unaware of the special exception for two leading slashes.)<\/p>\n<p>\uff08\u76f8\u8f83\u4e4b\u4e0b\uff0cUNIX \u7a0b\u5e8f\u5219\u4f1a\u300e\u5e2e\u5fd9\u300f\u5c06 \/\/server\/volume\/file \u91cd\u5199\u4e3a \/server\/volume\/file\uff0c\u56e0\u4e3a\u4ed6\u4eec\u300e\u77e5\u9053\u300f\u8fde\u7eed\u659c\u7ebf\u5e94\u5f53\u8fdb\u884c\u5408\u5e76\uff0c\u4f46\u5374\u4e0d\u77e5\u9053\u4e24\u9053\u659c\u7ebf\u5f00\u5934\u662f\u4e2a\u4f8b\u5916\u3002\uff09<\/p>\n<p>In order to retain compatibility with programs that provided this sort of \u201cunwanted help\u201d, the designers of the networking support in MS-DOS decided to allow the strange syntax C:\\\\server\\share\\directory and treat it as if the drive letter simply weren\u2019t there. Some (but not all) of this quirk of path parsing persists today.<\/p>\n<p>\u4e3a\u4e86\u4fdd\u6301\u4e0e\u63d0\u4f9b\u8fd9\u79cd\u300e\u6beb\u65e0\u5fc5\u8981\u7684\u5e2e\u52a9\u300f\u7684\u7a0b\u5e8f\u7684\u517c\u5bb9\u6027\uff0cMS-DOS \u7f51\u8def\u652f\u6301\u529f\u80fd\u7684\u8bbe\u8ba1\u8005\u4eec\u51b3\u5b9a\u5141\u8bb8 C:\\\\server\\share\\directory \u8fd9\u79cd\u5947\u602a\u8bed\u6cd5\u7684\u5b58\u5728\uff0c\u5e76\u5c06\u5176\u89c6\u4e3a\u5f00\u5934\u7684\u76d8\u7b26<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/devblogs.microsoft.com\/oldnewthing\/2005112 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3226","post","type-post","status-publish","format-standard","hentry","category-tont_history"],"_links":{"self":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/comments?post=3226"}],"version-history":[{"count":0,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/posts\/3226\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/media?parent=3226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/categories?post=3226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aoisnow.net\/blog\/wp-json\/wp\/v2\/tags?post=3226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}