Beispiel #1
0
SVFIP VirtualFAT::InsertItem(const char* Dir, SVFIP Item)
{
    SVFIP D;
    SVFIP T;
    SVFIP I;
    char *p, *s;

    D = Root;

    p = my_strdup(Dir);    

    char *fn = ExtractName(Dir);
    while (TRUE){        

        char * t = ExtractRoot(p);
        
        T = GetDir(D, t);

        if (!T) {
            I = (SVFIP)my_malloc(sizeof(SVFI));
            I->FileName      = my_strdup(t);
            I->Description   = my_strdup("<dir>");
            I->Plugin        = my_strdup("");
            I->IsDirectory   = TRUE;
            I->Fmt           = -1;
            I->IsExtension   = FALSE;
            I->Offset        = 0;
            I->LevelUp       = D;
            I->PackedSize    = 0;
            I->UnpackedSize  = 0;
            I->UserData.Data = NULL;
            I->UserData.Size = 0;

            D = InsertItem(D, I);            
        } else D = T;

        s = my_substr(p, lstrlen(t)+1, lstrlen(p));                
        
        if (lstrlen(s)==0){
            my_free(t);
            my_free(p);
            my_free(s);
            my_free(fn);
            
            if (Item->Fmt == FMT_SPEC)
                return D;
            D = InsertItem(D, Item);
            return D;
        }
        my_free(p);
        my_free(t);
        p = s;        
    }
    my_free(p);
    my_free(fn);

    return NULL;
}
void AnimaMappedValues::CopyBooleans(const AnimaMappedValues& src)
{
	_booleansMap.clear();

	const boost::unordered_map<AnimaString, bool, AnimaStringHasher>* srcBooleansMap = &src._booleansMap;
	for (auto pair : *srcBooleansMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetBoolean(propertyName, pair.second);
	}
}
void AnimaMappedValues::CopyIntegers(const AnimaMappedValues& src)
{
	_integersMap.clear();

	const boost::unordered_map<AnimaString, AInt, AnimaStringHasher>* srcIntegersMap = &src._integersMap;
	for (auto pair : *srcIntegersMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetInteger(propertyName, pair.second);
	}
}
void AnimaMappedValues::CopyFloats(const AnimaMappedValues& src)
{
	_floatsMap.clear();

	const boost::unordered_map<AnimaString, AFloat, AnimaStringHasher>* srcFloatsMap = &src._floatsMap;
	for (auto pair : *srcFloatsMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetFloat(propertyName, pair.second);
	}
}
void AnimaMappedValues::CopyMatricesArrays(const AnimaMappedValues& src)
{
	ClearAllMatricesArrays();

	const boost::unordered_map<AnimaString, AnimaArray<AnimaMatrix>*, AnimaStringHasher>* srcMatricesArraysMap = &src._matricesArraysMap;
	for (auto pair : *srcMatricesArraysMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetMatrixArray(propertyName, pair.second);
	}
}
void AnimaMappedValues::CopyVectorsArrays(const AnimaMappedValues& src)
{
	ClearAllVectorsArrays();

	const boost::unordered_map<AnimaString, AnimaArray<AnimaVectorGenerator*>*, AnimaStringHasher>* srcVectorsArraysMap = &src._vectorsArraysMap;
	for (auto pair : *srcVectorsArraysMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetVectorArray(propertyName, pair.second);
	}
}
void AnimaMappedValues::CopyVectors(const AnimaMappedValues& src)
{
	_vectorsMap.clear();

	const boost::unordered_map<AnimaString, AnimaVectorGenerator*, AnimaStringHasher>* srcVectorsMap = &src._vectorsMap;
	for (auto pair : *srcVectorsMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetVector(propertyName, pair.second->GetVector4f());
	}
}
void AnimaMappedValues::CopyTextures(const AnimaMappedValues& src)
{
	_texturesMap.clear();

	const boost::unordered_map<AnimaString, AnimaTextureGenerator*, AnimaStringHasher>* srcTexturesMap = &src._texturesMap;
	for (auto pair : *srcTexturesMap)
	{
		AnimaString propertyName = ExtractName(pair.first);
		SetTexture(propertyName, pair.second);
	}
}
Beispiel #9
0
SVFIP VirtualFAT::GetPath(SVFIP Item, char* PathName)
{
    SVFIP D;
    char *p, *s;

    if (!Item) D = Root;
    else D = Item;

    if (lstrlen(PathName)==0) return Root;

    p = my_strdup(PathName);
    char *fn = ExtractName(PathName);
    while (TRUE){
        char * t = ExtractRoot(p);
        
        D = GetDir(D, t);
        
        if (!D) {
            my_free(t);
            my_free(p);
            my_free(fn);
            return NULL;
        }
        s = my_substr(p, lstrlen(t)+1, lstrlen(p));                
        if (lstrlen(s)==0) {        
            my_free(t);
            my_free(p);
            my_free(s);
            my_free(fn);
            return D;
        }        
        my_free(p);
        my_free(t);        
        p = s;
    }
    my_free(p);
    my_free(fn);
    
    return NULL;
}
ptree AnimaMappedValues::GetObjectTree(bool saveName) const
{
	ptree tree;
	
	if(saveName)
	{
		tree.add("AnimaMappedValues.Name", GetName());
	}
	
	ptree propertiesTree;
	
	for (auto& pair : _texturesMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "texture");
		propertyTree.add_child("Value", pair.second->GetObjectTree(true));

		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _colorsMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "color");
		propertyTree.add_child("Value", pair.second->GetObjectTree(true));
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _vectorsMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "vector");
		propertyTree.add_child("Value", pair.second->GetObjectTree(true));
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _floatsMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "float");
		propertyTree.add("Value", pair.second);
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _booleansMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "bool");
		propertyTree.add("Value", pair.second);
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _matricesMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "matrix");
		propertyTree.add("Value", pair.second);
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	for (auto& pair : _integersMap)
	{
		ptree propertyTree;
		propertyTree.add("Name", ExtractName(pair.first));
		propertyTree.add("Type", "integer");
		propertyTree.add("Value", pair.second);
		
		propertiesTree.add_child("Property", propertyTree);
	}
	
	tree.add_child("AnimaMappedValues.Properties", propertiesTree);
	
	tree.add_child("AnimaMappedValues.NamedObject", AnimaNamedObject::GetObjectTree(false));
	
	return tree;
}
Beispiel #11
0
/*
 * struct fs32_opencreate_parms {
 *     PTR16          pfgenflag;
 *     PTR16          pEABuf;
 *     unsigned short attr;
 *     PTR16          pAction;
 *     unsigned short openflag;
 *     unsigned long  openmode;
 *     PTR16          psffsd;
 *     PTR16          psffsi;
 *     unsigned short iCurDirEnd;
 *     PTR16          pName;
 *     PTR16          pcdfsd;
 *     PTR16          pcdfsi;
 * };
 */
int FS32ENTRY fs32_opencreate(struct fs32_opencreate_parms *parms)
{
    char *pName;
    struct cdfsi32 *pcdfsi;
    union cdfsd32 *pcdfsd;
    struct sffsi32 *psffsi;
    union sffsd32 *psffsd;
    unsigned short *pAction;
    int rc;
    struct super_block *sb;
    struct file *p_file, *dir;
    UINT32 openmode, DOSmode;
    UINT32 accessmode;
    UINT16 newflag, existflag;
    char component[CCHMAXPATH];
    char parent[CCHMAXPATH];
    struct inode *inode;
    struct inode *inode_parent;
    struct inode *base;
    char *tmp;
    ino_t ino_no;

    psffsi = VDHQueryLin(parms->psffsi);
    psffsd = VDHQueryLin(parms->psffsd);
    if (parms->pcdfsi.seg)
        pcdfsi = VDHQueryLin(parms->pcdfsi);
    else
        pcdfsi = 0;
    if (parms->pcdfsd.seg)
        pcdfsd = VDHQueryLin(parms->pcdfsd);
    else
        pcdfsd = 0;
    pName = VDHQueryLin(parms->pName);
    pAction = VDHQueryLin(parms->pAction);

    if (trace_FS_OPENCREATE)
    {
        kernel_printf("FS_OPENCREATE(%s)", pName);
    }


#ifdef FS_TRACE
    if (parms->ulOpenMode & OPEN_FLAGS_DASD)
    {
        fs_log("OPEN_FLAGS_DASD");
    }


    if (parms->ulOpenMode & OPEN_FLAGS_WRITE_THROUGH)
    {
        fs_log("OPEN_FLAGS_WRITE_THROUGH");
    }
    if (parms->ulOpenMode & OPEN_FLAGS_FAIL_ON_ERROR)
    {
        fs_log("OPEN_FLAGS_FAIL_ON_ERROR");
    }
    if (parms->ulOpenMode & OPEN_FLAGS_NO_CACHE)
    {
        fs_log("OPEN_FLAGS_NO_CACHE");
    }
    if (parms->ulOpenMode & OPEN_FLAGS_NOINHERIT)
    {
        fs_log("OPEN_FLAGS_NO_INHERIT");
    }
#endif
    accessmode = parms->ulOpenMode & OPEN_ACCESS_MASK;

    if (accessmode == OPEN_ACCESS_READONLY)
    {
#ifdef FS_TRACE
        fs_log("OPEN_ACCESS_READONLY");
#endif
        openmode = OPENMODE_READONLY;
    }

    if (accessmode == OPEN_ACCESS_WRITEONLY)
    {
#ifdef FS_TRACE
        fs_log("OPEN_ACCESS_WRITEONLY");
#endif
        openmode = OPENMODE_WRITEONLY;
    }

    if (accessmode == OPEN_ACCESS_READWRITE)
    {
#ifdef FS_TRACE
        fs_log("OPEN_ACCESS_READWRITE");
#endif
        openmode = OPENMODE_READWRITE;
    }

#ifdef FS_TRACE
    if (accessmode == OPEN_ACCESS_EXECUTE)
    {
        fs_log("OPEN_ACCESS_EXECUTE");
    }
#endif

    newflag = parms->openflag & OPEN_ACTION_NEW_MASK;

#ifdef FS_TRACE
    if (newflag == OPEN_ACTION_FAIL_IF_NEW)
    {
        fs_log("OPEN_ACTION_FAIL_IF_NEW");
    }
    if (newflag == OPEN_ACTION_CREATE_IF_NEW)
    {
        fs_log("OPEN_ACTION_CREATE_IF_NEW");
    }
#endif

    existflag = parms->openflag & OPEN_ACTION_EXIST_MASK;

#ifdef FS_TRACE
    if (existflag == OPEN_ACTION_OPEN_IF_EXISTS)
    {
        fs_log("OPEN_ACTION_OPEN_IF_EXISTS");
    }
    if (existflag == OPEN_ACTION_FAIL_IF_EXISTS)
    {
        fs_log("OPEN_ACTION_FAIL_IF_EXISTS");
    }
    if (existflag == OPEN_ACTION_REPLACE_IF_EXISTS)
    {
        fs_log("OPEN_ACTION_REPLACE_IF_EXISTS");
    }
#endif

    if ((!Read_Write) &&
        ((accessmode == OPEN_ACCESS_READWRITE) ||
         (accessmode == OPEN_ACCESS_WRITEONLY)))
    {
        fs_log("FS_OPENCREATE() - Write access not enabled");
        return ERROR_WRITE_PROTECT;
    }

    //
    // Direct access open of the whole device
    //
    if (parms->ulOpenMode & OPEN_FLAGS_DASD)
    {
        sb = getvolume(psffsi->sfi_hVPB);
        kernel_printf("OPEN_FLAGS_DASD");
        if ((p_file = _open_by_inode(sb, INODE_DASD, openmode)) == 0)
        {
            kernel_printf("FS_OPENCREATE() - couldn't DASD open %s", pName);
            return ERROR_OPEN_FAILED;
        }
        psffsd->f = p_file;
        psffsi->sfi_tstamp = ST_SCREAT | ST_PCREAT;
        psffsi->sfi_size = p_file->f_inode->i_size;
        psffsi->sfi_position = p_file->f_pos;
        date_unix2dos(p_file->f_inode->i_ctime, &(psffsi->sfi_ctime), &(psffsi->sfi_cdate));
        date_unix2dos(p_file->f_inode->i_atime, &(psffsi->sfi_atime), &(psffsi->sfi_adate));
        date_unix2dos(p_file->f_inode->i_mtime, &(psffsi->sfi_mtime), &(psffsi->sfi_mdate));
        return NO_ERROR;

    }

    //
    // Now that we treated the OPEN_FLAGS_DASD special case, lets treat the general case :
    // Try to open the file readonly
    // Success : the file exists
    //     if !S_ISDIR && !S_ISREG => error
    //     if OPEN_ACTION_FAIL_IF_EXISTS set => error
    //     if OPEN_ACTION_OPEN_IF_EXISTS set
    //         <test file attrs>
    //         change the open mode and return OK
    //     if OPEN_ACTION_REPLACE_IF_EXISTS set
    //         OPEN_ACCESS_READONLY or OPEN_ACCESS_EXECUTE set => error
    //         OPEN_ACCESS_READWRITE or OPEN_ACCESS_WRITEONLY set
    //             truncate
    //             change openmode and return
    // Failure : the file does not exist
    //     OPEN_ACCESS_READONLY or OPEN_ACCESS_EXECUTE set => error
    //     OPEN_ACCESS_READWRITE or OPEN_ACCESS_WRITEONLY set
    //         if OPEN_ACTION_CREATE_IF_NEW set
    //             try to create the file
    //             open the file and return
    //         if OPEN_ACTION_FAIL_IF_NEW   set => error
    rc = ERROR_INVALID_PARAMETER;
    if (parms->iCurDirEnd != CURDIREND_INVALID)
    {
        tmp = pName + parms->iCurDirEnd;
        if ((pcdfsd->u.p_file) && (pcdfsd->u.p_file->f_magic == FILE_MAGIC))
        {
            base = pcdfsd->u.p_file->f_inode;
            if (base)
            {
                sb = base->i_sb;
                rc = NO_ERROR;
            }
        }
    }
    else
    {
        sb = getvolume(psffsi->sfi_hVPB);
        if ((sb) && (sb->s_magic_internal == SUPER_MAGIC))
        {
            tmp = skip_drive(pName);
            base = sb->s_mounted;
            if (base)
            {
                rc = NO_ERROR;
            }
        }
    }

    if (rc != NO_ERROR)
    {
        return rc;
    }

    p_file = open_by_name(base, tmp, openmode);
    if (p_file)
    {                           // The file exists
        //
        // If it's not a regular file or a directory we cannot open
        //

        if (!S_ISREG(p_file->f_inode->i_mode))
        {
//            kernel_printf("Can't FS_OPENCREATE - %s is not a regular file", pName);
            if ((rc = vfs_close(p_file)) != NO_ERROR)
            {
                fs_err(FUNC_FS_OPENCREATE, FUNC_CLOSE, rc, FILE_TEST_C, __LINE__);
                return rc;
            }
            return ERROR_ACCESS_DENIED;
        }
        //
        // if OPEN_ACTION_FAIL_IF_EXISTS set => error
        //
        if (existflag == OPEN_ACTION_FAIL_IF_EXISTS)
        {
#ifdef FS_TRACE
            fs_log("Can't FS_OPENCREATE() - File exists & OPEN_ACTION_FAIL_IF_EXISTS");
#endif
            if ((rc = vfs_close(p_file)) != NO_ERROR)
            {
                fs_err(FUNC_FS_OPENCREATE, FUNC_CLOSE, rc, FILE_TEST_C, __LINE__);
                return rc;
            }
            return ERROR_FILE_EXISTS;
        }

        //
        // if OPEN_ACTION_OPEN_IF_EXISTS : OK
        //
        if (existflag == OPEN_ACTION_OPEN_IF_EXISTS)
        {
            *pAction = FILE_EXISTED;
        }

        //
        // if OPEN_ACTION_REPLACE_IF_EXISTS : truncate
        //
        if (existflag == OPEN_ACTION_REPLACE_IF_EXISTS)
        {
            p_file->f_inode->i_size = psffsi->sfi_size;
            p_file->f_inode->i_op->truncate(p_file->f_inode);
            p_file->f_inode->i_dirt = 1;
            p_file->f_flags = O_TRUNC;
            *pAction = FILE_TRUNCATED;
#if 0
            psffsi->sfi_tstamp = ST_PWRITE | ST_SWRITE;
#else
            /*
             * Time stamping is done by inode routines - Only propagate value.
             */
            psffsi->sfi_tstamp = ST_PWRITE;
#endif

        }
    }
    else
    {                           // The file doesn't exist

        ExtractPath(pName, __StackToFlat(parent));
        ExtractName(pName, __StackToFlat(component));
        //
        // We try to open the parent dir
        //
        if ((dir = open_by_name(sb->s_mounted, Skip_drive(__StackToFlat(parent)), OPENMODE_READONLY)) == 0)
        {
//            kernel_printf("FS_OPENCREATE() - The parent directory %s doesn't seem to exist", parent);
            return ERROR_PATH_NOT_FOUND;
        }

        //
        // The parent dir exists
        //

        //
        // If the file is open for execution : error (it doesn't even exist)
        //
        if (accessmode == OPEN_ACCESS_EXECUTE)
        {
#ifdef FS_TRACE
            fs_log("Can't FS_OPENCREATE() - File doesn't exist & OPEN_ACCESS_EXECUTE");
#endif
            if ((rc = vfs_close(dir)) != NO_ERROR)
            {
                fs_err(FUNC_FS_OPENCREATE, FUNC_CLOSE, rc, FILE_TEST_C, __LINE__);
                return rc;
            }
            return ERROR_FILE_NOT_FOUND;
        }

        //
        // If the file is open for writing or readwrite ...
        //
        if ((accessmode == OPEN_ACCESS_READONLY) ||
            (accessmode == OPEN_ACCESS_READWRITE) ||
            (accessmode == OPEN_ACCESS_WRITEONLY))
        {
            if (newflag == OPEN_ACTION_FAIL_IF_NEW)
            {
#ifdef FS_TRACE
                fs_log("Can't FS_OPENCREATE() - File doesn't exist &  OPEN_ACTION_FAIL_IF_NEW");
#endif
                if ((rc = vfs_close(dir)) != NO_ERROR)
                {
                    fs_err(FUNC_FS_OPENCREATE, FUNC_CLOSE, rc, FILE_TEST_C, __LINE__);
                    return rc;
                }
                return ERROR_OPEN_FAILED;
            }

            if (newflag == OPEN_ACTION_CREATE_IF_NEW)
            {
//                ino_no = dir->f_inode->i_ino;
                inode_parent = dir->f_inode;
                inode_parent->i_count++;
                if ((rc = vfs_close(dir)) != NO_ERROR)
                {
                    fs_err(FUNC_FS_OPENCREATE, FUNC_CLOSE, rc, THISFILE, __LINE__);
                    return rc;
                }
//                inode_parent = iget(sb, ino_no);
                inode_parent->i_count++;
                down(&inode_parent->i_sem);
                rc = inode_parent->i_op->create(inode_parent, __StackToFlat(component), strlen(component), S_IRWXU | S_IFREG, __StackToFlat(&inode));
                up(&inode_parent->i_sem);
                if (rc)
                {
                    kernel_printf("Couldn't create %s", pName);
                    iput(inode_parent);
                    return rc;
                }
                ino_no = inode->i_ino;
                iput(inode_parent);
                iput(inode);
                if ((p_file = _open_by_inode(sb, ino_no, openmode)) == 0)
                {
                    kernel_printf("open_by_inode(%lu) failed in FS_OPENCREATE", ino_no);
                    return ERROR_OPEN_FAILED;
                }
                p_file->f_inode->i_size = psffsi->sfi_size;
                p_file->f_inode->i_dirt = 1;
                p_file->f_flags = O_CREAT;
                *pAction = FILE_CREATED;
#if 0
                psffsi->sfi_tstamp = ST_SCREAT | ST_PCREAT | ST_PWRITE | ST_SWRITE;
#else
                /*
                 * Time stamping is done by inode routines - Only propagate value.
                 */
                psffsi->sfi_tstamp = ST_PCREAT | ST_PWRITE;
#endif

            }

        }

    }





    psffsd->f = p_file;
    /*
     * Time stamping is done by inode routines - Only propagate value.
     */
#if 0
    psffsi->sfi_tstamp |= ST_PREAD | ST_SREAD;
#else
    /*
     * Time stamping is done by inode routines - Only propagate value.
     */
    psffsi->sfi_tstamp |= ST_PREAD;
#endif
    psffsi->sfi_size = p_file->f_inode->i_size;
    psffsi->sfi_position = p_file->f_pos;

//    kernel_printf("date = %u/%u/%u", (pCommon->dateCreate) & 31, (pCommon->dateCreate >> 5) & 15 , (pCommon->dateCreate) >> 9);

    date_unix2dos(p_file->f_inode->i_ctime, &(psffsi->sfi_ctime), &(psffsi->sfi_cdate));
    date_unix2dos(p_file->f_inode->i_atime, &(psffsi->sfi_atime), &(psffsi->sfi_adate));
    date_unix2dos(p_file->f_inode->i_mtime, &(psffsi->sfi_mtime), &(psffsi->sfi_mdate));

    psffsi->sfi_DOSattr = (unsigned char)Linux_To_DOS_Attrs(p_file->f_inode, __StackToFlat(component));
    if (write_through_support)
    {
        if ((parms->ulOpenMode & OPEN_FLAGS_WRITE_THROUGH) ||
            (parms->ulOpenMode & OPEN_FLAGS_NO_CACHE))
        {
            p_file->f_flags |= O_SYNC;
            p_file->f_inode->i_flags |= MS_SYNCHRONOUS;
        }
    }
    return NO_ERROR;

}
Beispiel #12
0
/***********************************************************
refresh text
***********************************************************/
void OsgObjectHandler::RefreshText()
{
	osg::ref_ptr<osg::Group> root = GetRootNoLight();
	if(root)
	{
		if(_textgroup)
		{
			root->removeChild(_textgroup);
			_textgroup = NULL;
		}

		if(_extrainfo.Name != "")
		{
			if(DataDirHandler::getInstance()->IsInEditorMode() || _extrainfo.Display)
			{
				std::string name = ExtractName(_extrainfo.Name);

				osg::Vec3 posT;
				if(_uselight)
				{
					osg::BoundingSphere bs = GetRoot()->computeBound();
					posT = bs.center()+ osg::Vec3(0,1,0);		
				}
				else
				{
					osg::BoundingSphere bs = GetRootNoLight()->computeBound();
					posT = bs.center()+ osg::Vec3(0,1,0);	
					if(name.find("Spawn") == 0)
						posT = osg::Vec3(0,1,0);	
				}

				_textgroup = new osg::AutoTransform();
				_textgroup->setPosition(posT);
				_textgroup->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
				_textgroup->setMinimumScale(0.01);
				_textgroup->setMaximumScale(0.5);
				_textgroup->setAutoScaleToScreen(true);

				osg::ref_ptr<osg::Geode> _textgeode = new osg::Geode();
				osg::ref_ptr<osgText::Text> textd = new osgText::Text();
				textd->setText(name);
				textd->setColor(osg::Vec4(_extrainfo.NameColorR, _extrainfo.NameColorG, _extrainfo.NameColorB, 1));
				textd->setCharacterSize(/*0.4f*/10);
				textd->setFont("Tahoma.ttf");
				textd->setAlignment(osgText::Text::CENTER_CENTER);



				textd->setBackdropColor(osg::Vec4(0, 0, 0, 1));
				textd->setBackdropType(osgText::Text::OUTLINE);
				textd->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
				textd->setBackdropOffset(0.1f);

				_textgeode->addDrawable(textd);

				osg::StateSet* stateSet = _textgeode->getOrCreateStateSet();
				stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
				stateSet->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
				stateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
				stateSet->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
				stateSet->setRenderBinDetails( 500, "DepthSortedBin");

				_textgroup->addChild(_textgeode);
				root->addChild(_textgroup);
				root->dirtyBound();
			}
		}
	}
}
Beispiel #13
0
int MrRipper::GetFiles(struct PluginPanelItem *PanelItem, int ItemsNumber, int Move, char *DestPath, int OpMode)
{
    TSaveScreen SS;
    DWORD StartTime=GetTickCount();
    BOOL WaitMessage=FALSE;
    double Progress1, Progress2;
    long FullSize,CurSize, ProcessedBytes;
    int Owervrite = 0;
    char MyDestPath[MAX_PATH];
    char MyDestFile[MAX_PATH];

    if (!OpMode & OPM_SILENT){        
        if (!DestDirPrompt(DestPath)) return -2;        
    }

        if ((strlen(DestPath)==3)&&
                (DestPath[1]==':')&&
                (DestPath[2]=='\\')) DestPath[2] = 0;

    GetCurrentDirectory(MAX_PATH, MyDestPath);
    if (!SetCurrentDirectory(DestPath)) return FALSE;
    SetCurrentDirectory(MyDestPath);
    
    FormatFinder FF(PluginPath);        
    for (int i = 0; i<FF.GetFormatCount(); i++)             
        for (int j = 0; j<FF.GetnKnownFormats(i); j++)
            FF.SetActiveOpt(i, j, GetRegKey(HKEY_CURRENT_USER,"",FF.GetRegPath(i, j), 1));

    MakeCopyList(PanelItem, ItemsNumber);

    int f1, f2;
    int readed, pos, endpos, getret;
    
    if (!bPluginManager){
        FullSize = 0;
    
        for (int I = 0; I < copyfiles.size(); I++)
            FullSize += copyfiles[I].FileSize;
                        
        ProcessedBytes = 0;                                                     
    
        for (I = 0; I < copyfiles.size(); I++){
            if (copyfiles[I].FileName[strlen(copyfiles[I].FileName)-1]=='\\'){
                char *c = my_substr(copyfiles[I].FileName, 0, strlen(copyfiles[I].FileName)-1);
                FSF.sprintf(MyDestPath, "%s\\%s", DestPath, c);
                my_free(c);
                CreateDirectory(MyDestPath, NULL);            
            } else {    
                char *d = ExtractPath(copyfiles[I].FileName);
                if (strlen(d)>0) FSF.sprintf(MyDestPath, "%s\\%s", DestPath, d); 
                else strcpy(MyDestPath, DestPath);
                my_free(d);
            
                d = ExtractName(copyfiles[I].FileName);
                FSF.sprintf(MyDestFile, "%s", d);
                my_free(d);

                char c[MAX_PATH];
                FSF.sprintf(c, "%s\\%s", MyDestPath, MyDestFile);

                f2 = _open(c, _O_RDONLY|_O_BINARY);
                if (f2!=-1) {
                    _close(f2);
                    if (Owervrite==3) continue;
                    if (Owervrite == 0||Owervrite == 1)
                    if (!OpMode & OPM_SILENT) Owervrite = OverwritePrompt(MyDestFile);
                    if (Owervrite==-1) break;
                    if (Owervrite==3||Owervrite==1) continue;
                }   
    
                if (copyfiles[I].Fmt != FMT_DUMMY)
                    if (FF.GetCanGetFile(copyfiles[I].Fmt, copyfiles[I].Plugin)&&ConvView){
                        getret = FF.GetFile(copyfiles[I].Plugin, copyfiles[I].Fmt, RipFileName, MyDestFile, MyDestPath, copyfiles[I].StartOffset, copyfiles[I].FileSize, copyfiles[I].UnpSize, OpMode & OPM_SILENT, copyfiles[I].UserData.Data);
                        if (getret == 1){
                            ProcessedBytes += copyfiles[I].FileSize;
                            WaitMessage=FALSE;
                            if (!OpMode & OPM_SILENT){                                
                                if (GetTickCount()-StartTime>500){
                                    if (CheckForKey(VK_ESCAPE)) break;
                                    Progress1 = 100.0;
                                    Progress2 = ProcessedBytes; Progress2 *= 100; Progress2 /= FullSize;
                                    char FileMsg[100], ProgressMsg1[100], ProgressMsg2[100];
                                    FSF.sprintf(FileMsg,GetMsg(MExtracting), MyDestFile);
                                    FSF.sprintf(ProgressMsg1,GetMsg(MExtr1), Progress1);
                                    FSF.sprintf(ProgressMsg2,GetMsg(MExtr2), Progress2);                                                                                        
                                    const char *MsgItems[]={GetMsg(MExtraction),FileMsg, ProgressMsg1, ProgressMsg2};
                                    Info.Message(Info.ModuleNumber,WaitMessage ? FMSG_LEFTALIGN|FMSG_KEEPBACKGROUND:FMSG_LEFTALIGN,NULL,MsgItems,sizeof(MsgItems)/sizeof(MsgItems[0]),0);
                                    WaitMessage=TRUE;
                                }       
                            }
                            continue;
                        }
                        if (getret == 2){
                            if (CheckForKey(VK_ESCAPE)) break;
                            continue;
                        }
                    }
            
                FSF.sprintf(c, "%s\\%s", MyDestPath, MyDestFile);
    
                f1 = _open(RipFileName, _O_RDONLY|_O_BINARY);
                _lseek(f1,copyfiles[I].StartOffset,SEEK_SET);                                                     
            
                f2 = _open(c, _O_CREAT|_O_WRONLY|_O_BINARY);
                                
                endpos = copyfiles[I].StartOffset+copyfiles[I].FileSize;
                CurSize = copyfiles[I].FileSize;
                pos = _tell(f1);

                while (pos<endpos){                                       
                    if (!OpMode & OPM_SILENT){                    
                        if (GetTickCount()-StartTime>500){
                            if (CheckForKey(VK_ESCAPE)) break;
                            Progress1 = (pos-copyfiles[I].StartOffset); Progress1 *= 100; Progress1 /= copyfiles[I].FileSize;
                            Progress2 = ProcessedBytes; Progress2 *= 100; Progress2 /= FullSize;
                            char FileMsg[100], ProgressMsg1[100], ProgressMsg2[100];
                            FSF.sprintf(FileMsg,GetMsg(MExtracting), MyDestFile);
                            FSF.sprintf(ProgressMsg1,GetMsg(MExtr1), Progress1);
                            FSF.sprintf(ProgressMsg2,GetMsg(MExtr2), Progress2);                                                                                        
                            const char *MsgItems[]={GetMsg(MExtraction),FileMsg, ProgressMsg1, ProgressMsg2};
                            Info.Message(Info.ModuleNumber,WaitMessage ? FMSG_LEFTALIGN|FMSG_KEEPBACKGROUND:FMSG_LEFTALIGN,NULL,MsgItems,sizeof(MsgItems)/sizeof(MsgItems[0]),0);
                            WaitMessage=TRUE;
                        }       
                    }
                    readed = _read(f1, buf, BUF_SIZE);                                       
                    pos = _tell(f1);                                                                                
                    if (pos > endpos) readed = readed - (pos - endpos);
                    _write(f2, buf, readed);
                    ProcessedBytes += readed;
                    pos = _tell(f1);    
                    WaitMessage=FALSE;
                }            
                _close(f2);
                _close(f1);            
                SetFileAttributes(c, FILE_ATTRIBUTE_ARCHIVE);            
                if (!OpMode & OPM_SILENT) if (CheckForKey(VK_ESCAPE))  break;
            }
        }
        Free_copyfiles();
        return TRUE;
    } else { //For plugin manager    
        ADDPLUGININFO *PI;
        for (int I = 0; I < copyfiles.size(); I++){
            if (copyfiles[I].FileName[strlen(copyfiles[I].FileName)-1]=='\\'){
                char *c = my_substr(copyfiles[I].FileName, 0, strlen(copyfiles[I].FileName)-1);
                FSF.sprintf(MyDestPath, "%s\\%s", DestPath, c);
                my_free(c);
                CreateDirectory(MyDestPath, NULL);            
            } else {    
                char *d = ExtractPath(copyfiles[I].FileName);
                if (strlen(d)>0) FSF.sprintf(MyDestPath, "%s\\%s", DestPath, d); 
                else strcpy(MyDestPath, DestPath);
                my_free(d);
            
                d = ExtractName(copyfiles[I].FileName);
                FSF.sprintf(MyDestFile, "%s", d);
                my_free(d);

                char c[MAX_PATH];
                FSF.sprintf(c, "%s\\%s", MyDestPath, MyDestFile);

                f2 = _open(c, _O_RDONLY|_O_BINARY);
                if (f2!=-1) {
                    _close(f2);
                    if (Owervrite==3) continue;
                    if (Owervrite == 0||Owervrite == 1)
                    if (!OpMode & OPM_SILENT) Owervrite = OverwritePrompt(MyDestFile);
                    if (Owervrite==-1) break;
                    if (Owervrite==3||Owervrite==1) continue;
                }                   
            
                FSF.sprintf(c, "%s\\%s", MyDestPath, MyDestFile);                
            
                f2 = _open(c, _O_CREAT|_O_WRONLY|_O_BINARY);                                
                
                PI = (ADDPLUGININFO*)copyfiles[I].UserData.Data;

                FSF.sprintf((char*)buf, GetMsg(MInfoOptString), copyfiles[I].FileName);
                _write(f2, buf, lstrlen((char*)buf)+1);
                _write(f2, "\xD\xA\xD\xA", 4);

                FSF.sprintf((char*)buf, GetMsg(MInfoVer), copyfiles[I].Description);
                _write(f2, buf, lstrlen((char*)buf)+1);
                _write(f2, "\xD\xA", 2);
                
                char v[30];
                Ver2Char(PI->RipVer, v);

                FSF.sprintf((char*)buf, GetMsg(MInfoRipVer), v);
                _write(f2, buf, lstrlen((char*)buf)+1);                
                _write(f2, "\xD\xA\xD\xA", 4);

                FSF.sprintf((char*)buf, GetMsg(MInfoCopyright), PI->Copy);
                _write(f2, buf, lstrlen((char*)buf)+1);
                _write(f2, "\xD\xA", 2);

                FSF.sprintf((char*)buf, GetMsg(MInfoPath), PI->FilePath);
                _write(f2, buf, lstrlen((char*)buf)+1);
                _write(f2, "\xD\xA", 2);

                char *types[8] = {GetMsg(MInfoTypeGraph), 
                                  GetMsg(MInfoTypeVideo), 
                                  GetMsg(MInfoTypeSound),
                                  GetMsg(MInfoTypePack),
                                  GetMsg(MInfoTypeOther),
                                  GetMsg(MInfoTypeMusic),
                                  GetMsg(MInfoTypeText),
                                  GetMsg(MInfoTypeExe)};

                FSF.sprintf((char*)buf, GetMsg(MInfoType), types[PI->Type]);
                _write(f2, buf, lstrlen((char*)buf)+1);                

                _close(f2);
                
                SetFileAttributes(c, FILE_ATTRIBUTE_ARCHIVE);            
                if (!OpMode & OPM_SILENT) if (CheckForKey(VK_ESCAPE))  break;
            }
        }
        Free_copyfiles();

        //This for refuse reset selection
        if (!OpMode&OPM_SILENT) return -1;
        else return TRUE;
    }
    Free_copyfiles();
    return TRUE;
}
Beispiel #14
0
const UnicodeString TStrings::GetName(intptr_t Index) const
{
  return ExtractName(GetString(Index));
}