// Lookup the other table involved in this RI relationship,
// and find the other constraint in the other NATable constraint list.
// I.e., if called by a UniqueConstraint, this looks in the referencing table's
// refConstraints to find the FK constraint passed in riInfo;
// if called by a RefConstraint, this looks in the referenced table's
// uniqueConstraints to find the UC constraint passed in riInfo.
//
AbstractRIConstraint *AbstractRIConstraint::findConstraint(
				  BindWA *bindWA,
				  const ComplementaryRIConstraint &riInfo) const
{
  // Lookup errors should be impossible, due to Ansi transaction semantics
  // during compilation of a query, so no need for fancy diags, just assert
  // (should only happen if catalog corrupt or txn seriously haywire)

  CorrName tempName(riInfo.tableName_);
  NATable *naTable = bindWA->getNATable(tempName, FALSE);
  if (!naTable) return NULL;

  const AbstractRIConstraintList otherConstraints =
    (getOperatorType() == ITM_UNIQUE_CONSTRAINT) ?
      naTable->getRefConstraints() : naTable->getUniqueConstraints();

  // The find() from Collections template doesn't work for us, so roll our own
  AbstractRIConstraint *c;
  for (CollIndex i = 0; i < otherConstraints.entries(); i++)
  {
    c = otherConstraints[i];
    if (c->getConstraintName() == riInfo.constraintName_) return c;
  }
  *CmpCommon::diags() << DgSqlCode(-4353)
        << DgTableName(naTable->getTableName().getQualifiedNameAsAnsiString()) ;
  bindWA->setErrStatus();
  return NULL;

} // AbstractRIConstraint::findConstraint
Beispiel #2
0
QString CJobRunner::fileName(const KUrl &url)
{
    if(url.isLocalFile())
        return url.toLocalFile();
    else
    {
        KUrl local(KIO::NetAccess::mostLocalUrl(url, 0L));

        if(local.isLocalFile())
            return local.toLocalFile(); // Yipee! no need to download!!
        else
        {
            // Need to do actual download...
            if(!itsTempDir)
            {
                itsTempDir=new KTempDir(KStandardDirs::locateLocal("tmp", "fontinst"));
                itsTempDir->setAutoRemove(true);
            }

            QString tempName(itsTempDir->name()+QChar('/')+Misc::getFile(url.path()));
            if(KIO::NetAccess::download(url, tempName, 0L))
                return tempName;
            else
                return QString();
        }
    }
}
bool SelectionVOI::populateXMLNode( wxXmlNode *pCurNode, const wxString &rootPath )
{
    bool result( SelectionObject::populateXMLNode( pCurNode, rootPath ) );
    
    if( result )
    {
        wxString floatPrecision = wxT( ".8" );
        
        wxXmlNode *pVoiNode = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "voi_properties" ) );
        pCurNode->AddChild( pVoiNode );
        
        pVoiNode->AddAttribute( new wxXmlAttribute( wxT( "gen_threshold" ), wxStrFormat( m_generationThreshold, floatPrecision ) ) );
        pVoiNode->AddAttribute( new wxXmlAttribute( wxT( "thres_op_type" ), Helper::getThresholdingTypeString( m_thresType ) ) );
        
        wxXmlNode *pVoiGenAnatPath = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "generation_anatomy" ) );
        pVoiNode->AddChild( pVoiGenAnatPath );
        
        // Get the dataset to be able to get the index.
        DatasetInfo *pDS = DatasetManager::getInstance()->getDataset( m_sourceAnatIndex );
        if( pDS )
        {
            wxFileName tempName( pDS->getPath() );
            tempName.MakeRelativeTo( rootPath );
            pVoiGenAnatPath->AddChild( new wxXmlNode( NULL, wxXML_TEXT_NODE, wxT( "path"), tempName.GetFullPath() ) );
        }
        else
        {
            // Should never happen.
            result = false;
        }
    }
    
    return result;
}
void FunctionDefinitionNode::declareFunction( SymbolTable* _table )
{

	FunctionType* t = new FunctionType();

	std::string tempName("retVal");

	BuiltinType* returnType = new BuiltinType( Type::Int );

	Symbol* returnValue;

	returnValue = _table->getSymbolInfo( tempName , false ).symbol;

	//t->setReturnType( new BuiltinType( Type::Int ) );

	if( !returnValue )

		returnValue = new Symbol( std::string("retVal"),  *new SymbolLocation() , returnType , Symbol::LOCAL );

	t->returnSymbol = returnValue;

	calculateSymbolAddresses( _table , t );

	//Symbol* functionSymbol = declarator->nodeData->result;
	Symbol* functionSymbol = declarator->nodeData->result;

	functionSymbol->symbolType = t;

}
std::string FontAtlasCache::generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField)
{
    std::string tempName(fontFileName);
    
    switch (theGlyphs)
    {
        case GlyphCollection::DYNAMIC:
            tempName.append("_DYNAMIC_");
        break;
            
        case GlyphCollection::NEHE:
            tempName.append("_NEHE_");
            break;
            
        case GlyphCollection::ASCII:
            tempName.append("_ASCII_");
            break;
            
        case GlyphCollection::CUSTOM:
            tempName.append("_CUSTOM_");
            break;
            
        default:
            break;
    }
    if(useDistanceField)
        tempName.append("df");
    // std::to_string is not supported on android, using std::stringstream instead.
    std::stringstream ss;
    ss << size;
    return  tempName.append(ss.str());
}
void Aggregate::merger() {

    // Just sleep for a while
    // Only for syncronization in main loop
    boost::this_thread::sleep(boost::posix_time::millisec(500));

    // If total size downloaded isn't equal
    // to the size of file downloaded then
    // do not merge the Chunks
    if( m_filesize != bytesTotal())
        Throw(ex::Error,"Downloaded bytes greater than total filesize.");

    fancyprint("Merging!",NOTIFY);
    fancyprint("Do not close this window.",WARNING);
    File tmp(tempName());
    tmp.write(Node::FORCE);
    // TODO try binary appends and storing to "tmp"
    // Append the content to "tmp"
    for(unsigned i=0; i < m_chunk.size(); i++){
        print(i+1 << " of " << m_chunk.size());
        tmp.append(*(m_chunk[i]->file()));
        std::cout << DELETE;
    }
    std::cout << DELETE;
    tmp.move(prettyName(),Node::NEW);
    // Remove the old directory
    Directory(m_hashedUrl).remove(Node::FORCE);

    fancyprint("Complete!",SUCCESS);
}
Beispiel #7
0
bool FileManager::Save(const wxString& name, const char* data, size_t len)
{
    if(wxFileExists(name) == false) // why bother if we don't need to
    {
        wxFile f(name, wxFile::write);
        if(!f.IsOpened())
            return false;
        return f.Write(data, len);
    }

    if(platform::windows) // work around broken Windows readonly flag
    {
        wxFile f;
        if(!f.Open(name, wxFile::read_write))
            return false;
    }

    wxString tempName(name + _T(".cbTemp"));
    do
    {
        if( !wxCopyFile(name, tempName) )
        {
            return false;
        }

        wxFile f(name, wxFile::write);
        if ( !f.IsOpened() )
        {
            return false;
        }
        if(f.Write(data, len) != len)
        {
            f.Close();
            // Keep the backup file as the original file has been destroyed
            //wxRemoveFile(tempName);
            return false;
        }

        f.Close();

    }while(false);

    if (Manager::IsAppShuttingDown())
    {
        // app shut down, forget delayed deletion
        wxRemoveFile(tempName);
    }
    else
    {
        // issue a delayed deletion of the back'd up (old) file
        delayedDeleteThread.Queue(new DelayedDelete(tempName));
    }

    return true;
}
Beispiel #8
0
bool FileManager::Save(const wxString& name, const wxString& data, wxFontEncoding encoding, bool bom)
{
    if(wxFileExists(name) == false) // why bother if we don't need to
    {
        wxFile f(name, wxFile::write);
        if(!f.IsOpened())
            return false;
        return WriteWxStringToFile(f, data, encoding, bom);
    }

    if(platform::windows)
    {
        wxFile f;
        if(!f.Open(name, wxFile::read_write))
            return false;
    }

    wxString tempName(name + _T(".cbTemp"));
    do
    {
        if (!wxCopyFile(name, tempName))
        {
            return false;
        }

        wxFile f(name, wxFile::write);
        if ( !f.IsOpened() )
        {
            return false;
        }
        if(WriteWxStringToFile(f, data, encoding, bom) == false)
        {
            f.Close();
            // Keep the backup file as the original file has been destroyed
            //wxRemoveFile(tempName);
            return false;
        }

        f.Close();

    }while(false);

    if (Manager::IsAppShuttingDown())
    {
        // app shut down, forget delayed deletion
        wxRemoveFile(tempName);
    }
    else
    {
        // issue a delayed deletion of the back'd up (old) file
        delayedDeleteThread.Queue(new DelayedDelete(tempName));
    }
    return true;
}
//------------------------------------------------------------------------------
void vtkAMRSimPlaParticlesReader::ReadMetaData()
{
    if (this->Initialized)
    {
        return;
    }

    if (!this->FileName)
    {
        vtkErrorMacro("No FileName set!");
        return;
    }

   this->m_pimpl_->SetFileName(this->FileName);
    std::string tempName(this->FileName);
    std::string bExtName(".boundary");
    std::string hExtName(".hierarchy");

    if (tempName.length() > hExtName.length() &&
        tempName.substr(tempName.length() - hExtName.length()) == hExtName)
    {
       this->m_pimpl_->MajorFileName =
                tempName.substr(0, tempName.length() - hExtName.length());
       this->m_pimpl_->HierarchyFileName = tempName;
       this->m_pimpl_->BoundaryFileName =
               this->m_pimpl_->MajorFileName + bExtName;
    }
    else if (tempName.length() > bExtName.length() &&
             tempName.substr(tempName.length() - bExtName.length()) == bExtName)
    {
       this->m_pimpl_->MajorFileName =
                tempName.substr(0, tempName.length() - bExtName.length());
       this->m_pimpl_->BoundaryFileName = tempName;
       this->m_pimpl_->HierarchyFileName =
               this->m_pimpl_->MajorFileName + hExtName;
    }
    else
    {
        vtkErrorMacro("SimPla file has invalid extension!");
        return;
    }

   this->m_pimpl_->DirectoryName =
            GetSimPlaDirectory(this->m_pimpl_->MajorFileName.c_str());

   this->m_pimpl_->ReadMetaData();
   this->m_pimpl_->CheckAttributeNames();

    this->NumberOfBlocks =this->m_pimpl_->NumberOfBlocks;
    this->Initialized = true;

    this->SetupParticleDataSelections();
}
Beispiel #10
0
HRESULT COpenCallbackGUI::CryptoGetTextPassword(BSTR *password)
{
    if (!PasswordIsDefined)
    {
        CPasswordDialog dialog;
        if (dialog.Create(ParentWindow) == IDCANCEL)
            return E_ABORT;
        Password = dialog.Password;
        PasswordIsDefined = true;
    }
    CMyComBSTR tempName(Password);
    *password = tempName.Detach();
    return S_OK;
}
bool
FileDBufRequester::writeToFile(const MC2SimpleString& descr,
                               BitBuffer* buffer)
{
   MC2SimpleString fullFileName(getFileName(descr));

   {
      FILE* readFile = fopen(fullFileName.c_str(), "r");
      if ( readFile != NULL ) {
         // Already there
         mc2dbg8 << "[FDBR]: " << descr << " already on disk" << endl;
         fclose(readFile);
         return true;
      }
   }
#if defined (__unix__) || defined (__MACH__)
#define USE_TEMP_FILE
#endif
   
#ifdef USE_TEMP_FILE
   // Make temporary file in the same dir. (For e.g. server
   // to avoid two threads writing to the same file).
   char tempTemplate[1024];   
   sprintf(tempTemplate, "%stilecachXXXXXX", m_path.c_str());
   int tmpDesc = mkstemp(tempTemplate);
   MC2SimpleString tempName(tempTemplate);
   FILE* file = fdopen(tmpDesc, "w");
#else
   // Write directly to the file
   FILE* file = fopen(fullFileName.c_str(), "w");
#endif
      
   if ( file && (fwrite(buffer->getBufferAddress(),
                        buffer->getBufferSize(), 1, file) == 1 ) ) {
      mc2dbg8 << "[FDBR]: Wrote " << descr << " to disk" << endl;
#ifdef USE_TEMP_FILE
      // Rename the file to the correct name and hope it works.
      rename(tempName.c_str(), fullFileName.c_str());
#endif
      fclose(file);            
      file = NULL;
      return true;
   }
   if ( file ) {
      fclose(file);
   }
   return false;
}
Beispiel #12
0
TPalette::TPalette()
    : m_version(0)
    , m_isCleanupPalette(false)
    , m_currentFrame(-1)
    , m_dirtyFlag(false)
    , m_mutex(QMutex::Recursive)
    , m_isLocked(false)
    , m_askOverwriteFlag(false)
    , m_shortcutScopeIndex(0) {
  QString tempName(QObject::tr("colors"));
  std::wstring pageName = tempName.toStdWString();
  Page *page            = addPage(pageName);
  page->addStyle(TPixel32(255, 255, 255, 0));
  page->addStyle(TPixel32(0, 0, 0, 255));
  getStyle(0)->setName(L"color_0");
  getStyle(1)->setName(L"color_1");

  for (int i = 0; i < 10; i++) m_shortcuts['0' + i] = i;
}
Beispiel #13
0
        void readConfig()
        {
            wxString fileName = MainFrame::getConfigFileName();
            wxXmlDocument xmlFile;
            if ( !xmlFile.Load(fileName, wxString("UTF-8")) )
                return;
            wxXmlNode *root = xmlFile.GetRoot();
            if (root == NULL)
                return;
            //Not really necessary:
            //if (root->GetName() != wxString("miniBloq"))
            //    return;

            bool mainFrameRead = false;
            bool hardRead = false;
            wxString tempName("");
            wxXmlNode *rootChild = root->GetChildren();
            while (rootChild)
            {
                tempName = rootChild->GetName();
                if (tempName == wxString("mainFrame"))
                {
                    wxXmlNode *child = rootChild->GetChildren();
                    while (child)
                    {
                        if (child->GetName() == "x")
                        {
                            wxString returnStringValue = child->GetNodeContent();
                            long returnNumericValue = 0;
                            if (returnStringValue.ToLong(&returnNumericValue))
                                initialFrameX = (int)returnNumericValue;
                        }
                        else if (child->GetName() == "y")
                        {
                            wxString returnStringValue = child->GetNodeContent();
                            long returnNumericValue = 0;
                            if (returnStringValue.ToLong(&returnNumericValue))
                                initialFrameY = (int)returnNumericValue;
                        }
                        else if (child->GetName() == "width")
                        {
                            wxString returnStringValue = child->GetNodeContent();
                            long returnNumericValue = 1280;
                            if (returnStringValue.ToLong(&returnNumericValue))
                                initialFrameWidth = (int)returnNumericValue;
                        }
                        else if (child->GetName() == "height")
                        {
                            wxString returnStringValue = child->GetNodeContent();
                            long returnNumericValue = 800;
                            if (returnStringValue.ToLong(&returnNumericValue))
                                initialFrameHeight = (int)returnNumericValue;
                        }
                        else if (child->GetName() == "maximized")
                        {
                            maximized = Bubble::string2bool(child->GetNodeContent());
                        }
                        else if (child->GetName() == "centered")
                        {
                            centered = Bubble::string2bool(child->GetNodeContent());
                        }

                        child = child->GetNext();
                    }
                    mainFrameRead = true; //Optimization.
                }
                else if (tempName == wxString("hard"))
                {
                    wxXmlNode *child = rootChild->GetChildren();
                    while (child)
                    {
                        if (child->GetName() == "board")
                        {
                            strBoard = child->GetNodeContent();
                        }
                        child = child->GetNext();
                    }
                    hardRead = true; //Optimization.
                }

                if (mainFrameRead && hardRead) //Optimization.
                    break;

                rootChild = rootChild->GetNext();
            }
        }
Beispiel #14
0
QByteArray getTempFileName(QByteArray fileName, int page)
{
    QByteArray tempName(fileName);
    tempName.append(QString("[%1].temp").arg(page+1));
    return tempName;
}
Beispiel #15
0
QString File::displayName() const {
    return m_path.isEmpty() ? tempName() : name();
}
Beispiel #16
0
TemporaryFile::TemporaryFile(const std::string& tempDir): 
	File(tempName(tempDir)), 
	_keep(false)
{
}
Beispiel #17
0
TemporaryFile::TemporaryFile(): 
	File(tempName()), 
	_keep(false)
{
}