Thread: how to save a directory and file tree

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    2

    how to save a directory and file tree

    i have made a linked list of the following type which contains directories and files info:
    Code:
    struct DIR
    {
    filename // file or directory name
    fileID // file or dir ID
    ParentID// parent dir's ID
    // other info crucial to saving
    }
    my question is how to save files and directories such that a complete tree is saved?
    Please give me some guidelines. I'll be thankfull.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Well, to store a tree, your data structure must be capable of reproducing that tree format. To do so, your DIR struct will likely need to store a pointer to another DIR struct representing the subtrees. You are probably already using such a setup for the linked-list correct? Now we are simply talking about adding another such pointer.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    yes the next pointer is already there, which I forgot to mention. what I need is an algo to save the tree.

    Code:
    struct DIR
    {
         filename // file or directory name
         fileID // file or dir ID
         ParentID// parent dir's ID
         // other info crucial to saving
         DIR* next;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM