Remove a UNIX hidden file using boost::filesystem

J

Javier

Hello all,

I'm trying to remove a hidden file (in UNIX) using the
Boost::filesystem library.
This is what I have:


#include <boost/filesystem/operations.hpp>

namespace fs=boost::filesystem;

my_func()
{
fs::remove(fs::path("/path/to/.hiddenfile")); // this file
exists, and I have permissions to write it
}


And I get this error:


terminate called after throwing an instance of
'boost::filesystem::filesystem_error'
what(): boost::filesystem::path: invalid name ".hiddenfile" in
path: "/path/to/.hiddenfile"


Do you know what is wrong?
Is there any other way for doing this?

Thanks.
 
J

Joel Yliluoma

I'm trying to remove a hidden file (in UNIX) using the
Boost::filesystem library.

Your question is not relevant to the C++ language in general,
but it covers an issue with the boost::filesystem library.
Check for support groups of boost::filesystem instead.
The comp.lang.c++ group is for C++ language issues.
 
M

Markus Schoder

Hello all,

I'm trying to remove a hidden file (in UNIX) using the Boost::filesystem
library.
This is what I have:


#include <boost/filesystem/operations.hpp>

namespace fs=boost::filesystem;

my_func()
{
fs::remove(fs::path("/path/to/.hiddenfile")); // this file
exists, and I have permissions to write it }


And I get this error:


terminate called after throwing an instance of
'boost::filesystem::filesystem_error'
what(): boost::filesystem::path: invalid name ".hiddenfile" in
path: "/path/to/.hiddenfile"


Do you know what is wrong?
Is there any other way for doing this?

Not sure whether that has anything to do with your problem but to delete
a file on UNIX and UNIX-like systems you usually need write permissions
to the directory the file is in not the file itself (unless the sticky
bit is set on the directory).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top