I want to design a file-system crawler for Linux and Windows OS in java. I am new to java and I am building an application that searches for matching files for a given file-name in the file-system. For Linux I have come up with the following strategy and my algorithm is as follows:-
- Open the root directory ("/") using the file open methods in java.
- Search in the current directory for the filename and record the path if search is successful for the file.
- Record the name of all directories in the current directory
- Visit each directory recursively and record the full path name if search is successful.
- After accessing the entire filesystem, list the results.
How do I search for a file, in a similar fashion, in the Windows file-system (NTFS)?. How do I find the root?
I know this may be a VERY inefficient method to scan for files or I may be going off track but please do suggest methods or post links where I can find useful information to accomplish my project. One such link that I found was the following one: https://docs.oracle.com/javase/tutorial/essential/io/walk.html
I wanted to know if implementing the FileVisitorInterface is correct and efficient or some other ways exist to do what I intend to. I am a newbie in java hence I don't know where to start and where to look. Many thanks in advance for all your answers!