Repository navigation
Expand file tree
/
Copy pathhelpers.h
More file actions
90 lines (82 loc) · 2.79 KB
/
Copy pathhelpers.h
File metadata and controls
90 lines (82 loc) · 2.79 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Copyright (C) 2021 Jo2003 (olenka.joerg@gmail.com)
* This file is part of cd2netmd_gui
*
* cd2netmd is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cd2netmd is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*/
#pragma once
#include <QFile>
#include <QString>
#include <QByteArray>
#include "defines.h"
///
/// \brief put number to file
/// \param num number to put
/// \param f file to put to
/// \param sz size of bytes to write
/// \return 0 -> ok; else -> -1
///
int putNum(uint32_t num, QFile &f, size_t sz);
///
/// \brief UTF-8 to MiniDisc text
/// \param from string to convert
/// \return converted string in byte array
///
QByteArray utf8ToMd(const QString& from);
///
/// \brief mini disc text to utf-8
/// \param from SHIFT-JIS encoded text
/// \return unicode string
///
QString mdToUtf8(const QByteArray& ba);
///
/// \brief convert umlaut and accents
/// \param s string to convert
/// \return ref. to converted string
///
QString& deUmlaut(QString& s);
//------------------------------------------------------------------------------
//! @brief extract title from file name
//!
//! @param[in] fName file name
//!
//! @return title
//------------------------------------------------------------------------------
QString titleFromFileName(const QString& fName);
//--------------------------------------------------------------------------
//! @brief get uint from array
//!
//! @param[in] start char[] start of array
//! @param[in] sz int number of bytes to use
//!
//! @return uint64_t
//--------------------------------------------------------------------------
uint64_t arrayToUint(const char start[], int sz);
//--------------------------------------------------------------------------
//! @brief create a temporary file name from template
//!
//! @param[in] templ file name template,
//! 'X' will be replaced by random char
//!
//! @return file name
//--------------------------------------------------------------------------
QString tempFileName(const QString& templ);
//--------------------------------------------------------------------------
//! @brief create a pseudo random number in range a ... b
//!
//! @param[in] a range start
//! @param[in] b range end
//!
//! @return value in between a and b
//--------------------------------------------------------------------------
int randRange(int a, int b);