Marble

CacheStoragePolicy.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org>
4//
5
6
7// Own
8#include "CacheStoragePolicy.h"
9
10// Qt
11#include <QDir>
12
13using namespace Marble;
14
15CacheStoragePolicy::CacheStoragePolicy( const QString &cacheDirectory )
16 : m_cache( cacheDirectory )
17{
18 if ( ! QDir( cacheDirectory ).exists() )
19 QDir::root().mkpath( cacheDirectory );
20}
21
22CacheStoragePolicy::~CacheStoragePolicy()
23{
24}
25
26bool CacheStoragePolicy::fileExists( const QString &fileName ) const
27{
28 return m_cache.exists( fileName );
29}
30
31bool CacheStoragePolicy::updateFile( const QString &fileName, const QByteArray &data )
32{
33 if ( !m_cache.insert( fileName, data ) ) {
34 m_errorMsg = QObject::tr("Unable to insert data into cache");
35 return false;
36 }
37
38 return true;
39}
40
41void CacheStoragePolicy::clearCache()
42{
43 m_cache.clear();
44}
45
46QString CacheStoragePolicy::lastErrorMessage() const
47{
48 return m_errorMsg;
49}
50
51QByteArray CacheStoragePolicy::data( const QString &fileName )
52{
53 QByteArray data;
54 m_cache.find( fileName, data );
55
56 return data;
57}
58
59void CacheStoragePolicy::setCacheLimit( quint64 bytes )
60{
61 m_cache.setCacheLimit( bytes );
62}
63
64quint64 CacheStoragePolicy::cacheLimit() const
65{
66 return m_cache.cacheLimit();
67}
68
69#include "moc_CacheStoragePolicy.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
bool mkpath(const QString &dirPath) const const
QDir root()
QString tr(const char *sourceText, const char *disambiguation, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:57:57 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.