Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qt File XOR Processor

Multithreaded Qt application for block-wise XOR processing of large files with pause, resume, cancellation and progress tracking.

The project was originally developed as a C++/Qt technical interview assignment. The task was to create a Windows application capable of processing large binary files without blocking the graphical interface.

Overview

The application searches for files matching a user-defined mask, processes them using a repeating 8-byte XOR key, and saves the resulting files to the selected directory.

The implementation is designed for large files: input data is processed in blocks instead of loading the entire file into memory.

The GUI remains responsive during processing because the file-processing logic runs in a dedicated QThread.

Features

  • Processing files using an 8-byte XOR key
  • Block-wise processing of large files
  • Recursive search through input directories
  • Configurable input file mask
  • Configurable input and output directories
  • Optional deletion of source files after successful processing
  • Overwrite or automatic output filename generation
  • One-time processing mode
  • Periodic processing mode
  • Processing interval configuration
  • Progress tracking for the current file
  • Progress tracking for the complete file set
  • Pause and resume processing
  • Cancellation of the current processing operation
  • Graceful application shutdown during processing
  • GUI remains responsive while files are being processed

Processing Architecture

The application separates the graphical interface from the file-processing logic.

┌─────────────────────────────┐
│         MainWindow          │
│                             │
│  Configuration              │
│  Progress bars              │
│  User controls              │
└──────────────┬──────────────┘
               │
               │ Qt signals / slots
               ▼
┌─────────────────────────────┐
│           Worker            │
│                             │
│  File discovery             │
│  Block-wise processing      │
│  Progress reporting         │
│  Pause / Resume             │
│  Cancellation               │
└──────────────┬──────────────┘
               │
               │ moved to
               ▼
┌─────────────────────────────┐
│          QThread            │
└─────────────────────────────┘

MainWindow is responsible for the user interface, while Worker performs the potentially long-running file operations.

The worker object is moved to a dedicated QThread, preventing file processing from blocking the GUI event loop.

Large File Processing

The program is designed to process files significantly larger than available RAM.

Instead of reading an entire file into memory, the input is processed in fixed-size blocks:

Input file
┌──────────────────────────────────────────────┐
│ Block 1 │ Block 2 │ Block 3 │ ... │ Block N │
└──────────────────────────────────────────────┘
     │
     ▼
   XOR key
     │
     ▼
Output file

The current implementation uses a 4 MiB processing block.

For each block:

  1. data is read from the input file;
  2. the block is checked against the current pause/cancellation state;
  3. each byte is XORed with the corresponding byte of the repeating 8-byte key;
  4. the processed block is written to the output file;
  5. progress is reported to the GUI.

This approach keeps memory consumption bounded by the processing buffer rather than by the total input file size.

XOR Processing

The user specifies an 8-byte key in hexadecimal form.

For example:

1234567890ABCDEF

The key is converted from hexadecimal representation into an 8-byte QByteArray.

The key is then applied cyclically to the input data:

Data:  A1 B2 C3 D4 E5 F6 17 28 A9 ...
Key:   12 34 56 78 90 AB CD EF 12 ...
       ───────────────────────────────
XOR:   B3 86 95 AC 75 5D DA C7 BB ...

The operation is performed independently for every processed block.

Pause and Resume

One of the main requirements of the assignment was the ability to pause processing and continue from the same point.

The implementation uses:

  • QMutex
  • QWaitCondition

The worker checks whether a pause has been requested between processing blocks.

When paused, the worker waits on a QWaitCondition rather than continuously polling the state.

Processing
    │
    ▼
pause requested?
    │
   yes
    │
    ▼
QWaitCondition::wait()
    │
    │
    │ resume
    ▼
continue processing

The input and output QFile objects remain associated with the current processing operation, so after resuming the next block is read from the current file position.

Cancellation

Pause and cancellation are implemented as separate mechanisms.

A pause is a temporary synchronization state:

pause → wait → resume

Cancellation is a request to terminate the current processing operation:

cancel → stop processing

The worker uses an atomic cancellation flag so that the cancellation request can be safely communicated to the processing thread.

The worker also wakes the condition variable when cancellation is requested, allowing a worker currently waiting in the paused state to terminate instead of remaining blocked.

Progress Reporting

The application provides two levels of progress information:

Current file

Shows the percentage of the currently processed file.

Complete file set

Shows how many matching files have already been processed.

The worker emits progress information through Qt signals, while MainWindow updates the corresponding progress bars.

This keeps UI updates in the GUI thread instead of manipulating widgets directly from the worker thread.

File Handling

The application supports:

  • configurable input file masks;
  • recursive directory traversal;
  • configurable output directory;
  • configurable output filename;
  • optional source-file deletion;
  • duplicate filename handling.

When the duplicate handling mode uses a counter, the application searches for an available filename:

result.bin
result1.bin
result2.bin
result3.bin
...

This prevents an existing output file from being overwritten when the corresponding option is selected.

Processing Modes

The application supports two execution modes.

Single run

Processes all matching files once and finishes.

Timer mode

Periodically checks the configured input directory and starts processing according to the selected interval.

This allows the application to be used for repeated processing of incoming files.

User Interface

The interface provides configuration controls for:

  • input file mask;
  • source directory;
  • output directory;
  • output filename;
  • source-file deletion;
  • duplicate filename handling;
  • processing mode;
  • timer interval;
  • XOR key.

During processing, the interface displays the current status and progress.

gui1

gui2

gui3

MainWindow

Responsible for:

  • creating and managing the GUI;
  • collecting user configuration;
  • starting and controlling processing;
  • displaying progress;
  • displaying processing status.

Worker

Responsible for:

  • finding matching files;
  • opening input and output files;
  • block-wise XOR processing;
  • progress reporting;
  • pause/resume synchronization;
  • cancellation;
  • source-file deletion;
  • output filename generation.

Settings

Contains the processing configuration passed from the GUI to the worker.

Technologies

  • C++
  • Qt 6
  • Qt Widgets
  • QThread
  • QMutex
  • QWaitCondition
  • atomic
  • QFile / QIODevice
  • QDirIterator
  • Qt signals and slots
  • qmake
  • MinGW 64-bit

Building

The project contains a Qt .pro file as required by the original assignment.

Requirements

  • Windows
  • Qt 6
  • Qt Creator
  • MinGW 64-bit

Notes

The project is an implementation of the original technical assignment and is intended primarily as a demonstration of C++/Qt programming techniques.

The XOR operation itself is intentionally simple. The main technical focus of the project is the architecture around large-file processing, GUI responsiveness, thread synchronization and cancellation.

About

Multithreaded Qt application for block-wise XOR processing of large files with pause, resume, cancellation and progress tracking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages