Boost logo

Boost Users :

Subject: [Boost-users] Unicode Problem
From: green beret (greenberet123_at_[hidden])
Date: 2010-04-19 11:12:20


Ive written a small function to copy a directory from one dir to another

When I run this on one Fedora 12 machine, it works fine, even for
chinese files and folders.

however, when i run this on Fedora 12 on another machine, it gives me
Boost::filesystem::copy_file: Invalid Argument: "/mnt/pd1/??Microsoft
Word ??.doc"."/mnt/pd/??Microsoft Word ??.doc"

Why? is the machine missing any package? Please help
Here is the code:

#include <iostream>
#include <boost/filesystem.hpp>
#include <cstdio>
#include <string>

using namespace std;

struct dir
{
   int file_count;
   int total_size;
};

void copy_dir(string src, string dest);

int main()
{

copy_dir("/media/disk", "/media/disk-1");

return 0;
}

void copy_dir(string src, string dest)
{

boost::filesystem::path psrc(src);
boost::filesystem::path pdest(dest);

if(!boost::filesystem::is_directory(psrc) ||
!boost::filesystem::is_directory(pdest))
{ cerr<<" Source and Destination are not directories "<<endl; }

for(boost::filesystem::directory_iterator i(psrc);
i!=boost::filesystem::directory_iterator(); ++i)
{
boost::filesystem::path from(*i);
string to_path=pdest.string() + "/" + i->leaf();
boost::filesystem::path to(to_path);

        if(is_regular(from) && !boost::filesystem::exists(to) )
        {
        cerr<<"Copying "<<from.string()<<" to "<<to.string()<<endl;
        copy_file(from,to);
        }
        else if(is_directory(from) )
        {
        if(!exists(to))
        create_directory(to);
        copy_dir(from.string(), to_path);
        }
}

}

Thanks...


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