Skip to content

平成31年度 春期 ITパスポート試験 問96

This question's explanation and your answers so far.

問96
頻出度★☆☆

Web サーバ上において, 図のようにディレクトリ d1 及び d2 が配置されているとき, ディレクトリ d1 (カレントディレクトリ) にある Web ページファイル f1.html の中から, 別のディレクトリ d2 にある Web ページファイル f2.html の参照を指定する記述はどれか。ここで, ファイルの指定方法は次のとおりである。 〔指定方法〕 (1) ファイルは, “ディレクトリ名/…/ディレクトリ名/ファイル名” のように, 経路上のディレクトリを順に “/” で区切って並べた後に “/” とファイル名を指定する。 (2) カレントディレクトリは “.” で表す。 (3) 1 階層上のディレクトリは “..” で表す。 (4) 始まりが “/” のときは, 左端のルートディレクトリが省略されているものとする。

          ルート
         /      \
        d1       d2
        |        |
     f1.html  f2.html
出典 平成31年度 春期 ITパスポート試験 問96
解説

問 96

  • Incorrectア

    “.” represents the current directory d1, so this means f2.html inside d2 inside d1, i.e. d1/d2/f2.html. But d2 is not a child of d1; it is a sibling located directly under the root, so this path does not exist and is incorrect.

  • Incorrectイ

    “./f2.html” points to f2.html located directly under the current directory d1. But what is under d1 is f1.html, while f2.html is under d2, so this specification does not reach the target file and is incorrect.

  • ウ

    正解 As shown in the figure, directly under the root, d1 and d2 sit side by side as sibling directories, and f2.html is inside d2. The current directory is d1, so to move from there to d2 you must first go back up to their common parent, the root. By specification method (3), the directory one level up is written as “..”, so you first go up to the root with “..”, then enter “d2”, and finally specify “f2.html”. Joining these with “/” gives “../d2/f2.html”, which is the correct reference, so choice ウ is the right answer.

  • Incorrectエ

    Because it starts with “d2”, it looks for d2 inside the current directory d1 (i.e. d1/d2/../f2.html), but d1 has no child named d2. Moreover, “d2/..” ultimately just returns to the original d1, so it effectively points to d1/f2.html; either way it cannot reach f2.html in d2, and is incorrect.

ここがポイント
  • Relative path notation: the current directory is written as “.” and the parent directory one level up as “..”. To move to a sibling directory, first go back to the common parent with “..”, then enter the target directory.
  • Reading the tree structure: d1 and d2 are siblings directly under the root, and neither is a child of the other. Correctly grasping this from the figure is the key to solving the problem.
用語

Your answers