Boost logo

Boost :

Subject: [boost] filesystem3::rename error codes
From: Andreas Haferburg (ahaferburg_at_[hidden])
Date: 2011-06-28 06:07:37


Greetings,

I was wondering how to handle errors of filesystem3::rename(). I'd like
to use the system::error_code& overload, but I can't seem to find out
how to use it. The documentation at [1] points to POSIX rename(), so I'm
guessing the error_code somehow corresponds to the POSIX rename() return
value. I'm not a native speaker, but I find the documentation pretty
vague here. The tutorial section [2] doesn't help either.

For example if the target file doesn't exist, the error_code.value() is
3. But I'm not supposed to use the constant 3 in the code, am I? Are
there any constants defined that correspond to these error code values?
What's the proper way to do the following:

TEST( BoostFilesystem3Test, testRenameFails )
{
   boost::system::error_code ec;
   boost::filesystem3::rename("c:/does/not/exist", "asdf", ec);
   ASSERT_EQ(3, ec.value());
}

I'm going to use QFile for now, but only because their documentation is
better. I would like to use boost for as much as possible, so any
explanation or pointers to better documentation would be much
appreciated. Thank you.

Best regards
Andreas

[1]
http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/reference.html#rename
[2]
http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/tutorial.html#Error-reporting


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk