// HDir.java
//
// You may use and distribute this example. This program is 
// provided WITHOUT WARRANTY either expressed or implied.
//
// Copyright Henrik Björkman 1998
//
//
//
// History:
// 0.0 Created by Henrik Björkman 1998-02-28 
//     (using code from H4Replace.java)
//


import java.io.*;



public class HDir
{

  static void error(String str)
  {
    System.err.println("HDir: " + str);
  }

  static void debug(String str)
  {
    //error(str);
  }

  static void print(String str)
  {
    System.out.println(str);
  }

  static void show_file(String name,int depth)
  {
    File f;
    //try 
    {
      f=new File(name);
      if (f.isDirectory())
      { 
        int i;
        String[] n;
        print(name+'/');
        n=f.list();
        for (i=0;i<n.length;i++)
        {
          show_file(name+"/"+n[i],depth+1);
        }
      }
      else if (f.isFile())
      {
        print(name);
      }
      else
      {
        print(name+" ?");
      }
    }
    //catch (IOException e) {error(""+e);}
  }

  static void show_file(String name)
  {
    show_file(name,0);
  }

  public static void main(String args[]) 
  {
    debug("begin");

    if (args.length < 1 )
    {
      System.out.println("Usage: java HDir <name>");
      System.exit(0);
    }

    show_file(args[0]);

    debug("end");
  }
}


