MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / cp_rf

Function cp_rf

src/core/UBForeignObjectsHandler.cpp:100–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100static bool cp_rf(const QString &what, const QString &where)
101{
102 QFileInfo whatFi(what);
103 QFileInfo whereFi = QFileInfo(where);
104
105 if (!whatFi.exists()) {
106 qDebug() << what << "does not exist" << Q_FUNC_INFO;
107 return false;
108 } else if (whatFi.isFile()) {
109 QString whereDir = where.section("/", 0, -2, QString::SectionSkipEmpty | QString::SectionIncludeLeadingSep);
110 QString newFilePath = where;
111 if (!whereFi.exists()) {
112 QDir().mkpath(whereDir);
113 } else if (whereFi.isDir()) {
114 newFilePath = whereDir + "/" + whatFi.fileName();
115 }
116 if (QFile::exists(newFilePath)) {
117 QFile::remove(newFilePath);
118 }
119 if (!QFile::copy(what, newFilePath)) {
120 qDebug() << "can't copy" << what << "to" << where << Q_FUNC_INFO;
121 return false;
122 }
123 return true;
124 } else if (whatFi.isDir()) {
125
126 if (whereFi.isFile() && whereFi.fileName().toLower() == whatFi.fileName().toLower()) {
127 qDebug() << "can't copy dir" << what << "to file" << where << Q_FUNC_INFO;
128 return false;
129 } else if (whereFi.isDir()) {
130 rm_r(where);
131 }
132
133 QDir().mkpath(where);
134
135 QFileInfoList fList = QDir(what).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
136 foreach (QFileInfo sub, fList) {
137 if (!cp_rf(sub.absoluteFilePath(), where + "/" + sub.fileName()))
138 return false;
139 }
140 return true;
141 }
142 return true;
143}
144
145static QString thumbFileNameFrom(const QString &filePath)
146{

Callers 2

foreachFunction · 0.85
cureNCopyMethod · 0.85

Calls 2

existsFunction · 0.85
rm_rFunction · 0.85

Tested by

no test coverage detected