• Post Reply Bookmark Topic Watch Topic
  • New Topic

Identifying Mapped vs Root File System  RSS feed

 
Bill Schmitt
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working up a small java app as part of the learning process and have developed some small bits of code to tell me about the drives on my machine using File ListRoots and ListFiles. However, I also have several mapped drives on my Windows XP machine, which also show up. I'd like to exclude them for my exercise, but I can't find a way to programatically see that they are not local. Is there a way to identify these attributes?

Thanks
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Bill.

And a good question to start with. I think there is no way to distinguish between a mapped drive and a physical drive when you make use of File.listRoots()
Perhaps a more experienced coder can point you to a solution ..

Meanwhile make sure you wrap your head around Java's naming conventions: 'ListRoots' as you wrote it, seems to refer to a class, while you meant the method listRoots() that is part of the java.io.File API.

Cheers,
Wim
 
Bill Schmitt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup! Intellectually, I knew the different naming conventions, but it is not yet natural to me. We'll get there.

I appreciate the quick response, too. I'm sure there's more information about roots or devices out there, so if anyone can point me to it, I'd appreciate it.

Essentially, I'm attempting to duplicate things I've already done in other languages to get a good handle here. I've worked with most stuff at one time or another (actually wrote my first code in COBOL and FORTRAN on punched cards, if you can believe it, and could still probably scare my way through JCL) but never dove deep into Java. It's time.

Bill
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punched cards ... I like how you come out of the closet so quickly

The response times are pretty high. I've been here for a month or two and I never saw a question remain unanswered for very long. Cudos to the various members and specificly the moderators for that. Probably someone will know about a different API that will allow you to make that distinction between mapped and physical.

Good luck with your learning process!
Wim
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome again

I tried googling and got this thread first, then the File class listRoots method. Not sure we are getting much farther, I am afraid.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have moved this discussion because I think it too difficult for us who are "beginning" Java™.
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you've already seen that the File class is the way Java uses to interact with files in the underlying operating system. I assume you've already combed through the API documentation for that class and come up empty?

Anyway, Java isn't the kind of language where it's a big lumber yard and you might find three or four completely different ways to do something. Not like some languages I could mention. So if you were hoping for some other API in a different part of Java which answers your question, chances are there isn't one.
 
Bill Schmitt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I did find a library on google code with a HelperIO class that included isNetworkDrive(). Added the library but it apparently has some requirements that are clearly beyond my debugging skills at the moment.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you can use FileSystemView, especially the isXXX methods and getSystemTypeDescription.
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill Schmitt wrote:Actually wrote my first code in COBOL and FORTRAN on punched cards,

There are a few of us here who started on an 029 or even 026. I've still got my McCracken Guide to Fortran Programming ( (no IV, etc.) book on my technical shelf.

Interesting question. Since Java works very hard to be platform independent, and even the concept of mapped directories are vendor specific, I'm not sure that there is a pure-Java way to do it. I could be wrong, but I've been slinging Java for over a decade, and for problems like this, I either write in C and use JNI, or use the System.exec hack. (you can spawn a native OS shell and execute any legal command in it).

 
Bill Schmitt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember the 029's. I also remember learning the hard way (like everyone else) why it was important to put sequence numbers on the cards!

I appreciate the answer. It's coming together as I proceed.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!