Example #1
0
/*将 rmfile 这个文件删除,而且目前只能删除文件*/
void do_rm()
{
    struct inode cur_dir,item;
    struct dir_ent ent,emptyent;
    char *filename;
    char buf[MAXBUF];
    memset(&emptyent,0,sizeof(emptyent));
    int i,j;
    if (!rmfile[0]) scanf("%s",rmfile);
    if(!strcmp(rmfile,".") || !strcmp(rmfile,"..")) {
        printf("Can not remove this file.\n");
        _clear(rmfile);
        return ;
    }
    strcpy(buf,rmfile);
    j=-1;
    for(i=0;rmfile[i];i++)   if(rmfile[i]=='/') j=i;
    if(j==0){//   case /dir
        buf[1]='\0';
        filename=rmfile+1;
    }else if(j>0){  //case /dir1/dir2  or ab/cd
        buf[j]='\0';
        filename=rmfile+j+1;
    }else {  //case ab
        strcpy(buf,".");
        filename=rmfile;
    }

    get_inode_bypath(buf,&cur_dir);
    if(cur_dir.i_num==-1) {
        printf("No such file.\n");
        _clear(rmfile);
        return ;
    }
        // get_inode(pwd,&cur_dir);
    fseek(fimg,cur_dir.i_start_sect*SECTOR_SIZE,SEEK_SET);
        //将逐个清空rmfile所占用的扇区
    for(i=0;i<cur_dir.i_size;i++)
    {
        fread(&ent,sizeof(struct dir_ent),1,fimg);
        if(strcmp(filename,ent.name)==0){        
            get_inode(ent.i_num,&item);
            if(item.i_mode==1){
                fseek(fimg,-sizeof(struct dir_ent),SEEK_CUR);
                fwrite(&emptyent,sizeof(struct dir_ent),1,fimg);//删除该目录项,只能删除文件
                free_inode(item.i_num);
                u32 sector=item.i_start_sect;
                while(sector!=0){
                    free_sector(sector);
                    fseek(fimg,sector*SECTOR_SIZE+SECTOR_SIZE-sizeof(u32),SEEK_SET);
                    fread(&sector,sizeof(u32),1,fimg);
                }
            }else printf("Can not remove directory\n");
            _clear(rmfile);
            return ;
        }
    }
    _clear(rmfile);
    printf("No such file.\n");
}
Example #2
0
void BSTree<KeyType, ValueType>::_clear(typename BSTree<KeyType, ValueType>::BSTreeNode *root)
{
	if(root == NULL) return;
	_clear(root->lchild);
	_clear(root->rchild);
	delete root;
}
void ObjectHierarchy::setBottom(SPObject *object) {
    if (object == NULL) { printf("assertion object != NULL failed\n"); return; }

    if ( bottom() == object ) {
        return;
    }

    if (!top()) {
        _addBottom(object);
    } else if (bottom()->isAncestorOf(object)) {
        _addBottom(bottom(), object);
    } else if ( top() == object ) {
        _trimBelow(top());
    } else if (top()->isAncestorOf(object)) {
        if (object->isAncestorOf(bottom())) {
            _trimBelow(object);
        } else { // object is a sibling or cousin of bottom()
            SPObject *saved_top=top();
            sp_object_ref(saved_top, NULL);
            _clear();
            _addBottom(saved_top);
            _addBottom(saved_top, object);
            sp_object_unref(saved_top, NULL);
        }
    } else {
        _clear();
        _addBottom(object);
    }

    _changed_signal.emit(top(), bottom());
}
Example #4
0
void do_mv()
{
    if(!src[0])  scanf("%s %s",src,dest);
    strcpy(rmfile,src);
    errno=0;
    do_cp();
    if(errno==0)     do_rm();
    _clear(src);  _clear(dest);
    _clear(rmfile);
}
Example #5
0
	void _clear(Node* node)
	{
		if (node)
		{
			if (node->left) _clear(node->left);
			
			if (node->right) _clear(node->right);
			
			delete node;
		}
	}
Example #6
0
File: kernel.c Project: ju34/asmos
void main(void)
{

    _clear();
    _printk("Kernel is runnig ... ");
//	int i = 0;

//	for(i=0; i < IDTSIZE; i++)
//		_init_idt_desc(&kidt[i], (unsigned int) _asm_default_int, 0x08, 0x8E00);
		
//	_init_idt_desc(&kidt[33], (unsigned int) _asm_keyboard_int, 0x08, 0x8E00);

//	kidtr.limite = 0xFF*8;
//	kidtr.base = 0x800;

//        memcpy((char *) kidtr.base, (char *) kidt, kidtr.limite);

//	asm("lidtl (kidtr)");

//	init_pic();
	
//	sti;

//	_clear();
//        _printk("OK");
//	_gotoxy(5,5);
//	_printk("TEST\t");
//	_setattr(0x04);
//	_printk("Encore un test");


	while(1);
}
void Selection::setList(std::vector<SPItem*> const &list) {
    // Clear and add, or just clear with emit.
    if (!list.empty()) {
        _clear();
        addList(list);
    } else clear();
}
Example #8
0
	void queue<type>::_clear(np cur) {
		if (cur == NULL) {
			return;
		}
		_clear(cur->next);
		delete cur;
	}
//----------------------------------------------------------------------------------------
CSparseMatrixProjectionGeometry2D::CSparseMatrixProjectionGeometry2D(const CSparseMatrixProjectionGeometry2D& _projGeom)
{
	_clear();
	initialize(_projGeom.m_iProjectionAngleCount,
				_projGeom.m_iDetectorCount, 
				_projGeom.m_pMatrix);
}
Example #10
0
void Webcam::open(int device)
{
	if(!use) return;
	_clear();
#ifdef USE_VIDEOINPUT
	m_device = device;
	VI.setupDevice(m_device);
#elif !defined(NO_WEBCAM)
	//Open the webcam with OpenCV
	m_VideoCap = new cv::VideoCapture(device);
	if(!m_VideoCap->isOpened())	
	{
		m_VideoCap->open(device);
		if(!m_VideoCap->isOpened())	
		{
			errlog << "Unable to open webcam " << device << endl;
			m_VideoCap->release();
			delete m_VideoCap;
			m_VideoCap = NULL;
		}
		else
			getNewFrame();	//Grab a new frame now while we're loading, because there seems to be a lag on getting the first frame
	}
	else
		getNewFrame();	//Grab a new frame now while we're loading, because there seems to be a lag on getting the first frame
#endif
}
Example #11
0
void Geometry::destroy()
{
	if (mMesh)
	{
		mMesh->destroy();
		delete mMesh;
	}
	if (mMaterial)
	{
		mMaterial->destroy();
		delete mMaterial;
	}
	if (mSkeletonMaterial)
	{
		mSkeletonMaterial->destroy();
		delete mSkeletonMaterial;
	}
	if (mSkeleton)
	{
		mSkeleton->destroy();
		delete mSkeleton;
	}
	if (mSkin)
	{
		delete mSkin;
	}
	_clear();
}
Example #12
0
void eAllowedOpInput::parseConfig(const eString &config)
{
    _clear();

    const eU32 configLen = config.length();
    eString buffer;

    for (eU32 i=0; i<configLen; i++)
    {
        buffer = "";

        while (i < configLen && config[i] != '|')
        {
            buffer += config[i++];
        }

        eString left, right;

        if (!buffer.split(',', left, right))
        {
            eSwap(left, right);
        }

        WhereWhat *ww = new WhereWhat;
        eASSERT(ww != eNULL);
        ww->index = (left == "" ? -1 : eStrToInt(left));
        ww->what = right;

        m_allowed.append(ww);
        m_allAllowed.append(new eString(right));
    }
}
Example #13
0
void stack<type>::_clear(np cur) {
    if (cur == NULL) {
        return;
    }
    _clear(cur->pre);
    delete cur;
}
Example #14
0
/**
 * 内部用: exec処理
 * @param v squirrelVM
 * @param idx このインデックスから先にあるものを実行開始する。文字列ならスクリプト、ファンクションなら直接
 */
void
Thread::_exec(HSQUIRRELVM v, int idx)
{
	_clear();
	_thread.clear();
	// スレッド先頭にスクリプトをロード
	if (sq_gettype(v, idx) == OT_STRING) {
		// スクリプト指定で遅延ロード
		_scriptName.getStack(v, idx);
		_fileHandler = sqobjOpenFile(getString(v, idx));
		_status = THREAD_LOADING_FILE;
	} else {
		// ファンクション指定
		_func.getStack(v, idx);
		_status = THREAD_LOADING_FUNC;
	}

	// 引数を記録
	SQInteger max = sq_gettop(v);
	if (max > idx) {
		_args.initArray();
		for (int i=idx+1;i<=max;i++) {
			_args.append(v, i);
		}
	}
}
Example #15
0
    void MovieSprite::clear()
    {
        _clear();

        _dirty = false;
        _playing = false;
        _paused = false;
        _ready = false;

        if (_textureUV)
            _textureUV->release();
        _textureUV = 0;

        if (_textureYA)
            _textureYA->release();
        _textureYA = 0;

        _movieRect = Rect(0, 0, 0, 0);

        setAnimFrame(0);

        _initialized = false;

        {
            MutexAutoLock m(_mutex);

            _mtUV.cleanup();
            _mtYA.cleanup();
        }
    }
Example #16
0
void Canvas::destroy()
{
	//
	if (_fx)
	{
		_fx->destroy();
		_fx = 0;
	}
	if (_fxTerrain)
	{
		_fxTerrain->destroy();
		_fxTerrain = NULL;
	}

	//
	if (_material)
	{
		delete _material;
		_material = 0;
	}
	//
	if (_vb)
	{
		_vb->destroy();
		delete _vb;
		_vb = NULL;
	}
	_destroyTerrain();
	RenderEngineImp::getInstancePtr()->destroy();
	delete RenderEngineImp::getInstancePtr();

	//
	_clear();
}
Example #17
0
void UMLTextItem::setFont(const QString & family, int pointSize )
{
	_clear();
	_font = family;
	_font_size = pointSize;
	_path.addText(_path.boundingRect().x(),_path.boundingRect().y(),QFont(_font,_font_size),QString(_text.c_str()));
}
Example #18
0
Ob _create ()
{//generic creation
    if (Ob::full()) CS::grow_obs();
    Ob ob = Ob::alloc();
    _clear (ob);
    return ob;
}
//----------------------------------------------------------------------------------------
// Copy Constructor
CFanFlatVecProjectionGeometry2D::CFanFlatVecProjectionGeometry2D(const CFanFlatVecProjectionGeometry2D& _projGeom)
{
	_clear();
	this->initialize(_projGeom.m_iProjectionAngleCount,
	                 _projGeom.m_iDetectorCount,
	                 _projGeom.m_pProjectionAngles);
}
//----------------------------------------------------------------------------------------
// Constructor with initialization
CCudaFDKAlgorithm3D::CCudaFDKAlgorithm3D(CProjector3D* _pProjector, 
								   CFloat32ProjectionData3DMemory* _pProjectionData, 
								   CFloat32VolumeData3DMemory* _pReconstruction)
{
	_clear();
	initialize(_pProjector, _pProjectionData, _pReconstruction);
}
Example #21
0
//---------------------------------------------------------------------------------------
// Initialize - C++
CCglsAlgorithm::CCglsAlgorithm(CProjector2D* _pProjector, 
							   CFloat32ProjectionData2D* _pSinogram, 
							   CFloat32VolumeData2D* _pReconstruction)
{
	_clear();
	initialize(_pProjector, _pSinogram, _pReconstruction);
}
Example #22
0
static int
value_set(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
{
    int32_t value;
    int r;
    struct segments_ctl_data *mdata = data;

    if (mdata->needs_clear) {
        _clear(node);
        mdata->needs_clear = false;
    }

#define RANGE_MIN (0)
#define RANGE_MAX (15)

    r = sol_flow_packet_get_irange_value(packet, &value);
    SOL_INT_CHECK(r, < 0, r);

    if ((value < RANGE_MIN) || (value > RANGE_MAX)) {
        sol_flow_send_error_packet(node, ERANGE,
            "Range invalid, it should be between %d and %d but was %" PRId32,
            RANGE_MIN, RANGE_MAX, value);
        return 0;
    }
    _write_byte(node, font[value]);

    return 0;

#undef RANGE_MAX
#undef RANGE_MIN
}
Example #23
0
void BufferProtocol::allocate(size_t size, mode_t mode)
{
    release();
    _clear();

    if(!size)
        return;

    back = 0;
    switch(mode) {
    case RDWR:
        input = buffer = (char *)malloc(size * 2);
        if(buffer)
            output = buffer + size;
        else
            fault();
        break;
    case RDONLY:
        input = buffer = (char *)malloc(size);
        if(!buffer)
            fault();
        break;
    case WRONLY:
        output = buffer = (char *)malloc(size);
        if(!buffer)
            fault();
        break;
    }

    bufpos = insize = outsize = 0;
    bufsize = size;

    if(buffer)
        end = false;
}
Example #24
0
void Restore(int *tokens)

{
	int i=1,j,cmp[7],o;
	FILE *fp;
	node *p,*q;
	char filename[Max_filename],c;
	if(Restore_Semantic_Analyser(tokens,&i)==-1)
		return;
	printf("Enter the directory then file's name.\n");
	gets(filename);
	if((fp=fopen(filename,"rb"))==NULL)
	{
		printf("Restore failed.\n");
		return;
	}
	for(i=0;i<7;i++)
	{
		fscanf(fp,"%d|",&cmp[i]);
		if(cmp[i]!=signiture[i])
		{
			printf("This file isn't a game file.\n");
			return;
		}
	}
	_clear();
	//Maybe examine the parameters in a limited range.Just so all the data make sense.
	//And Maybe get some sort good stuff to alter the data into more sophisitcated data,which is hard to transfer.You know,to cheat.
	fscanf(fp,"%d|%d|%d|%d",&player.x,&player.y,&player.health,&player.money);
	for(i=0;i<Max_carries;i++)
		fscanf(fp,"|%d",&player.inventory[i]);
	fscanf(fp,"|%d",&player.num_object);
	for(i=0;i<Map_num_rows;i++)
	{
		for(j=0;j<Map_num_columns;j++)
		{
			p=map_object[i][j];
			q=map_object[i][j];
			fscanf(fp,"|%d%c",&o,&c);
			p->obj=o;
			p->next=0;
			while(c==' ')
			{
				q=p;
				p=p->next;
				p=malloc(sizeof(node));
				fscanf(fp,"|%d%c",&o,&c);
				p->obj=o;
				p->next=0;
				q->next=p;
			}
		}
	}
	for(i=0;i<Max_condition;i++)
		fscanf(fp,"|%d",&condition[i]);
	fscanf(fp,"|%d",&step);
	fclose(fp);
	//Maybe an error check funtion in the end,making sure all the stuff are within its possible range.
}
Example #25
0
void PNG::_init() { 
if (_pixels != NULL) 
_clear(); 
_width = 1;

_height = 1;

_pixels = new RGBAPixel[1]; 
_blank(); 
} 
ServerGlobalStructs::~ServerGlobalStructs() {
    _clear();
    //now, close the modules
    for(std::vector<void *>::reverse_iterator i = modulesDLLs.rbegin(); i != modulesDLLs.rend(); ++i) {
        geryon::server::closeDynamicLibrary(*i);
    }
    modulesDLLs.clear();
}
//----------------------------------------------------------------------------------------
CParallelProjectionGeometry2D::CParallelProjectionGeometry2D(const CParallelProjectionGeometry2D& _projGeom)
{
	_clear();
	initialize(_projGeom.m_iProjectionAngleCount,
				_projGeom.m_iDetectorCount, 
				_projGeom.m_fDetectorWidth, 
				_projGeom.m_pfProjectionAngles);
}
//----------------------------------------------------------------------------------------
// Un-initialize the object, bringing it back in the unitialized state.
void CFloat32Data3DMemory::_unInit()
{
	ASTRA_ASSERT(m_bInitialized);

	_freeData();
	_clear();
	m_bInitialized = false;
}
Selection::~Selection() {
    _clear();
    _layers = NULL;
    if (_idle) {
        g_source_remove(_idle);
        _idle = 0;
    }
}
Example #30
0
void SubEntity::destroy()
{
	if (mGeometry)
	{
		mGeometry->destroy();
		delete mGeometry;
	}
	_clear();
}