TuttleOFX
1
|
00001 // vi: ts=4 00002 00003 /* 00004 * Copyright (c) 2009, Patrick A. Palmer. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * - Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 00013 * - Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 00017 * - Neither the name of Patrick A. Palmer nor the names of its 00018 * contributors may be used to endorse or promote products derived from 00019 * this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00031 * POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 00034 00035 00036 #include "DPX.h" 00037 00038 00039 00040 00041 00042 // determine byte order for current system 00043 // Intel processors are Little Endian 00044 // Power PC, MIPS and Ultra Sparc are Big Endian 00045 static unsigned long lValue = 0x12345678; 00046 static unsigned long *lPtr = &lValue; 00047 dpx::Endian dpx::systemByteOrder = (*(unsigned char*)lPtr == 0x78 ? dpx::kLittleEndian : dpx::kBigEndian); 00048 00049 00050 00051 00052 00053 00054 00055 bool dpx::IdentifyFile(InStream *fp) 00056 { 00057 U32 magic; 00058 00059 fp->Rewind(); 00060 00061 if (fp->Read(&magic, sizeof(magic)) != sizeof(magic)) 00062 return false; 00063 00064 return dpx::Header::ValidMagicCookie(magic); 00065 } 00066 00067 00068 00069 00070 bool dpx::IdentifyFile(const void *p) 00071 { 00072 U32 magic = *((U32 *) p); 00073 return dpx::Header::ValidMagicCookie(magic); 00074 00075 } 00076 00077