0. ์ฌ์ ์กฐ๊ฑด
- ์๋ ์์ ์ฝ๋๋ vs2017์์ ์ฌ์ฉ(๋ฆฌ๋ ์ค, ์๋์ฐ ํฌ๋ก์คํ๋ซํผ ํ๋ก์ ํธ ์ฌ์ฉ)
- boost ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ๊ฒฝ์ค์ ๋ง์น ์ํ
1. ํ์ผ ๊ฒฝ๋ก ์ค์
- ํค๋ ์ถ๊ฐ
#include <boost/filesystem.hpp>
2. ๊ธฐ๋ณธ path ์์ฑ
boost::filesystem::path p(boost::filesystem::current_path());
boost::filesystem::path state = p;
- get ํ ์ ์๋ path ์ ๋ณด
std::cout <<"boost::filesystem::initial_path() : " << boost::filesystem::initial_path().string() << std::endl;
std::cout <<"boost::filesystem::current_path() : " << boost::filesystem::current_path().string() << std::endl;
std::cout <<"boost::filesystem::unique_path() : " << boost::filesystem::unique_path().string() << std::endl;
๊ฒฐ๊ณผ๊ฐ
3. path ๊ฒฝ๋ก ์์ฑ
std::string dir_state = "state";
state += "/" + dir_state;
4. path์ ๋๋ ํ ๋ฆฌ ์์ฑ ์ ๋ฌด ํ๋จ
- ๋๋ ํ ๋ฆฌ๊ฐ ์กด์ฌํ์ง ์์๊ฒฝ์ฐ์ ์๋ก ์์ฑ
if(!boost::filesystem::exists(state))
{
boost::filesystem::create_directory(state);
}
5. ์์ฑํ ๋๋ ํ ๋ฆฌ ๋ด๋ถ์ ํ์ผ ์๋์ง ์๋์ง ์ฒดํฌ
if (boost::filesystem::is_empty(state) == false)
{
//ํ์ผ์ด ์์ ๊ฒฝ์ฐ
}
6. ํ์ผ๋ช
๋ณ๊ฒฝ
boost::filesystem::path oldfile = {old file path};
boost::filesystem::path newfile = {new file path};
boost::filesystem::rename(oldfile, newfile);
๋๊ธ