Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 67

Thread: Package Files

  1. #41
    Join Date
    Aug 2003
    Location
    Madrid - Spain
    Posts
    1,153
    Quote Originally Posted by thing2k
    The only thing that springs to mind is putting "buffer[file.gcount()] = '\0';" in front of "txt += buffer". As when reading reading to buffer size amount it buffer won't be a null terminating string.

    Hope it works.

    thing2k
    Thanks

    This way?
    Code:
    else if (m_filenames[i].rfind(".obj") != -1)
    {
    	const int MAX = 4096;
    	int amount = m_fileDetails[i].Size;
    	char buffer[MAX];
    	string txt;
        
    	while (amount > 0)
    	{
    		if (amount > MAX)
    			file.read(buffer, MAX);
    		else
    			file.read(buffer, amount);
    		buffer[file.gcount()] = '\0';
    		txt += buffer;
    		amount -= file.gcount();
    
    		m_texts.push_back(txt);
    	}
    }
    Cuz it doesn't work It gives this error: Runtime check failure: Stack around the variable 'buffer' was corrupted.

    Thanks
    n4x0 -- C++ Programmer
    Tank Game - Progress: 11%

  2. #42
    Join Date
    Feb 2004
    Location
    Shirebrook, England
    Posts
    637
    OKay, try
    Code:
                const int MAX = 4096;
                long amount = m_fileDetails[i].Size;
                char buffer[MAX+1];
                string txt;
                
                while (amount > 0)
                {
                    if (amount > MAX)
                        file.read(buffer, MAX);
                    else
                        file.read(buffer, amount);
                    buffer[file.gcount()] = '\0';
                    txt += buffer;
                    amount -= file.gcount();
                    
                    m_texts.push_back(txt);
            	}
    thing2k

    Wii Friendcode: 6478 2149 1540 7684

  3. #43
    Join Date
    Aug 2003
    Location
    Madrid - Spain
    Posts
    1,153
    Same error Thanks though
    n4x0 -- C++ Programmer
    Tank Game - Progress: 11%

  4. #44
    Join Date
    Aug 2003
    Location
    Madrid - Spain
    Posts
    1,153
    Any ideas?
    n4x0 -- C++ Programmer
    Tank Game - Progress: 11%

  5. #45
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    any updates at all thing2k??
    i would love for you to finish this tutorial out

    does this compile in visual studio .net ???
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

  6. #46
    Join Date
    Feb 2004
    Location
    Shirebrook, England
    Posts
    637
    Unfortunately no, so far I haven't had the time, also the above posts with n4x0 have highlighted a few errors, until I can fix these I can't take it farther.

    Quote Originally Posted by ostamo2
    does this compile in visual studio .net ???
    I believe it should do but you might have to change one or to function call names, as some have been deprecated.

    thing2k

    Wii Friendcode: 6478 2149 1540 7684

  7. #47
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    Quote Originally Posted by thing2k
    Unfortunately no, so far I haven't had the time, also the above posts with n4x0 have highlighted a few errors, until I can fix these I can't take it farther.



    I believe it should do but you might have to change one or to function call names, as some have been deprecated.

    thing2k
    allright but i am expecting you to finish this

    cuz man do i hate half tutorials

    thanks for the reply this tutorial is great
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

  8. #48
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    Any Updates on this Thing2k ????
    I hope so man, we are waiting
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

  9. #49
    Join Date
    Mar 2004
    Posts
    0
    interesting read i was using your tutorial for your info on directory listing. i found an error in this code:
    Code:
    bool Package::SetFileDetails(string path, vector<string> &filenames, vector<FileDetails> &fileDetails, bool subFolders)
    {
        _finddata_t find;
        long handle;
        int result;
        FileDetails fileInfo;
        string name; 
    
        handle = _findfirst((path + "*.*").data(), &find);
        if (handle < 0)
            return false;
    
        while ((find.name[0] == '.') && (result != -1))
            result = _findnext(handle , &find);
    
        while (result != -1)
        {
            name = path + find.name;
    
            if ((find.attrib & _A_SUBDIR) && subFolders)
            {
                SetFileDetails(name + "\\", filenames, fileDetails);
            }
            else
            {
                filenames.push_back(name);
                
                fileInfo.Index      = filenames.size();
                fileInfo.NameLength = name.length() + 1;
                fileInfo.Size       = find.size;
                fileDetails.push_back(fileInfo);
            }
            result = _findnext(handle , &find);
        }
        _findclose(handle);
        return true;
    }
    now, result is set to a random value, leaving the possablity that it will be -1, and therefore not entering eaither while statement. this is not a real error, just a possable bug. fix it by initing result:
    Code:
    int result = 0;



  10. #50
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    Any More updates on this Thing2k or is it dead for now ???
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

Page 5 of 7 FirstFirst ... 34567 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •