xp_comm_proj/ReadGeoTiff/libtiff/tif_win32.c
/*
 * Open a TIFF file for read/writing.
 */
Open a TIFF file for read/writing.
Open a TIFF file for read / writing .
TIFF*
TIFFOpen(const char* name, const char* mode)
{
	static const char module[] = "TIFFOpen";
	thandle_t fd;
	int m;
	DWORD dwMode;
	m = _TIFFgetMode(mode, module);
	switch(m)
	{
	case O_RDONLY:
		dwMode = OPEN_EXISTING;
		break;
	case O_RDWR:
		dwMode = OPEN_ALWAYS;
		break;
	case O_RDWR|O_CREAT:
		dwMode = CREATE_NEW;
		break;
	case O_RDWR|O_TRUNC:
		dwMode = CREATE_ALWAYS;
		break;
	case O_RDWR|O_CREAT|O_TRUNC:
		dwMode = CREATE_ALWAYS;
		break;
	default:
		return ((TIFF*)0);
	}
	fd = (thandle_t)CreateFile(name, (m == O_RDONLY) ? GENERIC_READ :
			(GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ, NULL, dwMode,
			(m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, NULL);
	if (fd == INVALID_HANDLE_VALUE) {
		TIFFError(module, "%s: Cannot open", name);
		return ((TIFF *)0);
	}
	return (TIFFFdOpen((int)fd, name, mode));
}
TIFF * TIFFOpen ( const char * name , const char * mode ) { static const char module [ ] = " " ; thandle_t fd ; int m ; DWORD dwMode ; m = _TIFFgetMode ( mode , module ) ; switch ( m ) { case O_RDONLY : dwMode = OPEN_EXISTING ; break ; case O_RDWR : dwMode = OPEN_ALWAYS ; break ; case O_RDWR | O_CREAT : dwMode = CREATE_NEW ; break ; case O_RDWR | O_TRUNC : dwMode = CREATE_ALWAYS ; break ; case O_RDWR | O_CREAT | O_TRUNC : dwMode = CREATE_ALWAYS ; break ; default : return ( ( TIFF * ) 0 ) ; } fd = ( thandle_t ) CreateFile ( name , ( m == O_RDONLY ) ? GENERIC_READ : ( GENERIC_READ | GENERIC_WRITE ) , FILE_SHARE_READ , NULL , dwMode , ( m == O_RDONLY ) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL , NULL ) ; if ( fd == INVALID_HANDLE_VALUE ) { TIFFError ( module , " " , name ) ; return ( ( TIFF * ) 0 ) ; } return ( TIFFFdOpen ( ( int ) fd , name , mode ) ) ; }
Open a TIFF file for read/writing.
Open a TIFF file for read / writing .