/* as-util.h 2011/06/12 by 7k email: blxode [at] gmail.com */ #ifndef _AS_UTIL_H_ #define _AS_UTIL_H_ #include #include #include #include #include using namespace std; namespace as{ int open_or_die(string in_filename, const int type){ const char *fn = in_filename.c_str(); int fd = open(fn, type); if(fd == -1){ cerr<<"Could not open "<0 ; i--){ if(filename[i] == '/') break; } string path=filename.substr(0,i); mkdirEx(path.c_str()); } void write_file(string filename, unsigned char *buff, unsigned long len){ const char *fn = filename.c_str(); fstream file; file.open(fn,ios::binary | ios::out); if(!file.is_open()){ cerr<<"Could not open "<