how to save a directory and file tree

This is a discussion on how to save a directory and file tree within the C++ Programming forums, part of the General Programming Boards category; i have made a linked list of the following type which contains directories and files info: Code: struct DIR { ...

  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,675
    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.
    I used to be an adventurer like you... then I took an arrow to the knee.

  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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21