libopenfpga/libopenfpgautil/src/openfpga_digest.cpp
/******************************************************************** 
 * Create a directory with a given path
 ********************************************************************/
Create a directory with a given path
Create a directory with a given path
static 
bool create_dir_path(const std::string& dir_path,
                     const bool& verbose) {
  if (true == dir_path.empty()) {
    VTR_LOG_WARN("Directory path is empty and nothing will be created.\n");
    return true;
  }
  int ret = mkdir(dir_path.c_str(), S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
  switch (ret) {
  case 0:
    VTR_LOGV(verbose,
             "Succeed to create directory '%s'\n",
             dir_path.c_str());
    return true;
  case -1:
    if (EEXIST == errno) {
      VTR_LOGV_WARN(verbose,
                    "Directory '%s' already exists. Will overwrite contents\n",
                    dir_path.c_str());
      return true;
    }
    VTR_LOG_ERROR("Create directory '%s'...Failed!\n",
                  dir_path.c_str());
    exit(1);
    break;
  default:
    VTR_LOG_ERROR("Create directory '%s'...Failed!\n",
                  dir_path.c_str());
    exit(1);
    return false;
  }
  return false;
}
static bool create_dir_path ( const std :: string & dir_path , const bool & verbose ) { if ( true == dir_path . empty ( ) ) { VTR_LOG_WARN ( " \n " ) ; return true ; } int ret = mkdir ( dir_path . c_str ( ) , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ) ; switch ( ret ) { case 0 : VTR_LOGV ( verbose , " \n " , dir_path . c_str ( ) ) ; return true ; case -1 : if ( EEXIST == errno ) { VTR_LOGV_WARN ( verbose , " \n " , dir_path . c_str ( ) ) ; return true ; } VTR_LOG_ERROR ( " \n " , dir_path . c_str ( ) ) ; exit ( 1 ) ; break ; default : VTR_LOG_ERROR ( " \n " , dir_path . c_str ( ) ) ; exit ( 1 ) ; return false ; } return false ; }
Create a directory with a given path
Create a directory with a given path
/* Give up if the path is empty */ /* Try to create a directory */ /* Analyze the return flag and output status */