boost-filesystem

bjam for boost 1.54

倖福魔咒の 提交于 2021-01-28 21:07:23
问题 I've boost 1.54 installed in Linux Debian (according to this). Then I installed bjam as follows: apt-get install bjam Then, in order to run a sample tut1 program with boost filesystem I typed: $ cd boost-root/libs/filesystem/example/test $ ./setup.sh $ ./bld.sh This should result in building tut1 file. But there is no tut1 file in test folder. There is only tut1.cpp copied here by setup.sh . I suspect the bjam installed is not for boost 1.54. How to install bjam properly? After typing bjam I

How does boost::filesystem::unique_path() resolve the need in mkstemp analogue in C++?

倖福魔咒の 提交于 2021-01-28 05:42:13
问题 An old feature request for Boost was requesting a feature similar to mkstemp POSIX function to be available in Boost.Filesystem. The issue is long closed as fixed, with the comment The unique_path() function in Version 3 addresses the problem. But I fail to see how unique_path resolves the problem. It's basically the same as tmpnam: after the name has been generated and before actual file is created, another program may have created its file with the same name. So how is it supposed to

Filtering folders in Boost Filesystem

為{幸葍}努か 提交于 2021-01-28 04:06:55
问题 I want to get all the files inside a concrete folder (in this case Documents) with Boost Filesystem in Windows. For this I make a filter to assure I get no folders. The problem is that when I still get the following folders : "C:\....\Documents\My Videos", "C:\....\Documents\My Music", "C:\....\Documents\My Pictures" (I don't get some other folders) The code is the following: boost::filesystem::directory_iterator end; for (boost::filesystem::directory_iterator iter(documentsFolder); iter !=

Which compilers support std::filesystem?

岁酱吖の 提交于 2021-01-27 02:55:06
问题 Thanks to C++11, after a long relationship with boost, the last component that makes me depend on it is the filesystem. std::filesystem seems to be implemented as experimental according to the link: Filesystem library Since it mimics boost::filesystem, I can easily adapt my project into std and get rid of huge boost dependency. Which compilers support it and would it matter to use it even though it is experimental since it mimics boost (since there is no time schedule for when it will be

how to use C++ to get the folder/directory name, but not the path of one file? Especially boost::filesystem; [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-07 04:03:23
问题 This question already has answers here : Getting a directory name from a filename (11 answers) Closed 3 years ago . std::string file="C:\\folder1\\folder2\\folder3.txt"; fs::path file_path(file); fs::path file_dir=file_path.parent_path();// "C:\\folder1\\folder2"; std::string str_path=file_path.string(); std::string str_dir=file_dir.string(); std:string str_folder=str_path.erase(0,str_dir()+1);// return folder2 This is the method I used. It works for me, but it looks ugly. So I prefer to look

Boost filesystem path append for char array

点点圈 提交于 2020-01-21 12:42:55
问题 The snippet of the code is: boost::filesystem::path petscConfigurationPath; petscConfigurationPath.append("FluidPetsc/Basic.conf"); It results in the following errors with boost 1.54: error: no matching function for call to ‘boost::filesystem::path::append(const char [22])’ petscConfigurationPath.append("FluidPetsc/Basic.conf"); ^ note: candidates are: In file included from /usr/include/boost/filesystem.hpp:16:0, /usr/include/boost/filesystem/path.hpp:305:11: note: boost::filesystem::path&

How to create a folder in the home directory?

…衆ロ難τιáo~ 提交于 2020-01-21 04:36:12
问题 I want to create a directory path = "$HOME/somedir" . I've tried using boost::filesystem::create_directory(path) , but it fails - apparently the function doesn't expand system variables. How can I do it the simplest way? (note: in my case the string path is constant and I don't know for sure if it contains a variable) edit: I'm working on Linux (although I'm planning to port my app to Windows in the near future). 回答1: Use getenv to get environment variables, including HOME . If you don't know