Create object of Linux file system
I would like to create an object which mirrors a Linux file system. Doesn't need to be very complicated, doesn't need file permissions, etc, but just lists the files with KB size and directors under each directory. I then will want to be able to add/delete/rename files and directories in the object.
I was thinking of something like that listed below. Problem with this approach is it doesn't prevent duplicate file names or directory names under a given directory (really not a huge deal). Also, it is somewhat convoluted to select a given directory (some sort of loop through each directory to see if a sub-directory exists, and then inspect that directory).
So, then I thought maybe I should make each folder a property so that duplicates are not possible and selecting a directory is as easy as folder1.dir2.dir22. Problem is one cannot create a directory called "files" as it will conflict with the files array.
Hopefully, what I am attempting to communicate makes sense! Any suggestions on how best to proceed?
What commands is it supposed to obey? "cd" and "ls" I assume, but what else? "mkdir" or "rmdir"? "mv"? And how is it to be populated to begin with? Your described object is probably sufficient to do what you want it to do as a data structure, the essential problem is writing methods/functions for the mother object.
I would also include two other objects as a property of the main object in which the properties would consist (A first object) KEY directory name--VALUE parent directory name and (B) KEY directory name --VALUE reference to the object which has that directory name.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)