Boost filesystem Tutorial Digest

1. Boost.Filesystem file_size function returns a uintmax_t containing the size of the file named by the argument. The declaration looks like this:

uintmax_t file_size(const path& p);

 

2. For now, all you have to know is that class path has constructors that take const char* and many other useful types.

 

3. Using status queries to determine file existence and type, such as exists, is_directory and is_regular_file. And a file's status can be regular file, directory file and other type.

 

4. Directory_entry. A directory_entry object stores a path object, a file_status object for non-symbolic link status, and a file_status object for symbolic link status.

 

5. directory_entry. After a directory_iterator is constructed, and every time operator ++ is called, it reads a directory element and stores information about it in a object of type directory_entry.

Two end iterators are always equal.

Directory iteration shall not yield directory entries for the current (dot) and parent (dot dot) directories.

 

6. recursive_directory_iterator. Objects of type recursive_directory_iterator provide standard library compliant iteration over the content of a directory, including recursion into its sub-directories.

The behavior of a recursive_directory_iterator is the same as a directory_iterator unless otherwise specified.

Incrementing a recursive_director_iterator pointing to a directory causes that directory itself to be iterated ovee, as specified by the operator++ and increment functions.

When a recursive_directory_iterator reaches the end of the directory currently being iterated over, or when pop() is called, m_level is decremented, and iteration of the parent directory continues.

 

7. copy(directory_iterator(p), directory_iterator(), ostream_iterator<directory_entry>(cout, "\n"));

copy(InputIterator first, InputIterator last, OutputIterator result)

directory_itertor() return last.

vector<int> vec_it1, vec_it2;

copy(vec_it1.begin(), vec_it1.end(), vec_it2.begin());

copy(vec_it1.begin(), vec_it1.end(), back_inserter(vec_it2));

 

8. Building boost from visual studio 2012

Properties > Linker > General > Additional Library Directories添加包含的库目录

例如:D:\boost\boost_1_54_0\stage\lib

 

这在[2] 没有提到, 但缺少这个步骤的话会报错

 

Reference

[1] http://www.boost.org/doc/libs/1_55_0/libs/filesystem/doc/tutorial.html

[2] http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html#build-from-the-visual-studio-ide

[3] http://blog.csdn.net/xzz_hust/article/details/9365511

posted @ 2014-04-10 14:00  周卓  阅读(214)  评论(0编辑  收藏  举报