Thread: gcount() question ?

  1. #1
    Registered User
    Join Date
    Apr 2008
    Location
    Australia
    Posts
    55

    gcount() question ?

    EDIT: move along, nothing to see here....haha....erm, sorry. After I posted this, realised I may of been passing the wrong variable . Hence my confusion :/. Don't need help with this now. Thanks for looking.


    hi,
    I have a reference book that states that gcount() returns the actual number of characters read.
    I am wondering how does this work with compressed files? I ask because I am getting mixed results with some code I have for compressed files (no problem with non-compressed files).


    Snippet code
    Code:
    //For compressed files
    if((iUserDisplayNum<FileCount)&&(abCompressed[iUserDisplayNum] == 1)) //1 for compressed
    {
      int filesize = aiDecompressedSize[iUserDisplayNum]; //contains decompressed size info
      char *read_filedata_array = new char[filesize];
    
      filepos = (FileLoc[iUserDisplayNum].Location)+4; //file position
      File.seekp(filepos);
      File.seekg(filepos);
      File.read(read_filedata_array,filesize); //read-in data at location n
    
      cout<<"filesize: "<<filesize<<endl;
      cout<<"gcount(): "<<File.gcount()<<endl;
    
      delete[] read_filedata_array;
      File.clear();
    }

    I am getting different gcount() results depending on the location-structuring of the data I am reading in; filesize is always right, but gcount() is not. Sometimes gcount() is equal to filesize, but not always.

    If I test the size/lenght of the data after decompressing it, more often than not it is returning the same size as the filesize (sometimes more/less, depending on the data).

    So my puzzlement is, that even though I am getting different results (gcount() is always same/lower than filesize), it is actually (or so it seems) properly reading in all the compressed data?


    Someone able to explain why then that gcount() may not properly be returning the correct value? Or is there more to it?
    Thanks.
    Last edited by Tropod; 11-13-2009 at 08:38 PM. Reason: because I screwed up :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM