Esempio n. 1
0
esint16 fs_findFreeFile(FileSystem *fs,eint8* filename,FileLocation *loc,euint8 mode)
{
	euint32 targetdir=0;
	eint8 ffname[11];
	
	if(fs_findFile(fs,filename,loc,&targetdir))return(0);
	if(!dir_getFatFileName(filename,ffname))return(0);
	if(dir_findinDir(fs,ffname,targetdir,loc,DIRFIND_FREE)){
		return(1);
	}else{
		if(dir_addCluster(fs,targetdir)){
			return(0);
		}else{
			if(dir_findinDir(fs,ffname,targetdir,loc,DIRFIND_FREE)){
				return(1);
			}
		}
	}
		
	return(0);
}
Esempio n. 2
0
esint8 fs_findFile(FileSystem *fs,eint8* filename,FileLocation *loc,euint32 *lastDir)
{
	euint32 fccd,tmpclus;
	eint8 ffname[11],*next,it=0,filefound=0;
	
	if(*filename=='/'){
		fccd = fs_getFirstClusterRootDir(fs);
		filename++;
		if(lastDir)*lastDir=fccd;
		if(!*filename){
			return(2);
		}
	}else{
		fccd = fs->FirstClusterCurrentDir;
		if(lastDir)*lastDir=fccd;
	}

	
	while((next=file_normalToFatName(filename,ffname))!=0){

		if((tmpclus=dir_findinDir(fs,ffname,fccd,loc,DIRFIND_FILE))==0){
			/* We didn't find what we wanted */
			/* We should check, to see if there is more after it, so that
			 * we can invalidate lastDir
			 */
			if((file_normalToFatName(next,ffname))!=0){
				if(lastDir)*lastDir=0;
			}			 
			return(0);
		}
		it++;
		if(loc->attrib&ATTR_DIRECTORY){
			fccd = tmpclus;
			filename = next;
			if(lastDir)*lastDir=fccd;
			if(filefound)*lastDir=0;
		}else{
			filefound=1;
			if((file_normalToFatName(next,ffname))!=0){
				if(lastDir)*lastDir=0;
				return(0);
			}else{
				filename=next;	
			}
		}
	}
	
	if(it==0)return(0);
	if(loc->attrib&ATTR_DIRECTORY || !filefound)return(2);
	return(1);
}
Esempio n. 3
0
esint8 fs_findFile(FileSystem *fs,eint8* filename,FileLocation *loc,euint32 *lastDir)
{
	euint32 fccd,tmpclus;
	eint8 ffname[11],*next,it=0,filefound=0;
	
	if(*filename=='/'){
		fccd = fs_getFirstClusterRootDir(fs);
		filename++;
		if(!*filename){
			if(lastDir)*lastDir=fccd;
			return(2);
		}
	}else{
		fccd = fs->FirstClusterCurrentDir;
	}
	
	if(lastDir)*lastDir=fccd;
	
	while((next=file_normalToFatName(filename,ffname))!=0){
		if((tmpclus=dir_findinDir(fs,ffname,fccd,loc,DIRFIND_FILE))==0)return(0);
		it++;
		if(loc->attrib&ATTR_DIRECTORY){
			fccd = tmpclus;
			filename = next;
			if(lastDir)*lastDir=fccd;
			if(filefound)*lastDir=0;
		}else{
			filefound=1;
			if((file_normalToFatName(next,ffname))!=0){
				return(0);
			}else{
				filename=next;	
			}
		}
	}
	
	if(it==0)return(0);
	if(loc->attrib&ATTR_DIRECTORY || !filefound)return(2);
	return(1);
}
Esempio n. 4
0
esint8 fs_findFile(FileSystem *fs, eint8* filename, FileLocation *loc, euint32 *lastDir)
{
	euint32 currentDir, tmpclus;
	eint8 ffname[11], *next, it = 0, filefound = 0;
	
	if(*filename=='/')
	{
		currentDir = fs_getFirstClusterRootDir(fs);
		filename++;
		if(lastDir)*lastDir=currentDir;
		if(!*filename)
		{
			return(2);
		}
	}
	else
	{
		currentDir = fs->FirstClusterCurrentDir;
		if(lastDir)
		{
			*lastDir = currentDir;
		}
	}
	
	
	while((next = file_normalToFatName(filename, ffname)) != 0)
	{
		if((tmpclus = dir_findinDir(fs, ffname, currentDir, loc, DIRFIND_FILE)) == 0)
		{
			/* We didn't find what we wanted */
			/* We should check, to see if there is more after it, so that
			 * we can invalidate lastDir
			 */
			if((file_normalToFatName(next,ffname)) != 0)
			{
				if(lastDir)
				{
					*lastDir=0;
				}
			}			 
			return(0);
		}
		it++;
		if(loc->attrib & ATTR_DIRECTORY)
		{
			currentDir = tmpclus;
			filename = next;
			if(lastDir)
			{
				*lastDir = currentDir;

				/* what in the world is this supposed to do? commenting out - edwards 6/15/2008
				if(filefound)
				{
					*lastDir=0;
				}
				*/
			}
		}
		else
		{
			filefound = 1;
			if((file_normalToFatName(next,ffname)) != 0)
			{
				if(lastDir)
				{
					*lastDir=0;
				}
				return(0);
			}
			else
			{
				filename = next;
			}
		}
	}
	
	if(it == 0)
	{
		return(0);
	}
	
	if(loc->attrib & ATTR_DIRECTORY || !filefound)
	{
		return(2);
	}
	
	return(1);
}