-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.cpp
More file actions
28 lines (25 loc) · 825 Bytes
/
io.cpp
File metadata and controls
28 lines (25 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/////////////////////////////////////////////////////////////////////////////
// Name: io.cpp
// Purpose: File load/save methods
// Author: Jan Buchholz
// Created: 2025-11-19
// Changed: 2026-04-06
/////////////////////////////////////////////////////////////////////////////
#include "io.h"
#include <QDir>
#include "constants.h"
int Io::save(const QString& fileName, const QByteArray& payload) {
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) return MSG_WRITE_ERROR;
file.write(payload);
file.close();
return MSG_OK;
}
int Io::load(const QString& fileName, QByteArray *payload) {
payload->clear();
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) return MSG_READ_ERROR;
*payload = file.readAll();
file.close();
return MSG_OK;
}