Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::filesystem normalize filename

I need normalize file names such that it don't contain any non-portable characters in it. There is portable_file_name but that just checks and returns bool. I need to anyhow convert the given string to a portable name to create files.

Is there any reusable works ?

like image 366
Neel Basu Avatar asked Jun 29 '26 10:06

Neel Basu


1 Answers

The best I could come up with so far is:

for (auto &c:name)
    {
        char test[] = { c,0 };
        if (!boost::filesystem::portable_file_name(test))
        {
            c = '_';
        }
    }
like image 172
Arsen Zahray Avatar answered Jul 03 '26 13:07

Arsen Zahray