Пример #1
0
bool BundleManager::InstallBundle() {
	wxASSERT(m_currentBundle);

	// Create temp dir
	wxString tempDir = wxStandardPaths::Get().GetTempDir();
	tempDir += wxFILE_SEP_PATH + m_currentBundle->m_name;
	if (wxDirExists(tempDir)) {
		// Delete old first
		DelTree(tempDir);
	}
	wxMkdir(tempDir);

	// Show progress dialog
	wxProgressDialog dlg(_("Downloading..."), m_currentBundle->m_name, 200, this, wxPD_AUTO_HIDE|wxPD_APP_MODAL);

	// Download bundle
	const wxString& repoUrl = GetCurrentRepoUrl();
	const wxString url = repoUrl + m_currentBundle->m_name + wxT('/');
	wxFileName path(tempDir, wxEmptyString);
	if (!DownloadDir(url, path, dlg)) {
		DelTree(tempDir); // clean up
		return false;
	}

	// Set modDate to match repo
	// Windows does not support changing dates on directories under FAT so
	// to make sure it works we set the date on info.plist instead
	path.SetFullName(wxT("info.plist"));
	path.SetTimes(NULL, &m_currentBundle->m_modDate, NULL);

	// Delete installed version (if any)
	wxString installPath = dynamic_cast<IAppPaths*>(wxTheApp)->GetAppDataPath() + wxT("InstalledBundles") + wxFILE_SEP_PATH;
	if (!wxDirExists(installPath)) wxMkdir(installPath);
	installPath += m_currentBundle->m_name;
	if (wxDirExists(installPath)) DelTree(installPath);

	// Move bundle to install dir
	wxRenameFile(tempDir, installPath);

	// Update list
	bool inList = false;
	for (vector<cxBundleInfo>::iterator p = m_installedBundles.begin(); p != m_installedBundles.end(); ++p) {
		if (p->dirName == m_currentBundle->m_name) {
			p->modDate = m_currentBundle->m_modDate;
			inList = true;
			break;
		}
	}
	if (!inList) {
		cxBundleInfo bi(-1, m_currentBundle->m_name, m_currentBundle->m_modDate);
		m_installedBundles.push_back(bi);
	}

	// Update the UI
	m_bundleList->SetItemImage(m_currentSel, 1); // up-to-date image
	SelectItem(m_currentSel, true);

	m_needBundleReload = true;
	return true;
}
Пример #2
0
void TParser::DelTree(TParserNode *tree)
{
   if(tree==NULL) return;

   DelTree(tree->left);
   DelTree(tree->right);

   delete tree;

   return;
}
Пример #3
0
void BundleManager::OnDeleteButton(wxCommandEvent& WXUNUSED(event)) {
	wxASSERT(m_currentBundle);
	wxASSERT(m_currentBundleInfo);
	if (m_installedBundles.empty()) return;

	// convert pointer to iterator
	vector<cxBundleInfo>::iterator p = m_installedBundles.begin() + (m_currentBundleInfo - &*m_installedBundles.begin());

	if (m_currentBundleInfo->id == -1) {
		// We have just installed it, so just delete dir
		const wxString installPath = dynamic_cast<IAppPaths*>(wxTheApp)->GetAppDataPath() + wxT("InstalledBundles") + wxFILE_SEP_PATH + m_currentBundle->m_name;
		DelTree(installPath);

		m_installedBundles.erase(p);
	}
	else {
		if (m_plistHandler.DeleteBundle(m_currentBundleInfo->id)) m_installedBundles.erase(p);
		else m_currentBundleInfo->isDisabled = true;
	}

	// Update UI
	m_bundleList->SetItemImage(m_currentSel, 0); // empty image
	SelectItem(m_currentSel, true);

	m_needBundleReload = true;
}
Пример #4
0
//---------------------------------------------------------------------------
void __fastcall TCPEmpresas::SpeedButton8Click( TObject*  Sender )
{
  CodEmpExcl = ( int ) PHDS1->GV( "Codigo", 0 );
  if( CodEmpExcl == vg.EmpresaAtual )
   {
    throw Exception( "Impossível. Empresa está em uso" );
   }

  HandleExcl = vg.RequerExclusividade( tdsPrincipal, false );
  if( HandleExcl == -1 )
   {
    throw Exception( "Impossível. Outro(s) Usuário(s) no sistema" );
   }

  try
   {
    if( PHDS1->Delete( true ) == true )
     {
      chdir( vg.DiretorioPrincipal.c_str() );
      if( DelTree( vg.DiretorioPrincipal + IntToStr( CodEmpExcl ) ) == false )
       {
        Bip();
        ShowMensagem( "Não foi possível deletar Sub-Diretório." );
       }
     }
   }

  __finally
   {
    vg.LimpaExclusividade( HandleExcl );
   }
}
Пример #5
0
int MoveDirectory(const char* src_filename, const char* dest_filename)
{
    char src_path[MAXPATH], src_file[MAXPATH];
    char dest_path[MAXPATH],dest_file[MAXPATH];

    char drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILE], ext[MAXEXT];

    SplitPath(src_filename, drive, dir, fname, ext);
    
    strcpy(src_path, drive);
    strcat(src_path, dir);

    strcpy(src_file, fname);
    strcat(src_file, ext);

    SplitPath(dest_filename, drive, dir, fname, ext);

    strcpy(dest_path, drive);
    strcat(dest_path, dir);    

    strcpy(dest_file, fname);
    strcat(dest_file, ext);

    /* DRR: Ensure that I can move a dir to another drive
     * and with another name
     */
    if (stricmp(src_file, dest_file)) {
       strcat(dest_path, dest_file);
       strcat(dest_path, DIR_SEPARATOR);
       strcpy(dest_file, src_file);
    } 
    if (dir_exists(dest_filename))
        if (!DelTree(dest_filename))
	    return 0;

    if (!CopyTree(src_path, src_file, dest_path, dest_file))
    {
	DelTree(dest_filename);	
	return 0;
    }

    return DelTree(src_filename);
}
Пример #6
0
///////////////////////////////////////////////////////////////
//
// CServerIdManagerImpl::CServerIdManagerImpl
//
//
//
///////////////////////////////////////////////////////////////
CServerIdManagerImpl::CServerIdManagerImpl ( void )
{
    // Calc private dir root
    m_strServerIdLookupBaseDir = PathJoin ( g_pClientGame->GetFileCacheRoot(), MTA_SERVERID_LOOKUP_DIR );
    MakeSureDirExists ( PathJoin ( m_strServerIdLookupBaseDir, "" ) );

    // Calc temp dir path incase of server id error
    m_strTempErrorDir = PathJoin ( m_strServerIdLookupBaseDir, "_error" );

    // If temp dir has been used, clean it
    if ( DirectoryExists ( m_strTempErrorDir ) )
        DelTree ( m_strTempErrorDir, m_strServerIdLookupBaseDir );

    LoadServerIdMap ();
}
Пример #7
0
void XLFileUtil::DelTree(const std::string &path)
{
	auto pathname = XLStringUtil::pathseparator(path);
	#ifdef _WINDOWS
		if (pathname == "c:\\") return ;
		if (pathname == "C:\\") return ;
	#else
		if (pathname == "/") return ;
	#endif
	if (pathname == "") return ;
	//とりあえずセーフティかけとくかw
	if (pathname.size() <= 7 ) return ;

	if ( Exist(pathname) )
	{//ファイル?
		XLFileUtil::del(pathname);
		if (! Exist(pathname) )
		{
			return ;
		}
	}
	else
	{//ディレクトリかな
		pathname = pathname + PATHSEP;
		if (! Exist(pathname) )
		{//もう存在しないらしい
			return ;
		}
	}

	//pathnameはディレクトリ /終端 が入っている。
	//ディレクトリを巡回しながら消していく
	findfile(pathname , [&](const std::string& filename,const std::string& fullfilename) -> bool{
		auto dirname = fullfilename + PATHSEP;
		if (Exist(dirname) )
		{//ディレクトリなので再帰する
			DelTree(fullfilename);
		}
		else
		{
			del(fullfilename);
		}
		return true;
	});

}
Пример #8
0
/* ======================================================================= */
BOOL PrepareBasePath(PWINDOWHANDLES H, PCHAR BasePath)
{
  if(CreateDirectory(BasePath, NULL) == 0)
  {
    DWORD ErrorCode = GetLastError();
    if(ErrorCode == ERROR_ALREADY_EXISTS)
    {
      switch(MessageBoxF(H->WH, WindowName, MB_ICONEXCLAMATION | MB_YESNOCANCEL, "The directory %s already exists which means you may have already dumped this CD-ROM already. Do you want to continue anyway?\n\nClick the YES button to delete the directory and all of its' contents.\nClick the NO button to leave the directory intact and only overwrite existing files.\nClick the CANCEL button to terminate the program and do nothing.", BasePath))
      {
        case IDCANCEL:
        {
          return FALSE;
        }
        case IDNO:
        {
          break;
        }
        case IDYES:
        {
          INT ErrorCode = DelTree(H->WH, BasePath);
          if(ErrorCode != S_OK)
            Log(LOG_WRITE, "Error code %08x removing the base path", ErrorCode);
          else
            Log(LOG_WRITE, "The base path was successfully deleted");
          if(CreateDirectory(BasePath, NULL) == FALSE)
            Log(LOG_WRITE, "Error code %08x re-creating the base path", GetLastError());
          else
            Log(LOG_WRITE, "Re-created the base path");
          break;
        }
      }
    }
    else
    {
      Log(LOG_WRITE, "Error %u creating the base path", ErrorCode);
      return FALSE;
    }
  }
  else Log(LOG_WRITE, "Created the base path successfully");
  return TRUE;
}
Пример #9
0
bool TParser::Compile(char *_expr)
{
   pos = 0;
   expr = _expr;
   *curToken = '\0';
   if(root!=NULL)
   {
      DelTree(root);
      root = NULL;
   }

   history.clear();

   GetToken();
   if(typToken==PARSER_END) SendError(2);
   root = Expr();
   if(typToken!=PARSER_END) SendError(3);

   history.clear();

   return true;
}
Пример #10
0
bool TParser::Compile(CString _expr, NSGuidesOdp::CFormulaManager& pFManager)
{
   pos = 0;
   expr = _expr;
   curToken = _T("");
   if(root!=NULL)
   {
      DelTree(root);
      root = NULL;
   }

   history.clear();
   CString strTempString(_T("+-*/%^,"));
   while(strTempString.Find(expr[0]) >= 0) expr.Delete(0);

   GetToken();
   if(typToken==PARSER_END) SendError(2);
   root = Expr(pFManager);
   if(typToken!=PARSER_END) SendError(3);

   history.clear();

   return true;
}
Пример #11
0
int RenameTree(const char* src_filename, const char* dest_filename)
{    
    int found, attrib;
    char temppath[MAXPATH];
    char temppath1[MAXPATH];
    char origpath[MAXPATH];
    char tgtpath[MAXPATH];
    char tgtpath1[MAXPATH];
    
    struct ffblk info;

    char srcdrive[MAXDRIVE], srcdir[MAXDIR], srcfname[MAXFILE], srcext[MAXEXT];
    char dstdrive[MAXDRIVE], dstdir[MAXDIR], dstfname[MAXFILE], dstext[MAXEXT];
 
    /* If the target directory exists, delete it */
    if (dir_exists(dest_filename))
    {    
       if (!DelTree(dest_filename))
	  return 0;
    }
        
    /* First see wether we are not renaming a directory in the same path */
    
    SplitPath(src_filename, srcdrive, srcdir, srcfname, srcext);
    SplitPath(dest_filename, dstdrive, dstdir, dstfname, dstext);
    
    if ((strcmpi(srcdir, dstdir) == 0) &&
	(!dir_exists(dest_filename)))
    {
	return rename(src_filename, dest_filename) == 0;
    }
    
    /* Deep renaming a directory */
    strcpy(temppath, src_filename);
    strcpy(origpath, src_filename);
    GetPreviousDir(origpath);

    strcpy(tgtpath, dest_filename);
    if (mkdir(tgtpath) == -1)
	return 0;   

    /* Two state machine: */
    
    /* As long as the complete tree is not deleted */
    AddAllWildCard(origpath);
    AddAllWildCard(temppath);
    while (strcmp(temppath, origpath) != 0)
    {
          /* 1) as long as there are still sub directories, enter the
                first one */
	  found = findfirst(temppath, &info, FA_DIREC) == 0;
	  while (found &&
		 (info.ff_name[0] == '.' ||
		  (info.ff_attrib & FA_DIREC) == 0))
	  {
	     found = findnext(&info) == 0;
	  }

	  if (found)
	  {
	     GetIndividualFile(temppath1, temppath, info.ff_name);
	     strcpy(temppath, temppath1);
             AddAllWildCard(temppath);
	      
	     /* Make sure the target directory exists */	      
	     addsep(tgtpath); 
	     strcat(tgtpath, info.ff_name);
	      
	     if (mkdir(tgtpath) == -1)
		 return 0;
	  }

          /* 2) if there are no more sub directories in this directory, rename
                all the files and leave this directory, and delete this directory */
	  else
          {
	      found = findfirst(temppath, &info, FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCH) == 0;
	      while (found)
	      {
		  GetIndividualFile(temppath1, temppath, info.ff_name);
      
		  strcpy(tgtpath1, tgtpath);
		  addsep(tgtpath1);
		  strcat(tgtpath1, info.ff_name);

		  unlink(tgtpath1);

		  if (rename(temppath1, tgtpath1) == -1)
		      return 0;

		  found = findnext(&info) == 0;
	      }
	
	      GetPreviousDir(temppath);	/* Strip *.* */

              /* DRR: FreeDOS cannot set attributes of directory without
               * clearing directory bit (but the directory will not be 
               * changed to a normal file)
               */
              if ((attrib = _chmod(temppath, 0)) == -1)
                 return 0;
              attrib &= ~FA_RDONLY;
              if (_chmod(temppath, 1, attrib & ~FA_DIREC) == -1)
	         return 0;

	      if (rmdir(temppath) == -1)
	         return 0;
	    
	      
	      GetPreviousDir(temppath);       /* Leave directory */
              AddAllWildCard(temppath);
	      
	      GetPreviousDir(tgtpath);        /* Leave target directory */
	}
    }
    
    return 1;    
}
Пример #12
0
///////////////////////////////////////////////////////////////////////////////
//
// ~TMarcRecord
//
///////////////////////////////////////////////////////////////////////////////
TMarcRecord::~TMarcRecord()
{
    DelTree();
}
Пример #13
0
///////////////////////////////////////////////////////////////////////////////
//
// ToXMLString
//
///////////////////////////////////////////////////////////////////////////////
int TMarcRecord::ToXMLString(typestr &a_xml)
{
    a_xml = "<record";
    if (!mStateManager->GetOutputXMLRecordFormat().is_empty())
    {
        a_xml.append(" format=\"");
        a_xml.append(mStateManager->GetOutputXMLRecordFormat());
        a_xml.append_char('\"');
    }
    if (!mStateManager->GetOutputXMLRecordType().is_empty())
    {
        a_xml.append(" type=\"");
        a_xml.append(mStateManager->GetOutputXMLRecordType());
        a_xml.append_char('\"');
    }
    a_xml.append(">\n");

    a_xml.append("  <leader>");
    a_xml.append(escape_xml(itsLeader));
    a_xml.append("</leader>\n");

    TMarcField *field = itsFirstField;
    while (field)
    {
        const char *tag = field->GetTag();
        const char *marcdata = field->GetLib1();
        size_t lng = strlen(marcdata);
        bool have_ind = IsFieldWithIndicators(OUTPUT, tag, marcdata, lng);
        if (!have_ind)
        {
            a_xml.append("  <controlfield tag=\"");
            a_xml.append(tag);
            a_xml.append("\">");
            a_xml.append(escape_xml(marcdata));
            a_xml.append("</controlfield>\n");
        }
        else
        {
            char *indicators = field->GetIndicators();
            a_xml.append("  <datafield tag=\"");
            a_xml.append(escape_xml(tag));
            a_xml.append("\" ind1=\"");
            char ind1[2] = {indicators[0], '\0'};
            char ind2[2] = {indicators[1], '\0'};
            a_xml.append(*ind1 ? escape_xml(ind1) : " ");
            a_xml.append("\" ind2=\"");
            a_xml.append(*ind2 ? escape_xml(ind2) : " ");
            a_xml.append("\">\n");

            const char *p = strchr(marcdata, START_OF_FIELD);
            while (p)
            {
                char code = p[1];
                typestr subfield = p + 2;
                char *end = strchr(subfield.str(), START_OF_FIELD);
                if (end)
                    *end = '\0';

                a_xml.append("    <subfield code=\"");
                char codestr[2] = {code, '\0'};
                a_xml.append(escape_xml(codestr));
                a_xml.append("\">");
                a_xml.append(escape_xml(subfield));
                a_xml.append("</subfield>\n");

                p = strchr(p + 1, START_OF_FIELD);
            }

            a_xml.append("  </datafield>\n");
        }

        field = field->GetNextField();
    }
    a_xml.append("</record>\n");

    DelTree();

    return 0;
}
Пример #14
0
///////////////////////////////////////////////////////////////////////////////
//
// ToString
//
///////////////////////////////////////////////////////////////////////////////
int TMarcRecord::ToString(typestr & a_marcstr)
{
    typestr directory;
    typestr data;

    size_t pos_data = 0;

    TMarcField *field = itsFirstField;
    while (field != NULL)
    {
        char *tag = field->GetTag();
        char *marcdata = field->GetLib1();

        char temps[20];
        size_t lng = strlen(marcdata);
        bool have_ind = IsFieldWithIndicators(OUTPUT, tag, marcdata, lng);
        if (!have_ind)
            sprintf(temps, "%s%04d%05d", tag, lng+1 < 9999 ? int(lng+1) : 9999, pos_data < 99999 ? int(pos_data) : 99999);
        else
            sprintf(temps, "%s%04d%05d", tag, lng+3 < 9999 ? int(lng+3) : 9999, pos_data < 99999 ? int(pos_data) : 99999);

        directory += temps;

        if (have_ind)
        {
            // There must be two indicators
            char *indicators = field->GetIndicators();
            if (*indicators && *(indicators + 1))
              data += indicators;
            else
              data += "  ";
            pos_data += 2;
        }
        data += marcdata;
        data += END_OF_FIELD;
        pos_data += lng + 1;

        field = field->GetNextField();
    }

    a_marcstr = "";
    a_marcstr.append(itsLeader, 24);
    while (strlen(a_marcstr.str()) < 24)
        a_marcstr += ' ';

    a_marcstr += directory + END_OF_FIELD;
    a_marcstr += data + END_OF_RECORD;

    // Set total length of the record to the leader
    char temps[20];
    sprintf(temps, "%05u", strlen(a_marcstr.str()));
    memcpy(a_marcstr.str(), temps, 5);

    // Set base address of data to the leader
    sprintf(temps, "%05u", 24 + strlen(directory.str()));
    memcpy(&a_marcstr.str()[12], temps, 5);

    DelTree();

    return 0;
}
Пример #15
0
///////////////////////////////////////////////////////////////////////////////
//
// FromXMLString
//
///////////////////////////////////////////////////////////////////////////////
int TMarcRecord::FromXMLString(typestr & a_xml)
{
    // Delete previous content
    DelTree();

    typestr xml = a_xml;

    TMarcField *field, *lastfield;

    while (true)
    {
        typestr tag, attribs, content, remainder;
        if (!get_tag(xml, tag, attribs, content, remainder))
            return mStateManager->SetErrorD(1050, ERROR, xml.str());
        if (tag == "record")
        {
            xml = content;
            while (true)
            {
                if (!get_tag(xml, tag, attribs, content, remainder))
                {
                    if (!itsFirstField)
                        return mStateManager->SetErrorD(1050, ERROR, xml.str());
                    break;
                }

                xml = remainder;

                if (tag == "leader")
                {
                    content = unescape_xml(content);
                    size_t len = strlen(content.str());
                    for (size_t i = len; i < 24; i++)
                        content.append_char(' ');
                    memcpy(itsLeader, content.str(), 24);
                }
                else if (tag == "controlfield" || tag == "datafield")
                {
                    if ((field = new TMarcField()) == NULL)
                        return mStateManager->SetError(9041,FATAL);
                    if (!itsFirstField)
                    {
                        itsFirstField = field;
                    }
                    else
                    {
                        lastfield->SetNextField(field);
                    }
                    lastfield = field;

                    field->SetTag(get_attrib("tag", attribs).str());

                    if (tag == "datafield")
                    {
                        field->SetI1(*get_attrib("ind1", attribs).str());
                        field->SetI2(*get_attrib("ind2", attribs).str());

                        typestr field_data;
                        typestr subfield;
                        while (get_tag(content, tag, attribs, subfield, remainder))
                        {
                            content = remainder;
                            if (tag == "subfield")
                            {
                                field_data += START_OF_FIELD;
                                field_data += get_attrib("code", attribs);
                                field_data += unescape_xml(subfield);
                            }
                        }
                        field->SetLib1(field_data.str());
                    }
                    else
                    {
                        field->SetLib1(unescape_xml(content).str());
                        if (strcmp(field->GetTag(), "001") == 0)
                        {
                            strncpy(m_recordId, field->GetLib1(), 50);
                            m_recordId[50] = '\0';
                        }
                    }

                }
            }
            break;
        }
    }

    return 0;
}
Пример #16
0
///////////////////////////////////////////////////////////////////////////////
//
// FromString
//
///////////////////////////////////////////////////////////////////////////////
int TMarcRecord::FromString(char* MarcString)
{
    unsigned long       lngchamp,
                        debutdata,
                        pos,
                        dd,
                        posdata;
    char                cdebutdata[6],
                        temp[6];
    TMarcField          *champ;

    // Delete existing tree
    DelTree();

    *m_recordId = '\0';

    // Leader
    memcpy(itsLeader, MarcString, 24);
    itsLeader[24]=0;

    // On isole l'adresse de d‰but des donn‰es
    memcpy(cdebutdata,&itsLeader[12],5);
    cdebutdata[5]=0;
    if (Val(cdebutdata,&debutdata))
        return mStateManager->SetErrorD(1007,FATAL,cdebutdata);
    pos=24;

    // On va maintenant renseigner les differents champs
    if ((itsFirstField = new TMarcField()) == NULL)
        return mStateManager->SetError(9041,FATAL);
    champ=itsFirstField;

    // Lecture du tag du champs
    memcpy(temp,&MarcString[pos],3);
    temp[3]=0;
    if (champ->SetTag(temp))
        return mStateManager->SetErrorD(1101,ERROR,temp);
    pos+=3;

    // Lecture de sa longueur
    memcpy(temp,&MarcString[pos],4);
    temp[4]=0;
    if (Val(temp,&lngchamp))
        return mStateManager->SetErrorD(1004,ERROR,temp);
    pos += 4;

    // Lecture de sa position
    memcpy(temp,&MarcString[pos],5);
    temp[5]=0;
    if (LongVal(temp,&posdata))
        return mStateManager->SetErrorD(1007,ERROR,temp);
    pos += 5;

    // on remplit le premier champ
    // on alloue de la memoire pour le libelle
    dd=(long)debutdata+posdata;
    if (IsFieldWithIndicators(INPUT,champ->GetTag(),&MarcString[dd],lngchamp))
    {
        champ->SetI1(MarcString[dd++]);
        champ->SetI2(MarcString[dd++]);
        lngchamp-=2;
    }

    champ->SetLib1(&MarcString[dd],(unsigned int)lngchamp-1);

    if (strcmp(champ->GetTag(), "001") == 0)
    {
        strncpy(m_recordId, champ->GetLib1(), 50);
        m_recordId[50] = '\0';
    }

    while (MarcString[pos] != '\x1E')  // end of directory
    {
        champ->SetNextField(new TMarcField());
        if (champ->GetNextField()==NULL)
            return mStateManager->SetError(9041,ERROR);
        champ = champ->GetNextField();

        // Lecture du tag du champs
        memcpy(temp,&MarcString[pos],3);
        temp[3]=0;
        if (champ->SetTag(temp))
            return mStateManager->SetErrorD(1101,ERROR,temp);
        pos+=3;

        // Lecture de sa longueur
        memcpy(temp,&MarcString[pos],4);
        temp[4]=0;
        if (Val(temp,&lngchamp))
            return mStateManager->SetErrorD(1004,ERROR,temp);
        pos += 4;

        // Lecture de sa position
        memcpy(temp,&MarcString[pos],5);
        temp[5]=0;
        if (LongVal(temp,&posdata))
            return mStateManager->SetErrorD(1007,ERROR,temp);
        pos += 5;

        // on remplit le champ
        // on alloue de la memoire pour le libelle
        dd=(long)debutdata+posdata;
        if (IsFieldWithIndicators(INPUT,champ->GetTag(),&MarcString[dd],lngchamp))
        {
            champ->SetI1(MarcString[dd++]);
            champ->SetI2(MarcString[dd++]);
            lngchamp-=2;
        }
        if (lngchamp < 1)
        {
            // A broken record
            lngchamp = 1;
        }

        champ->SetLib1(&MarcString[dd],(unsigned int)lngchamp-1);

        if (strcmp(champ->GetTag(), "001") == 0)
        {
            strncpy(m_recordId, champ->GetLib1(), 50);
            m_recordId[50] = '\0';
        }
    }

    champ->SetNextField(NULL);
    return 0;
}