Ejemplo n.º 1
0
void wb_crrgen::write(pwr_tStatus* rsts)
{
  pwr_tStatus sts;
  char type_char = '\0';
  pwr_tAttrRef prev_target;
  pwr_tFileName fname;

  memset(&prev_target, 0, sizeof(prev_target));

  sprintf(fname, "$pwrp_load/rtt_crr_%s.dat", vldh_VolumeIdToStr(m_sp->vid()));
  dcli_translate_filename(fname, fname);

  std::ofstream fps(fname);
  if (!fps) {
    *rsts = LDH__FILEOPEN;
    return;
  }

  sCrr* crr = (sCrr*)tree_Minimum(&sts, m_signal_th);
  while (crr) {
    wb_attribute a_target = m_sp->attribute(&crr->key.target);
    wb_object o = m_sp->object(crr->key.reference.Objid);
    if (!a_target) {
      if (crr->key.target.Objid.vid == crr->key.reference.Objid.vid)
        printf("** Undefined reference in: %s\n",
            o.longName().name(
                cdh_mName_volume | cdh_mName_path | cdh_mName_attribute));
      else
        printf("-- External reference in: %s\n",
            o.longName().name(
                cdh_mName_volume | cdh_mName_path | cdh_mName_attribute));
      crr = (sCrr*)tree_Successor(&sts, m_signal_th, crr);
      continue;
    }
    wb_cdef cdef = m_sp->cdef(o.cid());

    if (!(crr->key.target.Objid.vid == prev_target.Objid.vid
            && crr->key.target.Objid.oix == prev_target.Objid.oix
            && crr->key.target.Offset == prev_target.Offset
            && crr->key.target.Size == prev_target.Size))
      fps << a_target.longName().name(
                 cdh_mName_volume | cdh_mName_path | cdh_mName_attribute)
          << '\n';

    switch (crr->key.type) {
    case crrgen_eType_Write:
      type_char = 'W';
      break;
    case crrgen_eType_Read:
      type_char = 'R';
      break;
    case crrgen_eType_Ref:
      type_char = '>';
      break;
    default:;
    }
    fps << " " << type_char << " "
        << o.longName().name(cdh_mName_path | cdh_mName_attribute) << " "
        << cdef.name() << '\n';
    memcpy(&prev_target, &crr->key.target, sizeof(prev_target));
    crr = (sCrr*)tree_Successor(&sts, m_signal_th, crr);
  }
  fps.close();

  // Signal list
  sprintf(fname, "$pwrp_load/rtt_crrs_%s.dat", vldh_VolumeIdToStr(m_sp->vid()));
  dcli_translate_filename(fname, fname);

  std::ofstream fpsl(fname);
  if (!fps) {
    *rsts = LDH__FILEOPEN;
    return;
  }

  pwr_tCid siglist[] = { pwr_cClass_Di, pwr_cClass_Do, pwr_cClass_Dv,
    pwr_cClass_Ai, pwr_cClass_Ao, pwr_cClass_Av, pwr_cClass_Ii, pwr_cClass_Io,
    pwr_cClass_Iv, pwr_cClass_Co, pwr_cClass_Sv, pwr_cClass_ATv,
    pwr_cClass_DTv };

  for (int i = 0; i < int(sizeof(siglist) / sizeof(siglist[0])); i++) {
    pwr_tAttrRef aref;

    for (m_sp->aref(siglist[i], &aref); m_sp->oddSts();
         m_sp->nextAref(siglist[i], &aref, &aref)) {
      wb_object o = m_sp->object(aref.Objid);
      if (!o)
        continue;

      // Skip if in LibHier
      bool in_libhier = false;
      for (wb_object p = o.parent(); p; p = p.parent()) {
        if (p.cid() == pwr_eClass_LibHier) {
          in_libhier = true;
          break;
        }
      }
      if (in_libhier)
        continue;

      wb_attribute a = m_sp->attribute(&aref);
      if (!a)
        continue;

      fpsl << a.longName().name(
                  cdh_mName_path | cdh_mName_object | cdh_mName_attribute)
           << '\n';
    }
  }
  fpsl.close();

  sprintf(fname, "$pwrp_load/rtt_crro_%s.dat", vldh_VolumeIdToStr(m_sp->vid()));
  dcli_translate_filename(fname, fname);

  std::ofstream fpo(fname);
  if (!fpo) {
    *rsts = LDH__FILEOPEN;
    return;
  }

  memset(&prev_target, 0, sizeof(prev_target));

  crr = (sCrr*)tree_Minimum(&sts, m_object_th);
  while (crr) {
    wb_attribute a_target = m_sp->attribute(&crr->key.target);
    wb_object o = m_sp->object(crr->key.reference.Objid);
    if (!a_target) {
      if (crr->key.target.Objid.vid == crr->key.reference.Objid.vid)
        printf("** Undefined reference in: %s\n",
            o.longName().name(
                cdh_mName_volume | cdh_mName_path | cdh_mName_attribute));
      else
        printf("-- External reference in: %s\n",
            o.longName().name(
                cdh_mName_volume | cdh_mName_path | cdh_mName_attribute));
      crr = (sCrr*)tree_Successor(&sts, m_object_th, crr);
      continue;
    }
    wb_cdef cdef = m_sp->cdef(o.cid());

    if (!(crr->key.target.Objid.vid == prev_target.Objid.vid
            && crr->key.target.Objid.oix == prev_target.Objid.oix
            && crr->key.target.Offset == prev_target.Offset
            && crr->key.target.Size == prev_target.Size))
      fpo << a_target.longName().name(
                 cdh_mName_volume | cdh_mName_path | cdh_mName_attribute)
          << '\n';

    switch (crr->key.type) {
    case crrgen_eType_Write:
      type_char = 'W';
      break;
    case crrgen_eType_Read:
      type_char = 'R';
      break;
    case crrgen_eType_Ref:
      type_char = '>';
      break;
    default:;
    }
    fpo << " " << type_char << " "
        << o.longName().name(cdh_mName_path | cdh_mName_attribute) << " "
        << cdef.name() << '\n';
    memcpy(&prev_target, &crr->key.target, sizeof(prev_target));
    crr = (sCrr*)tree_Successor(&sts, m_object_th, crr);
  }
  fpo.close();

  *rsts = 1;
}
Ejemplo n.º 2
0
void GitEntry::WriteGitProperties(const wxString& localRepoPath, const GitEntry::GitProperties& props)
{
    // Read the global name/email
    // ~/.gitconfig | %USERPROFILE%\.gitconfig
    {
        wxFileName globalConfig(::wxGetHomeDir(), ".gitconfig");
        if(globalConfig.Exists()) {
            wxFFile fp(globalConfig.GetFullPath(), "rb");
            if(fp.IsOpened()) {
                wxString content;
                fp.ReadAll(&content, wxConvUTF8);
                fp.Close();
                wxStringInputStream sis(content);
                wxFileConfig conf(sis);
                conf.Write("user/email", props.global_email);
                conf.Write("user/name", props.global_username);

                // Write the content
                content.Clear();
                wxStringOutputStream sos(&content);
                if(conf.Save(sos, wxConvUTF8)) {
                    wxFFile fpo(globalConfig.GetFullPath(), "w+b");
                    if(fpo.IsOpened()) {
                        fpo.Write(content, wxConvUTF8);
                        fpo.Close();
                    }
                } else {
                    ::wxMessageBox("Could not save GIT global configuration. Configuration is unmodified",
                                   "git",
                                   wxICON_WARNING | wxOK | wxCENTER);
                }
            }
        }
    }

    // Read the repo config file
    if(!localRepoPath.IsEmpty()) {
        wxFileName localConfig(localRepoPath, "config");
        localConfig.AppendDir(".git");
        wxFFile fp(localConfig.GetFullPath(), "rb");
        if(fp.IsOpened()) {
            wxString content;
            fp.ReadAll(&content, wxConvUTF8);
            fp.Close();
            wxStringInputStream sis(content);
            wxFileConfig conf(sis);
            conf.Write("user/email", props.local_email);
            conf.Write("user/name", props.local_username);

            content.Clear();
            wxStringOutputStream sos(&content);
            if(conf.Save(sos, wxConvUTF8)) {
                wxFFile fpo(localConfig.GetFullPath(), "w+b");
                if(fpo.IsOpened()) {
                    fpo.Write(content, wxConvUTF8);
                    fpo.Close();
                }
            } else {
                ::wxMessageBox("Could not save GIT local configuration. Configuration is unmodified",
                               "git",
                               wxICON_WARNING | wxOK | wxCENTER);
            }
        }
    }
}