| 144 | } |
| 145 | |
| 146 | XnDumpFile* xnDumpFileOpenImpl(const XnChar* strDumpName, XnBool bForce, XnBool bSessionDump, const XnChar* strNameFormat, va_list args) |
| 147 | { |
| 148 | XnStatus nRetVal = XN_STATUS_OK; |
| 149 | |
| 150 | DumpData& dumpData = DumpData::GetInstance(); |
| 151 | |
| 152 | // check if there are writers |
| 153 | if (dumpData.writers.IsEmpty()) |
| 154 | { |
| 155 | return NULL; |
| 156 | } |
| 157 | |
| 158 | if (!bForce) |
| 159 | { |
| 160 | if (!xnLogIsDumpMaskEnabled(strDumpName)) |
| 161 | { |
| 162 | return NULL; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // format file name |
| 167 | XnChar strFileName[XN_FILE_MAX_PATH]; |
| 168 | XnUInt32 nChars; |
| 169 | nRetVal = xnOSStrFormatV(strFileName, XN_FILE_MAX_PATH, &nChars, strNameFormat, args); |
| 170 | if (nRetVal != XN_STATUS_OK) |
| 171 | { |
| 172 | XN_ASSERT(FALSE); |
| 173 | return NULL; |
| 174 | } |
| 175 | |
| 176 | // create a handle that will hold all handles to all writers |
| 177 | XnDumpFile* pFile = XN_NEW(XnDumpFile); |
| 178 | |
| 179 | // try to add writers |
| 180 | for (XnDumpWriters::Iterator it = dumpData.writers.Begin(); it != dumpData.writers.End(); ++it) |
| 181 | { |
| 182 | XnDumpWriterFile writerFile; |
| 183 | writerFile.pWriter = *it; |
| 184 | writerFile.hFile = writerFile.pWriter->OpenFile(writerFile.pWriter->pCookie, strDumpName, bSessionDump, strFileName); |
| 185 | XN_ASSERT(writerFile.hFile.pInternal != NULL); |
| 186 | if (writerFile.hFile.pInternal != NULL) |
| 187 | { |
| 188 | nRetVal = pFile->m_writersFiles.AddLast(writerFile); |
| 189 | XN_ASSERT(nRetVal == XN_STATUS_OK); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // check if any writer succeeded |
| 194 | if (pFile->m_writersFiles.IsEmpty()) |
| 195 | { |
| 196 | // no file. Release memory |
| 197 | XN_DELETE(pFile); |
| 198 | return NULL; |
| 199 | } |
| 200 | |
| 201 | // return the file pointer |
| 202 | return pFile; |
| 203 | } |
no test coverage detected