コード例 #1
0
ファイル: ecl_util.c プロジェクト: danielfmva/ert
bool ecl_util_valid_basename_fmt(const char * basename_fmt)
{
  bool valid;

  char * eclbasename_fmt = util_split_alloc_filename(basename_fmt);

  const char * percent_ptr = strchr(eclbasename_fmt, '%');
  if (percent_ptr) {
    percent_ptr++;
    while (true)
    {
      if (*percent_ptr == 'd')
      {
        char * basename_instance = util_alloc_sprintf(eclbasename_fmt, 0);
        valid = ecl_util_valid_basename(basename_instance);
        free(basename_instance);
        break;
      } else if (!isdigit(*percent_ptr)) {
        valid = false;
        break;
      } else
        percent_ptr++;
    }
  } else
    valid = ecl_util_valid_basename(eclbasename_fmt);

  free(eclbasename_fmt);

  return valid;
}
コード例 #2
0
ファイル: member_config.c プロジェクト: akva2/ResInsight
const char * member_config_update_eclbase(member_config_type * member_config , const ecl_config_type * ecl_config , const subst_list_type * subst_list) {
  util_safe_free( member_config->eclbase );
  {
    const path_fmt_type * eclbase_fmt = ecl_config_get_eclbase_fmt(ecl_config);
    if (eclbase_fmt != NULL) {
      {
        char * tmp = path_fmt_alloc_path(eclbase_fmt , false , member_config->iens);
        member_config->eclbase = subst_list_alloc_filtered_string( subst_list , tmp );
        free( tmp );
      }

      if (!ecl_util_valid_basename( member_config->eclbase )) 
        util_exit("Sorry - the basename:%s is invalid. ECLIPSE does not handle mIxeD cAsE :-( \n" , member_config->eclbase);
    }
  }
  
  return member_config->eclbase;
}
コード例 #3
0
ファイル: ecl_valid_basename.cpp プロジェクト: OPM/ResInsight
int main(int argc , char ** argv) {
    test_assert_true( ecl_util_valid_basename("ECLIPSE.DATA"));
    test_assert_true( ecl_util_valid_basename("ECLIPS100.DATA"));
    test_assert_true( ecl_util_valid_basename("eclipse100.data"));
    test_assert_true( ecl_util_valid_basename("MYPATH/ECLIPSE.DATA"));
    test_assert_true( ecl_util_valid_basename("mypath/ECLIPSE.DATA"));
    test_assert_false( ecl_util_valid_basename("ECLiPS100.DATa"));
    test_assert_false( ecl_util_valid_basename("mypath/eclipse.DATA"));

    test_assert_true( ecl_util_valid_basename_fmt("ECL_%d.DATA"));
    test_assert_true( ecl_util_valid_basename_fmt("ECL_%04d.DATA"));
    test_assert_true( ecl_util_valid_basename_fmt("mypath/ECL_%04d.DATA"));
    test_assert_true( ecl_util_valid_basename_fmt("MYPATH/ECL_%04d.DATA"));
    test_assert_true( ecl_util_valid_basename_fmt("MYPATH/ECL_%04d.DATA"));
    test_assert_false( ecl_util_valid_basename_fmt("ECL_%d.dATA"));
    test_assert_false( ecl_util_valid_basename_fmt("ECL_%s.DATA"));
    test_assert_false( ecl_util_valid_basename_fmt("mypath/ECL_%d.dATA"));

    exit(0);
}
コード例 #4
0
//-------------------------------------------------------------------------------------------------------
/// Check if libecl accepts the file name. libecl refuses to open files with mixed case in the file name.
//-------------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::isValidEclipseFileName(const QString& fileName)
{
    QString fileNameBase = QFileInfo(fileName).completeBaseName();
    return ecl_util_valid_basename(RiaStringEncodingTools::toNativeEncoded(fileNameBase).data());
}