| 321 | } |
| 322 | |
| 323 | void SourceData::readAndPreprocess(const QByteArray& encoding, bool bAutoDetect) |
| 324 | { |
| 325 | QTemporaryFile fileIn1, fileOut1; |
| 326 | QString fileNameIn1; |
| 327 | QString fileNameOut1; |
| 328 | QString fileNameIn2; |
| 329 | QString fileNameOut2; |
| 330 | |
| 331 | // Detect the input for the preprocessing operations |
| 332 | if(!mFromClipBoard) |
| 333 | { |
| 334 | //Routine result of directory compare finding a file that isn't in all locations. |
| 335 | if(!m_fileAccess.isValid()) return; |
| 336 | |
| 337 | mEncoding = encoding; |
| 338 | if(mEncoding.isEmpty()) |
| 339 | mEncoding = u8"UTF-8"; |
| 340 | |
| 341 | assert(!m_fileAccess.exists() || !m_fileAccess.isDir()); |
| 342 | if(!m_fileAccess.isNormal()) |
| 343 | { |
| 344 | mErrors.append(i18n("%1 is not a normal file.", m_fileAccess.prettyAbsPath())); |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | if(m_fileAccess.isLocal()) |
| 349 | { |
| 350 | fileNameIn1 = m_fileAccess.absoluteFilePath(); |
| 351 | } |
| 352 | else // File is not local: create a temporary local copy: |
| 353 | { |
| 354 | if(m_tempInputFileName.isEmpty()) |
| 355 | { |
| 356 | m_fileAccess.createLocalCopy(); |
| 357 | m_tempInputFileName = m_fileAccess.getTempName(); |
| 358 | } |
| 359 | |
| 360 | fileNameIn1 = m_tempInputFileName; |
| 361 | } |
| 362 | } |
| 363 | else // The input was set via setData(), probably from clipboard. |
| 364 | { |
| 365 | /* |
| 366 | Used to happen during early startup this is now a bug. |
| 367 | */ |
| 368 | assert(!m_tempInputFileName.isEmpty()); |
| 369 | |
| 370 | fileNameIn1 = m_tempInputFileName; |
| 371 | mEncoding = "UTF-8"; |
| 372 | } |
| 373 | |
| 374 | if(bAutoDetect) |
| 375 | { |
| 376 | mEncoding = detectEncoding(fileNameIn1).value_or(encoding); |
| 377 | } |
| 378 | |
| 379 | QByteArray pEncoding1 = getEncoding(); |
| 380 | QByteArray pEncoding2 = getEncoding(); |