• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Virtual File System

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi can anyone help me how to create a virtual file system using java.
Its will reflect changes in operating system but it will behave like Virtual File System.

So far i been thinking to take a class File,Directory,Drive
The commands i want to validate are
1. cd
2. cd..
3. md
4. dir
5. exit

Thanks in advance
i have wasted my whole day in it.
where i'm stuck is to maintain path.
 
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we see your code? If your code is very lengthy, break out the section that you're having difficulty with into a small compilable piece of code and post that.
 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My File class is something like that



Directory class looks like this

Drive class looks like this

this is how VFS class looks like

this is how view class looks like


Now it's not completed obviously.
you can add whatever methods you like where you like.
but please help me out
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mandeepsangwan kumar wrote:
where i'm stuck is to maintain path.



No magic involved here. As with any program that needs to maintain its data, you need to keep the mappings of the virtual file system to the actual physical file system. And as to how the virtual system maps to multiple physical file systems, you will have to design that.

Henry
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be sure to make your "Directory" and "File" etc classes Serializable so that you can write the entire collection to disk and recover it safely.

Bill
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've added code tags to your post to make it easier to read. You should probably read this FAQ we have.
 
Carey Brown
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What command are you entering?
What output are you getting?
What output were you expecting?

Seems like you need a Directory constructor that takes a name and a reference to its parent. Use the constructor instead of 'createDirectory()' which results in uninitialized fields.

Just deal with one command for now. Is 'cd' change directory or create directory? You'll have to parse the entire command line. What is the structure you are entering for the command?
 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well what i want is it must look like
C:\md newFolder
and it creates a new directory

and when i do c:\cd newFoler
it goes to newFolder
 
Carey Brown
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mandeepsangwan kumar wrote:well what i want is it must look like
C:\md newFolder
and it creates a new directory

and when i do c:\cd newFoler
it goes to newFolder



So, I'd start with 'md' for now and ignore 'cd'. Is 'md' preceded by 'C:\' ? Or is that the prompt? What does 'newFolder' look like? Is it just a name or a full path? When you create a new directory, how do you tell it what the parent directory is? You don't seem to have the concept of 'current working directory', which you would need if 'md' is relative to where you are now.
 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is the same concept when you open your command prompt in windows
You create new folders with md
and cd to get into the folder
when you run the program then it will be like c:\
where c is the drive and we create directories and can move in or out from folder using cd and cd..
You see im not tring to reflect the changes in my computer drives but i just want to store into those classes
and tring to fake out this concept
Thanks
your faithfully
 
Carey Brown
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mandeepsangwan kumar wrote:it is the same concept when you open your command prompt in windows
You create new folders with md
and cd to get into the folder
when you run the program then it will be like c:\
where c is the drive and we create directories and can move in or out from folder using cd and cd..
You see im not tring to reflect the changes in my computer drives but i just want to store into those classes
and tring to fake out this concept
Thanks
your faithfully


Well, your 'md' command as you've posted it does nothing except call createDirectory; no name, no parent. You mentioned that 'C:\' is (most likely) your current working directory but the prompt and concept are missing from your code.
 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes my code is not complete
And i'm not sure how to do it
that's why i'm asking for help
 
Carey Brown
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mandeepsangwan kumar wrote:Yes my code is not complete
And i'm not sure how to do it
that's why i'm asking for help


Yes, you've stated that your code is not complete. I've pointed out a few deficiencies that I though you should address but I don't see any effort on your part to address them or to ask specific questions. We're not going to write the code for you.
 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i don't want you to write code for me
what i am looking for is that how i will manage parent child
A drive can have folder and so can a folder can have sub-folders
So there is a problem in managing directories .
How i will manage them using ArrayList
 
Carey Brown
Saloon Keeper
Posts: 10750
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mandeepsangwan kumar wrote:well i don't want you to write code for me
what i am looking for is that how i will manage parent child
A drive can have folder and so can a folder can have sub-folders
So there is a problem in managing directories .
How i will manage them using ArrayList


You already have a Directory that has zero or more subFolders, ok so far, but the Directory will need a field of type Directory that is the parent directory. When you create a new directory

Where 'parent' will probably be currentWorkingDirectory (until such time as your interface accepts paths).
Where parent is probably your currentWorkingDirectory.
Of course this means that you'll need a static field that is of type Directory called currentWorkingDirectory initialized to "" and also a currentWorkingDrive initialized to 'C'.
See what you can do with that and repost your code.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Stop Writing CODE!
2. Get a lot of paper or a nice big white board
3. Draw out use case or similar diagrams of the program flow so clearly that you can explain it to somebody else
...
Only then do you go back to coding using the diagrams to ensure that you take care of all possibilities

If you are not familiar with use cases, go read and absorb this wikipedia article.

Bill

 
mandeepsangwan kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i solved the problem on my own
Thanks for your conceren...
 
reply
    Bookmark Topic Watch Topic
  • New Topic