61#ifdef PROEVALUATOR_DUAL_VFS
63# ifdef PROPARSER_THREAD_SAFE
64 QMutexLocker locker(&m_vmutex);
66 int idx = (flags & VfsCumulative) ? 1 : 0;
67 if (flags & VfsCreate) {
68 int &id = m_virtualFileIdMap[idx][fn];
70 id = ++s_fileIdCounter;
71 m_virtualIdFileMap[id] = fn;
75 int id = m_virtualFileIdMap[idx].value(fn);
76 if (id || (flags & VfsCreatedOnly))
80#ifdef PROPARSER_THREAD_SAFE
81 QMutexLocker locker(&s_mutex);
84 int &id = s_fileIdMap[fn];
86 id = ++s_fileIdCounter;
91 return s_fileIdMap.value(fn);
113 const QString &contents, QString *errStr)
115#ifndef PROEVALUATOR_FULL
116# ifdef PROEVALUATOR_THREAD_SAFE
117 QMutexLocker locker(&m_mutex);
119 QString *cont = &m_files[id];
121 if (mode & QIODevice::Append)
128 QFileInfo qfi(fileNameForId(id));
129 if (!QDir::current().mkpath(qfi.path())) {
130 *errStr = fL1S(
"Cannot create parent directory");
133 QByteArray bytes = contents.toLocal8Bit();
134 QFile cfile(qfi.filePath());
135 if (!(mode & QIODevice::Append) && cfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
136 if (cfile.readAll() == bytes) {
137 if (flags & VfsExecutable) {
138 cfile.setPermissions(cfile.permissions()
139 | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther);
141 cfile.setPermissions(cfile.permissions()
142 & ~(QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther));
148 if (!cfile.open(mode | QIODevice::WriteOnly | QIODevice::Text)) {
149 *errStr = cfile.errorString();
154 if (cfile.error() != QFile::NoError) {
155 *errStr = cfile.errorString();
158 if (flags & VfsExecutable)
159 cfile.setPermissions(cfile.permissions()
160 | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther);
167#ifndef PROEVALUATOR_FULL
168# ifdef PROEVALUATOR_THREAD_SAFE
169 QMutexLocker locker(&m_mutex);
171 auto it = m_files.constFind(id);
172 if (it != m_files.constEnd()) {
173 if (it->constData() == m_magicMissing.constData()) {
174 *errStr =
fL1S(
"No such file or directory");
177 if (it->constData() != m_magicExisting.constData()) {
184 QFile file(fileNameForId(id));
185 if (!file.open(QIODevice::ReadOnly)) {
186 if (!file.exists()) {
187#ifndef PROEVALUATOR_FULL
188 m_files[id] = m_magicMissing;
190 *errStr =
fL1S(
"No such file or directory");
193 *errStr = file.errorString();
196#ifndef PROEVALUATOR_FULL
197 m_files[id] = m_magicExisting;
201 if (bcont.startsWith(
"\xef\xbb\xbf")) {
203 *errStr =
fL1S(
"Unexpected UTF-8 BOM");
206 *contents = QString::fromLocal8Bit(bcont);
212#ifndef PROEVALUATOR_FULL
213# ifdef PROEVALUATOR_THREAD_SAFE
214 QMutexLocker locker(&m_mutex);
216 int id = idForFileName(fn, flags);
217 auto it = m_files.constFind(id);
218 if (it != m_files.constEnd())
219 return it->constData() != m_magicMissing.constData();
223 bool ex = IoUtils::fileType(fn) == IoUtils::FileIsRegular;
224#ifndef PROEVALUATOR_FULL
225 m_files[id] = ex ? m_magicExisting : m_magicMissing;