| 120 | } |
| 121 | |
| 122 | XN_C_API XnStatus xnOSLoadFile(const XnChar* cpFileName, void* pBuffer, const XnUInt32 nBufferSize) |
| 123 | { |
| 124 | // Local function variables |
| 125 | XN_FILE_HANDLE FileHandle; |
| 126 | XnUInt32 nReadBytes = nBufferSize; |
| 127 | XnStatus nRetVal = XN_STATUS_OK; |
| 128 | |
| 129 | // Validate the input/output pointers (to make sure none of them is NULL) |
| 130 | XN_VALIDATE_INPUT_PTR(cpFileName); |
| 131 | XN_VALIDATE_OUTPUT_PTR(pBuffer); |
| 132 | |
| 133 | if (nBufferSize == 0) |
| 134 | { |
| 135 | return XN_STATUS_NULL_OUTPUT_PTR; |
| 136 | } |
| 137 | |
| 138 | nRetVal = xnOSOpenFile(cpFileName, XN_OS_FILE_READ, &FileHandle); |
| 139 | XN_IS_STATUS_OK(nRetVal); |
| 140 | |
| 141 | nRetVal = xnOSReadFile(FileHandle, pBuffer, &nReadBytes); |
| 142 | if ((nRetVal != XN_STATUS_OK) || (nReadBytes != nBufferSize)) |
| 143 | { |
| 144 | xnOSCloseFile(&FileHandle); |
| 145 | return (XN_STATUS_OS_FILE_READ_FAILED); |
| 146 | } |
| 147 | |
| 148 | nRetVal = xnOSCloseFile(&FileHandle); |
| 149 | XN_IS_STATUS_OK(nRetVal); |
| 150 | |
| 151 | // All is good... |
| 152 | return (XN_STATUS_OK); |
| 153 | } |
| 154 | |
| 155 | XN_C_API XnStatus xnOSSaveFile(const XnChar* cpFileName, const void* pBuffer, const XnUInt32 nBufferSize) |
| 156 | { |
no test coverage detected