• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to traverse directory recursevely and to create soft-link !!!  RSS feed

 
Mac Dawson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi all,
I am developing a simple command line app which will search for multiples copies of a file in provided directory and will replace the copies by creating a softlinks and deletes the duplicate file.
i am doing this by recursively traveling every directory provided and matching the files in subdirectories.


the worst part is that when i use GNU compiler (gcj) the code is working properly i.e it is traversing every sub-directory properly, but when i am using sun's 'javac 1.6.0_26' the program is skipping many subdirectories.
now i m using Process , Runtime classes and getRuntime() method to execute "ln -s" linux command to create soft link and passing trgt and sftlnk as argument , this too is not working ( not working on both compiler)
then i used java 1.7.0 through which i was able to create soft-link but again the program is skipping many subdirectories , therefore many files are also skipped.



please have a look on the code :- ( javac 1.6.0_26)



code for javac 1.7.0 :-

i

please point out my mistakes ... thanks in advance
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mac, and welcome to the Ranch!

My first suggestion is to use code tags. I've added them to your post to make it easier to read. My second suggestion is to post less code. A lot of times, people who could answer your question get put off by seeing 100s of lines of code and just go on to the next question.

In this case, I assume you're running into trouble with recursiveTraversal(), but I don't see anything obviously wrong with it. I'd try breaking that code out and maybe using it to print out a tree structure of your folder. The subdirectories it's missing ... are they always the same ones? What distinguishes those from the ones it does find? If that doesn't make the problem pop out for you, at least you'd have more targeted information to bring back here.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!