Would you be able to print out what the values of message.size() and fileSize are, right before you do that comparison? Thanks. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Aubrey, Jason Sent: Tuesday, October 31, 2006 1:12 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost filesystem Replies are at the end of this message: Aubrey, Jason wrote:
Hi,
When I run the following program it runs successfully but throws an exception during shutdown. I don't know why, but it seems that the call to boost::filesystem::file_size() is corrupting memory somehow. This example only shows the call to file_size() but I think I've seen similar trouble with other calls within boost::filesystem.
Am I doing something wrong here or is this a bug?
Regards, Jason Aubrey
----------------------
Environment: OS: Win2k Compiler: VS7.1 Boost: v1.33.1
----------------------
#include
#include <fstream> int main(int, char**) { // Create a file using namespace std; const string fileName("/temp/test.txt"); ofstream file; file.open(fileName.c_str()); const string message("this is a test"); file << message; file.close();
const boost::intmax_t fileSize = boost::filesystem::file_size(fileName);
if( fileSize != message.size() ) throw std::exception("Bad result");
return 0; }
Either I'm missing something, or... file_size takes a path reference as its calling argument. You're passing a string. How does this even compile? - Rush _______________________________________________ Thanks for the Reply Rush. If I modify the above code to contain the following I still see the same behavior: const boost::filesystem::path filePath(fileName); const boost::intmax_t fileSize = boost::filesystem::file_size(filePath); Regards, Jason Aubrey _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users