Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / client / ryzom_installer / src / filescleaner.cpp
blob2dd89eb0064ffb0545828b42559cf42b5b4d5b01
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "stdpch.h"
18 #include "filescleaner.h"
19 #include "operation.h"
21 #ifdef DEBUG_NEW
22 #define new DEBUG_NEW
23 #endif
25 CFilesCleaner::CFilesCleaner(IOperationProgressListener *listener):m_listener(listener)
29 CFilesCleaner::~CFilesCleaner()
33 void CFilesCleaner::setDirectory(const QString &src)
35 m_directory = src;
38 bool CFilesCleaner::exec()
40 if (m_directory.isEmpty()) return false;
42 if (m_listener) m_listener->operationPrepare();
44 QDir dir(m_directory);
46 // directory doesn't exist
47 if (!dir.exists()) return false;
49 if (!dir.cd("data")) return false;
51 QStringList filter;
52 filter << "*.string_cache";
54 // certificate should be in gamedev.bnp now
55 filter << "*.pem";
57 if (dir.exists("packedsheets.bnp"))
59 filter << "*.packed_sheets";
60 filter << "*.packed";
63 // only .ref files should be there
64 filter << "exedll*.bnp";
66 // temporary files
67 QStringList files = dir.entryList(filter, QDir::Files);
69 // temporary directories
70 QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
72 // fonts directory is not needed anymore if fonts.bnp exists
73 if (!dir.exists("fonts.bnp")) dirs.removeAll("fonts");
75 if (m_listener)
77 m_listener->operationInit(0, files.size() + dirs.size());
78 m_listener->operationStart();
81 int filesCount = 0;
83 foreach(const QString &file, files)
85 dir.remove(file);
87 if (m_listener) m_listener->operationProgress(filesCount, file);
89 ++filesCount;
92 foreach(const QString &d, dirs)
94 if (dir.cd(d))
96 dir.removeRecursively();
97 dir.cdUp();
100 if (m_listener) m_listener->operationProgress(filesCount, d);
102 ++filesCount;
105 if (m_listener) m_listener->operationSuccess(files.size() + dirs.size());
107 return true;