擅长:python、mysql、java
<p>文件来源:</p>
<blockquote>
<p>Return True if pathname path is a mount <strong>point</strong></p>
</blockquote>
<p>强调我的。装载指向目录的子目录位于装载驱动器上,但不是装载“点”。在</p>
<blockquote>
<p>how can I correctly determine that 'bar' is a subdirectory of an externally mounted file system?</p>
</blockquote>
<p>在这种情况下,我会迭代到一个根,或者到达一个点。先到者为准。在</p>
<p>假设是Unix类型的文件系统:</p>
<pre><code>def is_on_mount(path):
while True:
if path == os.path.dirname(path):
# we've hit the root dir
return False
elif os.path.ismount(path):
return True
path = os.path.dirname(path)
path = '/mount/one/two/three'
is_on_mount(path)
</code></pre>