libopenfpga/libopenfpgautil/src/openfpga_digest.cpp
/******************************************************************** 
 * Recursively create a directory with a given path
 * The create_dir_path() function will only try to create a directory
 * in the last level. If any parent directory is not created, it will
 * always fail.
 * This function will try to create all the parent directory before 
 * creating the last level. 
 ********************************************************************/
Recursively create a directory with a given path
The create_dir_path() function will only try to create a directory
in the last level. If any parent directory is not created, it will
always fail.
This function will try to create all the parent directory before
creating the last level.
Recursively create a directory with a given path The create_dir_path () function will only try to create a directory in the last level . If any parent directory is not created it will always fail . This function will try to create all the parent directory before creating the last level .
static 
bool rec_create_dir_path(const std::string& dir_path) {
  if (true == dir_path.empty()) {
    VTR_LOG_WARN("Directory path is empty and nothing will be created.\n");
    return true;
  }
  char back_slash = '/';
#ifdef _WIN32
  char back_slash = '\\';
#endif 
  std::vector<size_t> slash_pos; 
  for (size_t pos = 0; pos < dir_path.size(); ++pos) {
    if ( (back_slash == dir_path.at(pos))
      && (0 != pos))  {
      slash_pos.push_back(pos);
    }
  }
  for (const size_t& pos : slash_pos) {
    std::string sub_dir = dir_path.substr(0, pos);
    if (false == create_dir_path(sub_dir, &pos == &slash_pos.back())) {
      return false;
    } 
  }
  return true;
}
static bool rec_create_dir_path ( const std :: string & dir_path ) { if ( true == dir_path . empty ( ) ) { VTR_LOG_WARN ( " \n " ) ; return true ; } char back_slash = ' ' ; #ifdef _WIN32 char back_slash = ' \\ ' ; #endif std :: vector < size_t > slash_pos ; for ( size_t pos = 0 ; pos < dir_path . size ( ) ; ++ pos ) { if ( ( back_slash == dir_path . at ( pos ) ) && ( 0 != pos ) ) { slash_pos . push_back ( pos ) ; } } for ( const size_t & pos : slash_pos ) { std :: string sub_dir = dir_path . substr ( 0 , pos ) ; if ( false == create_dir_path ( sub_dir , & pos == & slash_pos . back ( ) ) ) { return false ; } } return true ; }
Recursively create a directory with a given path
 The create_dir_path() function will only try to create a directory
 in the last level.
Recursively create a directory with a given path The create_dir_path () function will only try to create a directory in the last level .
/* Give up if the path is empty */ /* Try to find the positions of all the slashes
   * which are the splitter between directories
   */ /* For windows OS, replace any '/' with '\' */ /* Keep searching until we reach the end of the string */ /* Skip the pos = 0, we should avoid creating any root directory */ /* Create directory by following the position of back slash
   * For each back slash, create a sub string from the beginning 
   * and try to create directory
   */ /* Turn on verbose output only for the last position: the leaf directory */