Boost logo

Boost Users :

From: Lawrence Spector (Lawrence.Spector_at_[hidden])
Date: 2006-10-31 16:58:28


Hmm that's even more interesting, maybe a 2k vs. XP compability issue?
The file fails when trying to open on my system. I don't have a 2k
system to try it on, so I don't know how much more assistance I can be.
Based on the posts so far in this thread, though, I get the impression
that different users are getting different results, which is definitely
concerning. If I get a chance, I'll try it on my Fedora system tonight
and see what happens.

In the meantime, good luck.

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Aubrey, Jason
Sent: Tuesday, October 31, 2006 4:43 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] boost filesystem

Thanks for your suggestion Lawrence but I don't think it's related to
the problem.

I added the following after opening the file but it doesn't throw (since
the file is valid):
     if( !file.is_open() )
          throw std::exception("Unable to open file");

To prove that the file is valid:
     1) I verified that the program creates the file
     2) main() completes as expected.

The following is in regard to Rush's comment:

The call stack when trouble occurs is as follows:
     msvcr71d.dll!operator delete(void * pUserData=0x00343418)
     msvcp71d.dll!std::allocator<char>::deallocate(char *
_Ptr=0x00343418, unsigned int __formal=48)
     msvcp71d.dll!std::string::_Tidy(bool _Built=true, unsigned int
_Newsize=0)
     msvcp71d.dll!std::string::~string()
     TestsD.exe!$E2()
     msvcr71d.dll!doexit(int code=0, int quick=0, int retcaller=0)
     msvcr71d.dll!exit(int code=0)
     TestsD.exe!mainCRTStartup()
     kernel32.dll!7c816d4f()
     ntdll.dll!7c915b4f()
     kernel32.dll!7c8399f3()

The offending code within delete() is:
     _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));

Unfortunately, I couldn't make any sense of the data in or near the bad
block.

Regards,
Jason

----------------------

Environment:
        OS: Win2k
        Compiler: VS7.1
        Boost: v1.33.1

----------------------
 
#include <boost/filesystem/operations.hpp>
#include <fstream>

// Contrary to simplicity I've enhanced the following to satisfy
suggestions
int main(int, char**)
{
    // Create a file
    using namespace std;
    const string fileName("/temp/test.txt");
    ofstream file;
    file.open(fileName.c_str());
    if( !file.is_open() )
        throw std::exception("Unable to open file");
    const string message("this is a test");
    file << message;
    file.close();
    const boost::filesystem::path filePath(fileName);
    const boost::intmax_t fileSize =
boost::filesystem::file_size(filePath);

    if( fileSize != message.size() )
        throw std::exception("Bad result");

    return 0; // This line is reached without trouble
}
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net