図に示すような階層構造をもつファイルシステムにおいて,*印のディレクトリ(カレントディレクトリ)から“..¥..¥DIRB¥Fn.txt”で指定したときに参照されるファイルはどれか。ここで,図中の□はディレクトリ名を表し,ファイルの指定方法は次のとおりである。 〔指定方法〕 (1) ファイルは“ディレクトリ名¥…¥ディレクトリ名¥ファイル名”のように,経路上のディレクトリを順に“¥”で区切って並べた後に“¥”とファイル名を指定する。 (2) カレントディレクトリは“.”で表す。 (3) 1階層上のディレクトリは“..”で表す。 (4) 始まりが“¥”のときは,左端のルートディレクトリが省略されているものとする。 ・ルート → 子は DIRB(上)と DIRA(下)の 2 つ。 ・上の DIRB → 子は 3 つ: - 上: DIRA → DIRB(このノードに * 印。① Fn.txt を持つ) - 中: ② Fn.txt(この DIRB 直下のファイル) - 下: DIRB → 子は 2 つ: - 上: DIRB(③ Fn.txt を持つ) - 下: ④ Fn.txt(この DIRB 直下のファイル)
平成28年度 秋期 ITパスポート試験 問75
This question's explanation and your answers so far.
問 75
Incorrectア
① Fn.txt is a file held by the current directory (the DIRB marked *) itself. To reference it, “Fn.txt” (or “.¥Fn.txt”) would suffice, which does not match this question's specification that goes up 2 levels with “..”.
Incorrectイ
② Fn.txt is a file directly under the upper DIRB, two levels up. “..¥..” does reach this upper DIRB, but the specification then descends into a child directory with “DIRB”, so the target is not ② directly under DIRB but the file reached via the child DIRB.
Incorrectウ
③ Fn.txt is a file inside DIRB, which is a further child of the lower DIRB. To reach it, you would need to follow DIRB twice, as in “..¥..¥DIRB¥DIRB¥Fn.txt”; since this specification has DIRB only once, it stops directly under the lower DIRB (at ④).
- エ
正解 The current directory (marked *) is the innermost DIRB reached by following Root → upper DIRB → DIRA → DIRB (it holds ① Fn.txt). Resolve the specified path “..¥..¥DIRB¥Fn.txt” from left to right. First, “..” moves one level up (to the parent DIRA); the next “..” moves one more level up (back to the upper DIRB, directly under the root). This upper DIRB has three children: DIRA, ② Fn.txt, and another DIRB, and “DIRB” refers to this lower DIRB. The final “Fn.txt” is the file directly under that lower DIRB, namely ④ Fn.txt. Therefore the file referenced is ④, and the correct answer is エ.
- In relative path specification, “..” denotes one level up (the parent directory) and “.” denotes the current directory. Starting from the current directory, you go up to a parent with “..” and descend into a child by directory name, tracing the path segment by segment.
- In a hierarchy that contains multiple directories with the same name (DIRB), the key is to correctly identify which DIRB at which level is meant, based on the parent-child relationships.