os: let `os.dir("/xyz")` return "/" (fixes compiling .v files in /)
							parent
							
								
									7c504920e1
								
							
						
					
					
						commit
						44892fd942
					
				| 
						 | 
				
			
			@ -170,6 +170,9 @@ pub fn dir(path string) string {
 | 
			
		|||
		return '.'
 | 
			
		||||
	}
 | 
			
		||||
	pos := path.last_index(path_separator) or { return '.' }
 | 
			
		||||
	if pos == 0 && path_separator == '/' {
 | 
			
		||||
		return '/'
 | 
			
		||||
	}
 | 
			
		||||
	return path[..pos]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -534,6 +534,8 @@ fn test_dir() {
 | 
			
		|||
		assert os.dir('C:\\a\\b\\c') == 'C:\\a\\b'
 | 
			
		||||
		assert os.dir('C:\\a\\b\\') == 'C:\\a\\b'
 | 
			
		||||
	} $else {
 | 
			
		||||
		assert os.dir('/') == '/'
 | 
			
		||||
		assert os.dir('/abc') == '/'
 | 
			
		||||
		assert os.dir('/var/tmp/foo') == '/var/tmp'
 | 
			
		||||
		assert os.dir('/var/tmp/') == '/var/tmp'
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue