/* ============================================================================
# Create
# name : Andre Rikkert de Koe date: apr 2011
# descr : filefind
# This is a demo of programming in the java language.
# Its part of a project to implement a program to create a directory
# tree similar to the output of the Unix find program.
# EUID : Any user who has read access to all the files being searched for.
# run : interactive
#
# Changes
# name : date:
# descr : short description
#
# ========================================================================== */
import java.io.*;
import java.util.*;
public class filefind
{
{
System.
out.
println("Usage: " + progname +
" directory");
}
static boolean issymlink
(File file1
)
{
boolean result;
try
{
result = !file1.getAbsolutePath().equals(file1.getCanonicalPath());
}
{
System.
err.
println("Caught IOException: " + ie.
getMessage());
result = false;
}
return result;
}
public filefind
(String filename
)
{
base =
new File(filename
);
}
static void start_traverse
(File base
)
{
try
{
System.
out.
println(base.
getCanonicalPath());
}
{
System.
err.
println("Caught IOException: " + ie.
getMessage());
}
traverse(base);
}
static void traverse
(File b
)
{
File [] subs = b.
listFiles();
for(int i = 0; i < subs.length; i++)
{
if (subs[i].isDirectory() && !issymlink(subs[i]))
{
traverse(subs[i]);
}
else
{
}
}
}
/* ============================================================================
# MAIN
# ========================================================================== */
public static void main
(String [] args
)
{
if (args.length == 1)
{
basename = args[0];
if (base.isDirectory())
{
start_traverse(base);
}
else
{
Usage(progname, "ERROR: No directory " + basename + " found");
}
}
else
Usage(progname, "ERROR: 1 argument expected");
}
}