Skip to content

平成21年度 春期 ITパスポート試験 問57

This question's explanation and your answers so far.

問57
頻出度★☆☆

あるファイルシステムの一部が図のようなディレクトリ構造であるとき,*印のディレクトリ(カレントディレクトリ)D3から矢印が示すディレクトリD4の配下のファイルaを指定するものはどれか。ここで,ファイルの指定は,次の方法によるものとする。 〔指定方法〕 (1) ファイルは,“ディレクトリ名¥…¥ディレクトリ名¥ファイル名”のように,経路上のディレクトリを順に“¥”で区切って並べた後に“¥”とファイル名を指定する。 (2) カレントディレクトリは“.”で表す。 (3) 1階層上のディレクトリは“..”で表す。 (4) 始まりが“¥”のときは,左端にルートディレクトリが省略されているものとする。 (5) 始まりが“¥”,“.”,“..”のいずれでもないときは,左端にカレントディレクトリ配下であることを示す“.¥”が省略されているものとする。

D1
├─ D2
│   ├─ →D4
│   └─ D5
└─ D3 *(カレントディレクトリ)

(注:*印はカレントディレクトリD3を,矢印(→)は指定先のディレクトリD4を示す。)

出典 平成21年度 春期 ITパスポート試験 問57
解説

問 57

  • Incorrectア

    This option is “..¥..¥D2¥D4¥a”, with “..” appearing twice in a row. By method (3), the first “..” moves up from D3 to D1, but the second “..” moves up one more level, pointing to a parent of D1 that does not exist in the figure. From there you cannot go down to D2, so you never reach the target file a, and the option is wrong. Going up only one level is enough.

  • イ

    正解 The correct answer is イ. First, fix the parent-child relationships in the figure. D1 is at the top; directly under it are D2 and D3, and directly under D2 are D4 and D5. In other words, D3 (the current directory) and D2 are siblings whose common parent is D1, and the target D4 is a child of D2. So the route from D3 to file a under D4 is: go up one level to D1 → go down to D2 → go down to D4 → a. Applying the specification method: going up one level is written as “..” by method (3); after that, the directory names along the path are listed in order separated by “¥” according to method (1), and finally “¥” plus the file name a is added, giving “..¥D2¥D4¥a”. Because this begins with “..”, the “.¥” completion of method (5) does not apply, and it is interpreted exactly as written: a relative specification starting one level above the current directory. Therefore イ is correct.

  • Incorrectウ

    “D1¥D2¥D4¥a” begins with none of “¥”, “.”, or “..”, so by method (5) the “.¥” is regarded as omitted at the left end, and it actually means “.¥D1¥D2¥D4¥a”, that is, D1 lies under the current directory D3. But in the figure D1 is the parent of D3, not its child, so this is wrong. To follow the path absolutely from the root, method (4) requires a leading “¥”, writing “¥D1¥D2¥D4¥a”.

  • Incorrectエ

    “D2¥D4¥a” likewise begins with none of “¥”, “.”, or “..”, so by method (5) it means “.¥D2¥D4¥a”, that is, D2 lies under the current directory D3. In the figure, however, D2 is not a child of D3 but its sibling (both are children of D1), so this is wrong. It is the form that is missing the “..” for going up one level; adding “..¥” to it gives the correct answer イ.

ここがポイント
  • Apply the basic symbols of relative specification mechanically: “.” = the current directory, “..” = the directory one level up. If it begins with “¥” it is an absolute specification from the root; if it begins with none of “¥”, “.”, or “..”, it is treated as a relative specification with “.¥” omitted at the left end (that is, under the current directory). The key is to read strictly by the rules given in the question text.
  • Fix the parent-child relationships in the figure first, then assemble the path. Here D3 and D2 are siblings (both children of D1) and D4 is a child of D2, so the route from D3 to D4 is: go up exactly one level, then go down to D2 → D4. If you get the number of upward moves wrong, you end up pointing at a level that does not exist.
用語

Your answers