ckdirs.cpp
/*
 *	dir_check() - check if a directory exists, and create it if not
 */
check if a directory exists, and create it if not
check if a directory exists and create it if not
void dir_check(string dirpath) {
	struct stat stat_dirpath;
	if (stat(dirpath.c_str(), &stat_dirpath) != 0 || !(stat_dirpath.st_mode & S_IFDIR)) {
		cout << "creating directory " << dirpath << endl;
		if ((system(("mkdir -p \'" + dirpath + "\'").c_str()) != 0)) {
			error(("directory \"" + dirpath + "\" does not exist; unable to create the the directory: ").c_str(), strerror(errno));
		}
	}
	system(("chmod 755 \"" + dirpath + "\" && chown -R " + getlogin() + " \"" + dirpath + "\"").c_str());
}
void dir_check ( string dirpath ) { struct stat stat_dirpath ; if ( stat ( dirpath . c_str ( ) , & stat_dirpath ) != 0 || ! ( stat_dirpath . st_mode & S_IFDIR ) ) { cout << " " << dirpath << endl ; if ( ( system ( ( " \' " + dirpath + " \' " ) . c_str ( ) ) != 0 ) ) { error ( ( " \" " + dirpath + " \" " ) . c_str ( ) , strerror ( errno ) ) ; } } system ( ( " \" " + dirpath + " \" " + getlogin ( ) + " \" " + dirpath + " \" " ) . c_str ( ) ) ; }
dir_check() - check if a directory exists, and create it if not
dir_check () - check if a directory exists and create it if not