osutils.cpp osutils.h iostream sys/types.h sys/stat.h fcntl.h errno.h void void get_fname (char *filename, string &dirname, string &f) get_fname char * filename string & dirname string & f void void makedir (string &dirname, bool rewrite) makedir string & dirname bool rewrite true Function creates a directory and raises it_error if it is not possible. dirname name of the directory to be created rewrite if true then existence of the directory is not an error // //C++Implementation:osutils // //Description: // // //Author:smidl<smidl@utia.cas.cz>,(C)2008 // //Copyright:SeeCOPYINGfilethatcomeswiththisdistribution // // #include"osutils.h" #include<iostream> #ifdefWIN32 #include<direct.h> #else #include<sys/types.h> #include<sys/stat.h> #endif #include<fcntl.h> #include<errno.h> voidget_fname(char*filename,string&dirname,string&f){ #ifdefWIN32 sprintf(filename,"%s\\%s",dirname.c_str(),f.c_str()); #else sprintf(filename,"%s/%s",dirname.c_str(),f.c_str()); #endif } voidmakedir(string&dirname,boolrewrite){ #ifdefWIN32 if(mkdir(dirname.c_str())==-1)//Createthedirectory #else if(mkdir(dirname.c_str(),00755)==-1)//Createthedirectory #endif { if((rewrite)&&(errno==EEXIST))it_warning("rewritingdirectory"); elseit_error("dirfilelog::cannotcreatedirectory"); } }