/* $Id$ */ /* * Cantus Tag Editor * Copyright © 2002-2004 by Samuel Abels * Copyright © 2007 by Tim Huetz * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see **/ #ifdef HAVE_CONFIG_H # include #endif #include //#define _DEBUG_ /****************************************************************************** * Constructor/Destructor ******************************************************************************/ /* Constructor. */ FileInfoCache::FileInfoCache(void) { } /* Destructor. */ FileInfoCache::~FileInfoCache(void) { #ifdef _DEBUG_ printf("FileInfoCache::~FileInfoCache(): Called.\n"); #endif } /****************************************************************************** * Public ******************************************************************************/ /* Stores a copy of the pluginlist in the object. * This is required because the object invokes the FileInfo read function, * which needs a plugin as an argument. */ FileInfo* FileInfoCache::operator[](std::string filename) { #ifdef _DEBUG_ printf("FileInfoCache::operator[]: Called.\n"); #endif glong inode = inodemap[filename]; // Try to get the file from the cache. FileInfo *info = cache[inode]; if (info) return info; info = new FileInfo(filename); // Not in the cache, so read it. inode = info->get_inode(); if (inode == 0) { // Stat failed, so return. signal_file_stat_failed.emit(info); return NULL; } inodemap[filename] = inode; // Stat success, so hold. cache[inode] = info; return info; } /****************************************************************************** * Private ******************************************************************************/