3

I'm asking boost::filesystem::file_size for a file with path "/tmp/test\ file.txt", and it reports no such file or directory when it is there.

Error: fs::file_size("/tmp/test\ file.txt") reported boost::filesystem::file_size: No such file or directory
-rw-rw-r-- 1 rturrado users 12486 Mar 15 12:01 /tmp/test file.txt

Are there any considerations when using paths with escaped sequences in boost::filesystem?

3
  • 2
    Escaping the space in that filename seems strange. Commented Mar 15, 2011 at 11:21
  • 1
    Does the filename really have a backslash in it, or is that only to escape the space for the shell? What is the actual code you wrote? Commented Mar 15, 2011 at 11:35
  • Fixed. Thanks guys. I didn't need the escape. The real filename should be "/tmp/test file.txt", without the quotes. And I was passing "/tmp/test\\ file.txt" as a parameter. But just passing "/tmp/test file.txt" is good. Commented Mar 15, 2011 at 11:40

1 Answer 1

6

Closing this question, as I fixed the issue thanks to Mat and ymett comments.

boost::filesystem::file_size("/tmp/test file.txt") works just fine. You don't need any escaping.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.