DirectoryEntry Next() override { assert(m_find != INVALID_HANDLE_VALUE); DirectoryEntry entry; bool invalidEntry = true; while(invalidEntry && !m_lastError) { //due to the way the FindFirstFile api works, //the first entry will already be loaded by the time we get here. entry = ParseFileInfo(m_ffd, true); Aws::String fileName = Aws::Utils::StringUtils::FromWString(m_ffd.cFileName); if (fileName != ".." && fileName != ".") { AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Found entry " << entry.path); invalidEntry = false; } else { entry.fileType = FileType::None; AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Skipping . or .. entries."); } if(!FindNextFileW(m_find, &m_ffd)) { m_lastError = GetLastError(); AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "Could not fetch next entry from " << m_directoryEntry.path << " with error code " << m_lastError); break; } } return entry; }
tFileInfo CPkiCard::SelectFile(const std::string & csPath, bool bReturnFileInfo) { CByteArray oResp; tFileInfo xFileInfo = {0}; unsigned long ulPathLen = (unsigned long) csPath.size(); if (ulPathLen % 4 != 0 || ulPathLen == 0) throw CMWEXCEPTION(EIDMW_ERR_BAD_PATH); ulPathLen /= 2; unsigned char ucP2 = bReturnFileInfo ? 0x00 : 0x0C; CAutoLock autolock(this); if (m_selectAppletMode == ALW_SELECT_APPLET) { SelectApplet(); oResp = SelectByPath(csPath, bReturnFileInfo); } else { // First try to select the file by ID, assuming we're in the correct DF CByteArray oPath(ulPathLen); oPath.Append(Hex2Byte(csPath, ulPathLen - 2)); oPath.Append(Hex2Byte(csPath, ulPathLen - 1)); // Select File oResp = SendAPDU(0xA4, 0x02, ucP2, oPath); unsigned long ulSW12 = getSW12(oResp); if (ulSW12 == 0x6A82 || ulSW12 == 0x6A86) { if (ulPathLen == 2) throw CMWEXCEPTION(m_poContext->m_oPCSC.SW12ToErr(ulSW12)); // The file wasn't found in this DF, so let's select by full path oResp = SelectByPath(csPath, bReturnFileInfo); } else { getSW12(oResp, 0x9000); } } if (bReturnFileInfo) xFileInfo = ParseFileInfo(oResp); return xFileInfo; }
int AllFiles::GetIDFile(const AccessFile& tmpAccFl, const std::string PathFile)const { //lock mutex AccessFile AccFl = tmpAccFl; ParseFileInfo(AccFl, PathFile); int tmpIDFilem = atoi(AccFl.IDFile); if (tmpIDFilem < m_ClFiles.size()) { //TODO: method to return tmp struct with Mutex AccessFile tmp = m_ClFiles[tmpIDFilem].GetAccessFile();//create temporary struct of file if (!strcmp(AccFl.IDFile, tmp.IDFile))//check if (!strcmp(AccFl.name, tmp.name)) if (!strcmp(AccFl.mask, tmp.mask)) return atoi(tmp.IDFile); } return -1; }
User32Directory(const Aws::String& path, const Aws::String& relativePath) : Directory(path, relativePath), m_find(INVALID_HANDLE_VALUE), m_lastError(0) { WIN32_FIND_DATAW ffd; AWS_LOGSTREAM_TRACE(FILE_SYSTEM_UTILS_LOG_TAG, "Entering directory " << m_directoryEntry.path); m_find = FindFirstFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(m_directoryEntry.path.c_str())).c_str(), &ffd); if (m_find != INVALID_HANDLE_VALUE) { m_directoryEntry = ParseFileInfo(ffd, false); FindClose(m_find); auto seachPath = Join(m_directoryEntry.path, "*"); m_find = FindFirstFileW(ToLongPath(Aws::Utils::StringUtils::ToWString(seachPath.c_str())).c_str(), &m_ffd); } else { AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "Could not load directory " << m_directoryEntry.path << " with error code " << GetLastError()); } }