void MetaDataStore::maybe_initialise_() { if (not harakoon_.initialized()) { LOG_INFO("Trying to initialize filesystem metadata store"); try { harakoon_.initialize(DirectoryEntry(DirectoryEntry::Type::Directory, alloc_inode(), default_directory_permissions, UserId(::getuid()), GroupId(::getgid()))); LOG_INFO("Initialized filesystem metadata store"); } catch (ara::error_assertion_failed&) { // Another cluster node could've beaten us to it: if (not harakoon_.initialized()) { throw; } else { LOG_INFO("Filesystem metadata store already initialized by another node"); } } } else { LOG_INFO("Filesystem metadata store already initialized"); } }
QIODevice* CFBWriter::openSubStream(const QString &streamName) { DirectoryEntry* parent = &m_entries[0]; QStringList parts = streamName.split('/'); for (int i = 0; i < parts.size()-1; i++) { if (parent->children.contains(parts[i])) { parent = parent->children[parts[i]]; Q_ASSERT(parent->type == DirectoryEntry::Storage); } else { m_entries.append(DirectoryEntry(m_entries.size(), parts[i], DirectoryEntry::Storage)); parent->children[parts[i]] = &m_entries.last(); parent = &m_entries.last(); } } Q_ASSERT(!parent->children.contains(parts.last())); m_entries.append(DirectoryEntry(m_entries.size(), parts.last(), DirectoryEntry::Stream)); parent->children[parts.last()] = &m_entries.last(); return new StreamIODevice(*this, m_entries.last()); }
/** * Constructor of the Cache */ Cache::Cache(int nPointsIn, int cacheSizeIn) { directory.reserve(nPointsIn); nPoints = nPointsIn; cacheSize = cacheSizeIn; occupancy = 0; hits = 0; compulsoryMisses = 0; capacityMisses = 0; for(size_t i=0; i < nPoints; i++) directory.push_back(DirectoryEntry()); }
vector<DirectoryEntry> WiiOS::ReadDirectory(string path) { vector<DirectoryEntry> contents; struct stat st; struct dirent* dirEntry = NULL; DIR* dirStruct; if ((dirStruct = opendir(path.c_str()))) { if(dirStruct->dirData != NULL) { while( (dirEntry = readdir(dirStruct)) != NULL ) { string filepath = ""; bool isFolder = false; bool statFailed = true; int extra = 0; if (path == "/") { filepath = path; filepath += dirEntry->d_name; } else { filepath = path; filepath += "/"; filepath += dirEntry->d_name; } if(stat(filepath.c_str(), &st) == 0) { statFailed = false; if(st.st_mode & S_IFDIR) { isFolder = true; } } else { statFailed = true; } contents.push_back(DirectoryEntry(dirEntry->d_name, isFolder, statFailed, extra)); } } } return contents; }
System::Directory System::opendir(const std::string& pathname, const std::string& pattern) { Directory dir_list; #ifndef WIN32 DIR* dp; dirent* de; dp = ::opendir(pathname.c_str()); if (dp == 0) { raise_exception(std::runtime_error, pathname << ": " << strerror(errno)); } else { while ((de = ::readdir(dp)) != 0) { if (fnmatch(pattern.c_str(), de->d_name, FNM_PATHNAME) == 0) { struct stat buf; stat((Pathname::join(pathname, de->d_name)).c_str (), &buf); if (strcmp(de->d_name, "..") != 0 && strcmp(de->d_name, ".") != 0) { if (S_ISDIR(buf.st_mode)) { dir_list.push_back(DirectoryEntry(de->d_name, DE_DIRECTORY)); } else { dir_list.push_back(DirectoryEntry(de->d_name, DE_FILE)); } } } } closedir(dp); } #else /* WIN32 */ WIN32_FIND_DATA coFindData; std::string FindFileDir = Pathname::join(pathname, pattern); HANDLE hFind = FindFirstFile(TEXT(FindFileDir.c_str()),&coFindData); if (hFind == INVALID_HANDLE_VALUE) { if (GetLastError() != ERROR_FILE_NOT_FOUND) log_error("System: Couldn't open: %1%", pathname); } else { do { if (strcmp(coFindData.cFileName, "..") != 0 && strcmp(coFindData.cFileName, ".") != 0) { if (coFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { dir_list.push_back(DirectoryEntry(coFindData.cFileName, System::DE_DIRECTORY)); } else { dir_list.push_back(DirectoryEntry(coFindData.cFileName, System::DE_FILE)); } } } while (FindNextFile(hFind,&coFindData)); FindClose(hFind); } #endif return dir_list; }