boost-filesystem

How to get file permissions with c++ boost library?

最后都变了- 提交于 2019-12-19 19:13:07
问题 I am working on a project to make a database of the files I have on current directory. And one of the details I want about my files is the file permissions that are set with chmod in ubuntu. (just a note: I will be needing the group and owner info too - like chown- and if you could let me know if boost can retrieve the ownership info too that'd be great.) I am using boost filesystem library and I have checked the documentation for numerous times but couldn't find how to get the permissions.

C++:boost file system to return a list of files older than a specific time

随声附和 提交于 2019-12-19 15:40:28
问题 I am using the Boost::FileSystem library with C++ running under Linux platform and I have a question following: I would like to have a list of files which are modified older than a given date time. I don't know whether the boost::FileSystem offer such a method as: vector<string> listFiles = boost::FileSystem::getFiles("\directory", "01/01/2010 12:00:00"); If yes, could you please provide sample code? 回答1: Boost::filesystem doesn't offer a function exactly like that. But you can use this: http

C++ / Boost Filesystem - mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600'

本小妞迷上赌 提交于 2019-12-18 21:19:12
问题 I'm new to C++ and Boost. I'm doing a small simple program to trying to learn the Boost Filesystem library. I have followed the directions to build the Boost libs. And now when I try to compile this simple code I get 6 of these errors. Error 5 error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in App.obj C:\SOURCE\ConsoleApp2\ConsoleApp2\libboost_filesystem-vc110-mt-gd-1_51.lib(codecvt_error_category.obj) ConsoleApp2 Error 1 error LNK2038: mismatch

C++ BOOST undefined reference to `boost::filesystem::detail::copy_file

拟墨画扇 提交于 2019-12-18 03:11:30
问题 I have no clue why boost::filesystem::copy_file is making trouble for me. undefined reference to `boost::filesystem::detail::copy_file // g++ -std=c++11 test.cpp -lboost_filesystem -lboost_system -lrt -lboost_wave #include <boost/filesystem.hpp> int main() { boost::filesystem::create_directory("aaa"); // ok boost::filesystem::copy_file("f1","f2"); // /tmp/ccNWZltB.o: In function `boost::filesystem::copy_file(boost::filesystem::path const&, boost::filesystem::path const&)': // test.cpp:(.text.

boost directory_iterator example - how to list directory files not recursive

浪子不回头ぞ 提交于 2019-12-17 23:15:26
问题 How should I use directory_iterator to list directory files (not recursive)? Also what header files / libs should I add/link or other settings I should make? I'm using boost in my project but by some reason directory_iterator is "underclared identifier" while I can use other boost features. Update Another solution: #include <filesystem> #include <boost/filesystem.hpp> #include <iostream> using namespace boost::filesystem; for (directory_iterator itr(path_ss); itr!=directory_iterator(); ++itr)

expand file names that have environment variables in their path

醉酒当歌 提交于 2019-12-17 09:31:58
问题 What's the best way to expand ${MyPath}/filename.txt to /home/user/filename.txt or %MyPath%/filename.txt to c:\Documents and settings\user\filename.txt with out traversing the path string looking for environement variables directly? I see that wxWidgets has a wxExpandEnvVars function. I can't use wxWidgets in this case, so I was hoping to find a boost::filesystem equivalent or similar. I am only using the home directory as an example, I am looking for general purpose path expansion. 回答1: For

Environment PATH Directories Iteration

∥☆過路亽.° 提交于 2019-12-12 06:25:06
问题 I cant find any code (neither C nor C++ Boost.Filsystem) on how to iterate ( parse ) the directories present in the PATH environment variable in preferrably in a platform-independent way. It is not so hard to write but I want to reuse standard modules if they are available. Links or suggestions anyone? 回答1: This is what I used before: const vector<string>& get_environment_PATH() { static vector<string> result; if( !result.empty() ) return result; #if _WIN32 const std::string PATH = convert_to

Getting better error messages for iostreams

筅森魡賤 提交于 2019-12-12 05:58:38
问题 I implemented a small program that can extract (and via fuse mount) a certain archive format. I use boost::filesystem::ifstream , but on error (e.g. the file a user wants to extract does not exist) I get very nondescript error messages. I wonder is there a way to get better error messages for IO related problems in C++? On a related note I wonder whether I should have used C's FILE* or in the case of the fuse filesystem just plain file descriptors? Because strerror(errno) is way better than

Infinite recursion when I build an absolute path using boost

扶醉桌前 提交于 2019-12-12 00:55:22
问题 I needed a function to get the absolute path and for that purpose I had a look in boost but it only has that in recent version and I'm using an old 1.44 . As I cannot update my code on recent boost 1.55 or higher, I decided to re-write that function. It worked fine on Windows but I'm getting in an infinite recursion under Linux and I cannot understand why ? That code is based on the description you can find here All advice to fix that issue will be welcome ! Thanks #include "boost/filesystem

Using boost::iostreams::mapped_file_source with wide character strings

不打扰是莪最后的温柔 提交于 2019-12-11 00:54:59
问题 If I instantiate a mapped_file_source (boost 1.46.1 ) with a narrow character string as in the following I don't have a problem: boost::iostreams::mapped_file_source m_file_( "testfile.txt" ); However if I try to use a wide string: boost::iostreams::mapped_file_source m_file_( L"testfile.txt" ); I get the following compiler error in VC2010 SP1: P:\libs\boost_1_46_1\boost/iostreams/device/mapped_file.hpp(128): error C2248: 'boost::iostreams::detail::path::path' : cannot access private member