MCPcopy Create free account
hub / github.com/MultiMC/Launcher / operator()

Method operator()

launcher/FileSystem.cpp:108–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool copy::operator()(const QString &offset)
109{
110 //NOTE always deep copy on windows. the alternatives are too messy.
111 #if defined Q_OS_WIN32
112 m_followSymlinks = true;
113 #endif
114
115 auto src = PathCombine(m_src.absolutePath(), offset);
116 auto dst = PathCombine(m_dst.absolutePath(), offset);
117
118 QFileInfo currentSrc(src);
119 if (!currentSrc.exists())
120 return false;
121
122 if(!m_followSymlinks && currentSrc.isSymLink())
123 {
124 qDebug() << "creating symlink" << src << " - " << dst;
125 if (!ensureFilePathExists(dst))
126 {
127 qWarning() << "Cannot create path!";
128 return false;
129 }
130 return QFile::link(currentSrc.symLinkTarget(), dst);
131 }
132 else if(currentSrc.isFile())
133 {
134 qDebug() << "copying file" << src << " - " << dst;
135 if (!ensureFilePathExists(dst))
136 {
137 qWarning() << "Cannot create path!";
138 return false;
139 }
140 return QFile::copy(src, dst);
141 }
142 else if(currentSrc.isDir())
143 {
144 qDebug() << "recursing" << offset;
145 if (!ensureFolderPathExists(dst))
146 {
147 qWarning() << "Cannot create path!";
148 return false;
149 }
150 QDir currentDir(src);
151 for(auto & f : currentDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System))
152 {
153 auto inner_offset = PathCombine(offset, f);
154 // ignore and skip stuff that matches the blacklist.
155 if(m_blacklist && m_blacklist->matches(inner_offset))
156 {
157 continue;
158 }
159 if(!operator()(inner_offset))
160 {
161 qWarning() << "Failed to copy" << inner_offset;
162 return false;
163 }
164 }
165 }

Callers

nothing calls this directly

Calls 6

PathCombineFunction · 0.85
ensureFilePathExistsFunction · 0.85
copyClass · 0.85
ensureFolderPathExistsFunction · 0.85
existsMethod · 0.80
matchesMethod · 0.45

Tested by

no test coverage detected