Thread: Array of files

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    67

    Array of files

    How can I fill an array with files?

  2. #2
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: Array of files

    Originally posted by TeQno
    How can I fill an array with files?
    File names or file contents?

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    67

    Angry

    a file which encapsulates lets say 3 files

    MyFile([file1][file2][file3])
    Last edited by TeQno; 07-08-2003 at 02:31 AM.

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    First you say an array of files, then you say a file encapsulating many files. What EXACTLY do you want?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    67
    an array of files... an array not filled with characters but with files.
    so it encapsulates a few files....

    i dont know if its possible or how im just curious

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Do you mean something like this?

    Code:
    FARRAY fArray[5]; //short for filearray
    
    LoadFileIntoArray(&fArray,0,"filename.ext");
    LoadFileIntoArray(&fArray,1,"filename2.ext");
    //etc...
    //then later...
    
    int dispFile(const FARRAY fArray,int nIndex)
    {
    cout << (char *)(fArray[nIndex].data);
    return 0;
    }
    That sort of thing would allow you to load every byte from a file into a large BYTE array, (hopefully) allocated somewhere other than the local stack, then access that data as you please.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    What are you trying to do? There should be no need to store the entire contents of multiple files in some huge multi-dimensional array.

    Please be a bit more descriptive.

  8. #8
    Registered User
    Join Date
    May 2003
    Posts
    67

    thanx for the replies

    well think of winzip or the likes, isnt a zip file an array of files?
    (or am i totally off here.. if I am please say so )

  9. #9
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Without any compression, I could think of an easy way to do this. Create a structure for a file that will include a header, and x number of data blocks. The header should include the details of each file contained in the overall file, including the offset, length, filename, etcetera. You can then use whatever file ouputing technique you want. Eg: (file contents)

    Code:
    [HEADER]
    ["blah.dll",120,2500]
    ["readme.txt",2621,360]
    [/HEADER]
    blah.dll contents output right here, at offset 120
    readme.txt contents output here, at offset 2621
    Something like that should suffice.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Zip files are much more than just an array of files. There is quite a lot of information in a zip file. For more information on its structure and possibly how to code an unzip function, go to www.wotsit.org

  11. #11
    Registered User
    Join Date
    May 2003
    Posts
    67
    yes i know its quite more then an array of files.. i was just giving an example..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modify an single passed array element
    By swgh in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 08:58 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  5. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM