extra info returned from dir command

2 ビュー (過去 30 日間)
Leonardo Wayne
Leonardo Wayne 2016 年 3 月 18 日
回答済み: Walter Roberson 2016 年 3 月 18 日
I have the following command: MyFolderInfo = dir('H:\Motor Testing');
But it returns a struct as shown in the attached image file. I only have one folder called "motor number 1" inside the folder name: Motor Testing, but I get also these "." and ".." with a creation date. What are these dot and dot dot?
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 18 日
No image was included.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 3 月 18 日
For various reasons it turns out to be convenient for each directory to have an entry that refers to itself (named "."), and another entry that refers to its parent (named ".."). These are used for working with relative paths. So if you write
movefile('./abc/def.png', '../images')
then the relative paths ./abc/def.png and ../images are not simply handled by the parser to mean "relative to my current directory" and "relative to the parent of my current directory". They do have those meanings, but they are not handled by the parser: the file system itself has a "." and ".." entry that can be used to say where you will end up, without you needing to know where you already are.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by