Boost logo

Boost Users :

From: Galante Michele (M.Galante_at_[hidden])
Date: 2003-12-11 02:32:06


I think you should rewrite your code either as:

  int processFile(const fs::path& fileName)
  {
      fs::path copyFileName(fileName.string() + ".bak");
      fs::copy_file(fileName, copyFileName);
  }

or as:

  int processFile(const fs::path& fileName)
  {
      fs::path copyFileName(fileName.native_file_string() + ".bak",
fs::native);
      fs::copy_file(fileName, copyFileName);
  }

In your example you are creating a fs::path from a string in "native" form
by using the default constructor, which expects the string to be in
"generic" form.

Hope this helps.
Regards,

Michele Galante
Zucchetti Centro Sistemi s.p.a.
m.galante_at_[hidden]

-----Messaggio originale-----
Da: Scott Meyers [mailto:Usenet_at_[hidden]]
Inviato: giovedì 11 dicembre 2003 7.11
A: boost-users_at_[hidden]
Oggetto: [Boost-users] filesystem::copy_file throws -- but why?

[...]

  int processFile(const fs::path& fileName)
  {
      fs::path copyFileName(fileName.native_file_string() + ".bak");
      fs::copy_file(fileName, copyFileName);
  }

This throws an exception:

  boost::filesystem::path: invalid name "D:\Temp\CDFix\INDEX.HTM.bak" in
path: "D:\Temp\CDFix
\INDEX.HTM.bak"

[...]


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