Path


C# Data structures Strings Public

Hard  

30min


Write a function that provides change directory (cd) function for an abstract file system.

Notes:

  • Root path is '/'.
  • Path separator is '/'.
  • Parent directory is addressable as "..".
  • Directory names consist only of English alphabet letters (A-Z and a-z).
  • The function will not be passed any invalid paths.
  • Do not use built-in path-related functions.

For example:

Path path = new Path("/a/b/c/d");
path.Cd("../x");
Console.WriteLine(path.CurrentPath);

should display '/a/b/c/x'.

C# 7.0, .NET Framework 4.7
   

  •   Example case: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Selecting child directories: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Selecting parent directories: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14
  •   Selecting complex paths: System.NotImplementedException at Path.Cd(String newPath) in Path.cs:line 14