TSK_RETVAL_ENUM TSKAutoImpl::processFile(TSK_FS_FILE * a_fsFile, const char * a_path) { // skip the . and .. dirs if (isDotDir(a_fsFile, a_path) == 1) { return TSK_OK; } m_db.begin(); TSK_RETVAL_ENUM retval; // process the attributes if there are more than 1 if (tsk_fs_file_attr_getsize(a_fsFile) == 0) { retval = TSK_OK; uint64_t fileId; // If COR is returned, then keep on going. if (insertFileData(a_fsFile, NULL, a_path, fileId) == TSK_ERR) retval = TSK_ERR; else m_numFilesSeen++; } else { retval = processAttributes(a_fsFile, a_path); } static time_t lastCheck = m_startTime; time_t timeNow = time(NULL); if ((timeNow - lastCheck) > 3600) { lastCheck = timeNow; std::wstringstream msg; msg << L"TSKAutoImpl::processFile : Processed " << m_numFilesSeen << " files."; LOGINFO(msg.str()); } m_db.commit(); return retval; }
djvFileInfoList djvFileInfoUtil::list( const QString & path, djvSequence::COMPRESS compress) { //DJV_DEBUG("djvFileInfoUtil::list"); //DJV_DEBUG_PRINT("path = " << path); //DJV_DEBUG_PRINT("compress = " << compress); djvFileInfoList out; djvFileInfo * cache = 0; QString fixedPath = fixPath(path); #if defined(DJV_WINDOWS) WIN32_FIND_DATA data; HANDLE h = FindFirstFileEx( QString(fixedPath + "*").toLatin1().data(), FindExInfoBasic, &data, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH); if (h != INVALID_HANDLE_VALUE) { const char * p = data.cFileName; size_t l = strlen(p); if (! isDotDir(p, l)) { out.append(djvFileInfo(fixedPath + QString(p))); } while (FindNextFile(h, &data)) { p = data.cFileName; l = strlen(p); if (! isDotDir(p, l)) { if (! out.count()) { out.append(djvFileInfo(fixedPath + QString(p))); } else { const djvFileInfo tmp(fixedPath + QString(p)); int i = 0; if (compress && cache) { if (! cache->addSequence(tmp)) { cache = 0; } } if (compress && ! cache) { for (; i < out.count(); ++i) { if (out[i].addSequence(tmp)) { cache = &out[i]; break; } } } if (! compress || i == out.count()) { out.append(tmp); } } } } FindClose(h); } /*#elif defined(DJV_LINUX) struct linux_dirent64 { ino64_t d_ino; off64_t d_off; unsigned short d_reclen; unsigned char d_type; char d_name[]; }; int fd = open(path.toLatin1().data(), O_RDONLY | O_DIRECTORY); if (fd != -1) { djvMemoryBuffer<quint8> buf(djvMemory::megabyte); quint8 * p = buf.data(); while (1) { int readCount = syscall(SYS_getdents64, fd, p, buf.size()); if (-1 == readCount) break; if (0 == readCount) break; for (int i = 0; i < readCount;) { struct linux_dirent64 * de = (struct linux_dirent64 *)(p + i); if (de->d_ino != DT_UNKNOWN) { size_t l = strlen(de->d_name); if (! isDotDir(de->d_name, l)) { if (! out.count()) { out.append(djvFileInfo(fixedPath + de->d_name)); } else { const djvFileInfo tmp(fixedPath + de->d_name); int i = 0; if (compress && cache) { if (! cache->addSequence(tmp)) { cache = 0; } } if (compress && ! cache) { for (; i < out.count(); ++i) { if (out[i].addSequence(tmp)) { cache = &out[i]; break; } } } if (! compress || i == out.count()) { out.append(tmp); } } } } i += de->d_reclen; } } close (fd); } */ #else // DJV_WINDOWS DIR * dir = opendir(path.toLatin1().data()); if (dir) { struct dirent * de = 0; while ((de = readdir(dir)) != 0) { const char * p = de->d_name; const int l = strlen(p); if (! isDotDir(p, l)) { if (! out.count()) { out.append(djvFileInfo(fixedPath + QString(p))); } else { const djvFileInfo tmp(fixedPath + QString(p)); int i = 0; if (compress && cache) { if (! cache->addSequence(tmp)) { cache = 0; } } if (compress && ! cache) { for (; i < out.count(); ++i) { if (out[i].addSequence(tmp)) { cache = &out[i]; break; } } } if (! compress || i == out.count()) { out.append(tmp); } } } } closedir(dir); } #endif // DJV_WINDOWS for (int i = 0; i < out.count(); ++i) { out[i]._sequence.sort(); } if (djvSequence::COMPRESS_RANGE == compress) { for (int i = 0; i < out.count(); ++i) { if (out[i]._sequence.frames.count()) { out[i]._sequence.setFrames( out[i]._sequence.start(), out[i]._sequence.end()); } } } for (int i = 0; i < out.count(); ++i) { if (djvFileInfo::SEQUENCE == out[i].type()) { out[i]._number = djvSequenceUtil::sequenceToString(out[i]._sequence); } } return out; }