2007-05-11 :-)
_ [C++][boost]素人が書く C++
ファイル削除。Boost を使います。
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp>
#include <iostream>
#include <string>
using namespace std;
namespace fs = boost::filesystem;
int main( int ac, char** av )
{
string fn = av[ 1 ];
string sout = "hello";
string sin;
ofstream fout( fn.c_str() );
ifstream fin( fn.c_str() );
fout << sout << endl;
fin >> sin;
cout << sin << endl;
fout.close();
fin.close();
if( fs::exists( fn ) )
cout << "found: " << fn << endl;
fs::remove( fn ); // ファイル削除
if( !fs::exists( fn ) )
cout << "not found: " << fn << endl;
return 0;
}
実行します。
>file0 test.txt hello found: test.txt not found: test.txt
_ 素人が書く C++
ディレクトリを再帰的に辿ってディレクトリの下にあるファイル名を印字する。Boost を使用。find . -type f とかコマンドプロンプトの dir /s/b みたいなものです。
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>
using namespace std;
namespace fs = boost::filesystem;
void dirent( const fs::path& dir )
{
if( !fs::exists( dir ) ) return;
fs::directory_iterator end;
for( fs::directory_iterator it( dir ); it != end; it++ )
{
cout << it->string() << endl;
if( fs::is_directory( *it ) )
dirent( *it );
}
}
int main( int ac, char** av )
{
fs::path dirp( av[ 1 ] );
dirent( dirp );
return 0;
}
_ [C++][boost]素人が書く C++
ファイル名を検索する。boost を使用。find . -type d -name foo とかコマンドプロンプトの dir /s/b foo みたいなものです。
#include <boost/regex.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>
using namespace std;
namespace fs = boost::filesystem;
void dirent( const fs::path& dir, const boost::regex& pattern )
{
if( !fs::exists( dir ) ) return;
fs::directory_iterator end;
for( fs::directory_iterator it( dir ); it != end; it++ )
{
if( boost::regex_search( it->leaf(), pattern ) )
cout << it->string() << endl;
if( fs::is_directory( *it ) )
dirent( *it, pattern );
}
}
int main( int ac, char** av )
{
fs::path dirp( av[ 1 ] );
boost::regex pattern( av[ 2 ] );
dirent( dirp, pattern );
return 0;
}
_ [EXTRA]EXTRA - HYPER GAME MUSIC EVENT 2007
THE BLACK MAGES も参加するという EXTRA です。出演者が果てしなく豪華です。
- 伊藤賢治
- 岩田匡治
- 大久保博
- 河本圭代
- 古代祐三
- 﨑元仁
- 田中宏和
- 並木学
- 日比野則彦
- 細江慎治
- 松前公高
- 山岡晃
- [H.]
- THE BLACK MAGES
週刊ファミ通に先行予約応募券があるということで週刊ファミ通を買ってきました。チケットはひとり 4 枚まで応募可能ということで 4 枚応募してみます。当落通知は 6/20 に来るそうです。
ref. “THE BLACK MAGES”ライブ出演が決定!!

[ツッコミを入れる]






