Skip to content

平成24年度 秋期 ITパスポート試験 問63

This question's explanation and your answers so far.

問63
頻出度★☆☆

図に示す階層構造で,複数個の同名のディレクトリ A,B が配置されており,ユーザ ID ごとにログインしたときのカレントディレクトリが異なる。U0002 がログインした直後に,矢印が示すディレクトリ B に存在するファイル f を指定するものはどれか。ここで,ファイルの指定方法とユーザ ID 別のカレントディレクトリは次のとおりである。 〔ファイルの指定方法〕 (1) “ディレクトリ名¥ … ¥ディレクトリ名¥ファイル名”のように,経路上のディレクトリを順に“¥”で区切って並べた後に“¥”とファイル名を指定する。 (2) カレントディレクトリは“.”で表す。 (3) 1階層上のディレクトリは“..”で表す。 (4) 始まりが“¥”のときは,左端のルートディレクトリが省略されているものとする。 〔ユーザ ID 別カレントディレクトリ〕

ユーザ IDログイン時のカレントディレクトリ
U0001¥A¥B
U0002¥A¥B¥A

(図:ルートの下に A と B が配置されている。A の下に A と B が配置され,その B の下にさらに A と B が配置されている。ルート直下の B の下には A と B が配置されている。矢印はルート直下の B を指している。)

出典 平成24年度 秋期 ITパスポート試験 問63
解説

問 63

  • Incorrectア

    “.” refers to the current directory itself (¥A¥B¥A), so this option means ¥A¥B¥A¥B¥f. In the figure no child directory is drawn under ¥A¥B¥A, and in any case that is a different location from the B indicated by the arrow (the one directly below the root). Since there is not a single “..” for going up, no level is climbed at all.

  • Incorrectイ

    A single “..” goes up only one level, so you can get back only as far as ¥A¥B; this option means ¥A¥B¥B¥f. There is indeed a B under ¥A¥B in the figure, but it is the B inside the B under A, not the B directly below the root that the arrow indicates. Even with the same name, a different position means a different directory.

  • Incorrectウ

    “..¥..” goes up two levels and arrives at ¥A, so this option means ¥A¥B¥f. That ¥A¥B is the current directory of U0001 at login, and it is not the B directly below the root that the arrow indicates. One more “..” is needed to climb all the way back to the root.

  • エ

    正解 The current directory of U0002 right after login is ¥A¥B¥A, which is three levels below the root. The target file f, however, is in the “B directly below the root” indicated by the arrow. In a relative specification, “..” means one level up, so from ¥A¥B¥A one “..” goes back to ¥A¥B, a second “..” goes to ¥A, and a third “..” reaches the root. That is, “..¥..¥..” climbs back to the root, and from there “¥B¥f” specifies the B directly below the root and the file f inside it. Therefore エ, “..¥..¥..¥B¥f”, is the correct answer. The key point is that directories with the same names A and B appear at various places in the hierarchy, so they must be distinguished not by name but by their position (path) from the root.

ここがポイント
  • In a relative path that starts from the current directory, “.” means the current position and “..” means one level up. When the destination lies toward the root, repeat “..” as many times as the depth of the current directory to climb back to the common parent (here, the root), and then go down from there.
  • In a hierarchy where several directories share the same name, the directory name alone does not identify a location uniquely. First confirm the position by its path from the root (the absolute path), and then convert it into a relative path when reasoning about the answer.
用語

Your answers