MCPcopy Create free account
hub / github.com/KDE/kdiff3 / readAndPreprocess

Method readAndPreprocess

src/SourceData.cpp:323–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void 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();

Callers 8

runTestFunction · 0.80
mainInitMethod · 0.80
testReadMethod · 0.80
testEOLStyleMethod · 0.80
trailingEOLTestMethod · 0.80
testLineDataMethod · 0.80
testWhiteLineCommentMethod · 0.80

Calls 15

LineDataClass · 0.85
isNormalMethod · 0.80
appendMethod · 0.80
isBrokenLinkMethod · 0.80
fileNameMethod · 0.80
startMethod · 0.80
byteCountMethod · 0.80
preprocessMethod · 0.80
ignoreCommentsMethod · 0.80
copyBufFromMethod · 0.80
push_backMethod · 0.80
setPureCommentMethod · 0.80

Tested by 7

runTestFunction · 0.64
testReadMethod · 0.64
testEOLStyleMethod · 0.64
trailingEOLTestMethod · 0.64
testLineDataMethod · 0.64
testWhiteLineCommentMethod · 0.64