path
的最後一個字元為 '\'
的這個特殊狀況。path
的最後一個字元為 '\'
時,第 17 行的 while
迴圈條件不成立,而停止對 name
的操作。在執行完第 22 ~ 33 行的程式後,第 7 行的最外層 while
迴圈的條件仍然成立 (因為此時 i
的值為path.size() - 1
)。所以仍會進入第 8 ~ 10 行的 while
迴圈,使得 i
的值更新為 path.size()
。那麼緊接著第 8 行的 while
迴圈條件失敗後,第 11 行的 if
條件成立,並執行第 13 行的 break
,然後離開第 7 ~ 34 行的整個 while
迴圈。
is the length of path
.
is the length of path
.
is the depth of the filesystem.