/** * @brief 获取文件长度 * @param strFileName 相对路径 * @param nThreadIndex 线程索引 */ private int GetFileLength(string strFileName, int nThreadIndex = 0) { int nFileSize = 0; if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.IPhonePlayer) // MAC读取文件 { try { nFileSize = EngineNativeMethod.GetFileLength_MAC(strFileName, nThreadIndex); } catch (Exception e) { Utility.Log.Error("C++Plugin获取文件{0}失败:{1}", strFileName, e.ToString()); } } else { try { nFileSize = EngineNativeMethod.GetFileLength(strFileName, nThreadIndex); } catch (Exception e) { Utility.Log.Error("C++Plugin获取文件{0}失败:{1}", strFileName, e.ToString()); } } return(nFileSize); }
private int GetFileBuff(string strFileName, [MarshalAs(UnmanagedType.LPArray)] ref byte[] lpBuffer, int nStartPos, int nSize, int nThreadIndex = 0) { int nRet = 0; if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.IPhonePlayer) // MAC读取文件 { try { nRet = EngineNativeMethod.GetFileBuff_MAC(strFileName, ref lpBuffer, nStartPos, nSize, nThreadIndex); } catch (Exception e) { Utility.Log.Error("C++Plugin读取文件{0}失败:{1}", strFileName, e.ToString()); } } else { try { nRet = EngineNativeMethod.GetFileBuff(strFileName, ref lpBuffer, nStartPos, nSize, nThreadIndex); } catch (Exception e) { Utility.Log.Error("C++Plugin读取文件{0}失败:{1}", strFileName, e.ToString()); } } return(nRet); }