Fixed change dir command. TestDir returns false now if target is not a directory.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@554
This commit is contained in:
		
							parent
							
								
									406c78e2cc
								
							
						
					
					
						commit
						845d5c172f
					
				
					 2 changed files with 9 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -151,13 +151,7 @@ bool DOS_GetCurrentDir(Bit8u drive,char * buffer) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
bool DOS_ChangeDir(char * dir) {
 | 
			
		||||
 | 
			
		||||
	// Be sure its not a file (Eye of the beholder 3)
 | 
			
		||||
	char* str;
 | 
			
		||||
	if (str=strchr(dir,'.')) {
 | 
			
		||||
		if (isalpha(str[1]) || isdigit(str[1])) return false;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	Bit8u drive;char fulldir[DOS_PATHLENGTH];
 | 
			
		||||
	if (!DOS_MakeName(dir,fulldir,&drive)) return false;
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,6 +188,14 @@ bool localDrive::TestDir(char * dir) {
 | 
			
		|||
	strcpy(newdir,basedir);
 | 
			
		||||
	strcat(newdir,dir);
 | 
			
		||||
	CROSS_FILENAME(newdir);
 | 
			
		||||
	// Skip directory test, if "\"
 | 
			
		||||
	Bit16u len = strlen(newdir);
 | 
			
		||||
	if ((len>0) && (newdir[len-1]!='\\')) {
 | 
			
		||||
		// It has to be a directory !
 | 
			
		||||
		struct stat test;
 | 
			
		||||
		if (stat(newdir,&test)==-1)			return false;
 | 
			
		||||
		if ((test.st_mode & S_IFDIR)==0)	return false;
 | 
			
		||||
	};
 | 
			
		||||
	int temp=access(newdir,F_OK);
 | 
			
		||||
	return (temp==0);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue