mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	If the file has no resource fork first check to see whether it's a
datafork-based resource file before trying to decode it as AppleSingle.
This commit is contained in:
		
							parent
							
								
									695b33b02a
								
							
						
					
					
						commit
						5053b70da0
					
				
					 1 changed files with 12 additions and 5 deletions
				
			
		|  | @ -77,13 +77,20 @@ def open_pathname(pathname): | ||||||
| 		refno = Res.FSpOpenResFile(pathname, 1) | 		refno = Res.FSpOpenResFile(pathname, 1) | ||||||
| 	except Res.Error, arg: | 	except Res.Error, arg: | ||||||
| 		if arg[0] in (-37, -39): | 		if arg[0] in (-37, -39): | ||||||
| 			# No resource fork. We may be on OSX, try to decode | 			# No resource fork. We may be on OSX, and this may be either | ||||||
| 			# the applesingle file. | 			# a data-fork based resource file or a AppleSingle file | ||||||
| 			pathname = _decode(pathname) | 			# from the CVS repository. | ||||||
| 			if pathname: | 			try: | ||||||
| 				refno = Res.FSOpenResourceFile(pathname, u'', 1) | 				refno = Res.FSOpenResourceFile(pathname, u'', 1) | ||||||
|  | 			except Res.Error, arg: | ||||||
|  | 				if arg[0] != -199: | ||||||
|  | 					# -199 is "bad resource map" | ||||||
|  | 					raise | ||||||
| 			else: | 			else: | ||||||
| 				raise | 				return refno | ||||||
|  | 			# Finally try decoding an AppleSingle file | ||||||
|  | 			pathname = _decode(pathname) | ||||||
|  | 			refno = Res.FSOpenResourceFile(pathname, u'', 1) | ||||||
| 	return refno | 	return refno | ||||||
| 	 | 	 | ||||||
| def _decode(pathname): | def _decode(pathname): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jack Jansen
						Jack Jansen