Beispiel #1
0
int CFileName::FindFiles (LPCTSTR pszDir,CFileNameArray &ar,LPCTSTR pszPattern/*=_T("*.*")*/,bool bRecurse/*=true*/,DWORD dwExclude/*=FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN*/)
{
  ar.RemoveAll();
  CFileFind finder;
  BOOL bMore=finder.FindFile(CFileName(pszDir)+pszPattern);
  while (bMore)    {
    bMore = finder.FindNextFile();
    if(!finder.IsDots() && !finder.MatchesMask(dwExclude)){
      CFileName strFile(finder.GetFilePath());
      ar.Add(strFile);
    }
  }
  if(bRecurse){
    CFileFind finder;
    BOOL bMore=finder.FindFile(CFileName(pszDir)+_T("*.*"));
    while (bMore)    {
      bMore = finder.FindNextFile();
      if(!finder.IsDots() && finder.IsDirectory()){
        CFileNameArray ar2;
        FindFiles(finder.GetFilePath(),ar2,pszPattern,bRecurse,dwExclude);
        ar.Append(ar2);
      }
    }
  }
  return ar.GetSize();
}
Beispiel #2
0
bool CVSProcessor::WriteData(void)
{
    int client_id = -1;
    int molid;

    // get client ID --------------------------------
    if(CommandElement->GetAttribute("client_id",client_id) == false) {
        CMD_ERROR(Command,"unable to get client_id");
        return(false);
    }

    if(CommandElement->GetAttribute("molid",molid) == false) {
        CMD_ERROR(Command,"unable to get molid");
        return(false);
    }

    CRegClient* p_client = VSServer.RegClients.FindClient(client_id);

    if(p_client == NULL) {
        CSmallString error;
        error << "unable to find client with id " << client_id;
        CMD_ERROR(Command,error);
        return(false);
    }

    if(p_client->GetClientStatus() != ERCS_REGISTERED) {
        CSmallString error;
        error << "client " << client_id << " is not in active state";
        CMD_ERROR(Command,error);
        return(false);
    }

    //*********** LOCKED DATABASE ACCESS ******************

    VSServer.DBMutex.Lock();

    // update FLAG to 2
    sqlite3_reset(VSServer.P2STM);
    sqlite3_bind_int(VSServer.P2STM,1,molid);

    if( sqlite3_step(VSServer.P2STM) != SQLITE_DONE ){
        CMD_ERROR(Command,"unable to update FLAG to 2");
        VSServer.DBMutex.Unlock();
        return(false);
    }

    VSServer.DBMutex.Unlock();

    //*********** END OF LOCKED DATABASE ACCESS ******************

    // register successfull operation
    p_client->RegisterOperation();

    // write structure if it is present
    CXMLBinData* p_sele = CommandElement->GetFirstChildBinData("STRUCTURE");
    if(p_sele != NULL) {
        CSmallString str_type;
        str_type = "log";
        CommandElement->GetAttribute("type",str_type);

        CFileName molname(VSServer.StructureDir);

        CSmallString smolid;
        smolid.IntToStr(molid,"%08d");

        if(VSServer.UseHiearchy) {
            molname = molname / CFileName(smolid.GetSubString(0,2)) / CFileName(smolid.GetSubString(2,2))
                      / CFileName(smolid.GetSubString(4,2));
        }

        molname = molname / VSServer.UnisID + smolid + "." + str_type;

        FILE* p_fout = fopen(molname,"wb");
        if(p_fout == NULL) {
            CSmallString error;
            error << "unable to open molecule file (" << molname << ")";
            CMD_ERROR(Command,error);
            return(false);
        }

        fwrite(p_sele->GetData(),p_sele->GetLength(),sizeof(char),p_fout);
        fclose(p_fout);
    }

    return(true);
}
Beispiel #3
0
const CFileName CFileName::Head() const
{
  TCHAR *ch=_tcsrchr(m_pchData,cSep);
  return ch?CFileName(m_pchData,ch-m_pchData):m_pchData;
}