Jump to content
  • Advertisement
Sign in to follow this  
clinical

Simulate a file directory

This topic is 3547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all (long time reader, first time poster ;) ) Basically, I'm developing a game on hacking and want to simulate a file directory that the player will see and search for particular files - a little like Uplink. But I'm not sure how best to do this, I'm thinking along the lines of using external files holding the file structure and coding a search through these to give the impression of connecting to a remote site and viewing the directories. But is is best to use xml/plain text/some other format? I know that you can do a DOS command (tree > file.txt) to print a file directory and it looks like it could be useful, but basically wondered if anyone has done something similar and which is the best method to use. Any pointers, muchly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
There's no shortage of ways to do this, but using XML files with a DOM-compliant parser such as TinyXML will involve very little overhead while (as a side benefit) teaching you about XML/DOM stuff. The nice thing about DOM is that it already uses a tree structure to represent the document, which is nearly ideal for the sort of stuff you're looking for.

Share this post


Link to post
Share on other sites
Do you mean simulated directory structure (something entirely in the context of the game), or
a display of a real directory / .zip file somewhere on their computer that you want to let them browse in a safe simulated environment?

Share this post


Link to post
Share on other sites
Yeah, sorry if that wasn't clear, I wanted a simulated directory enclosed in the program - entirely in the context of the game. I think it could get a bit dodgy letting players access real files!

Share this post


Link to post
Share on other sites
Well, OOP is your friend, as in


class Permissions {}

class File {
Permissions permissions; // permissions for this file
};

class Directory {
Permissions permissions; // permissions for this directory
vector <Directory> subDirectories;
vector <File> files;
};



Of course you could collapse all 3 classes into one class and name it Inode or something. Just have a look at wikipedia on filesystems and be inspired [smile]

Ah, btw, for serialisation, you could usee boost. Though it won't actually be that hard with c++ filefunctions, especially because this is a self contained recursive structure.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!