BibleTime
directory.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include <cstddef>
16 #include <QtGlobal>
17 #include <QString>
18 
19 
20 class QDir;
21 
22 namespace util {
23 
24 /**
25  * Tools for working with directories.
26 */
27 namespace directory {
28 
29 /**
30  \brief Initializes the directory cache and returns whether it was successful.
31  \note When this function returns unsuccessfully, the program should exit.
32 */
33 bool initDirectoryCache();
34 
35 /** Returns the size of the directory including the size of all its files
36  * and its subdirs.
37  *
38  * \todo Check if it's suitable for huge dir trees, as it holds a QDir object
39  * for each of it at the same time in the deepest recursion.
40  * For really deep dir tree this may lead to a stack overflow.
41  *
42  * @return The size of the dir in bytes
43  */
44 ::qint64 getDirSizeRecursive(QString const & dir);
45 
46 #if defined(Q_OS_WIN) // Windows only directory
47 /** Return the path to the sword dir., Windows only
48  C:\Program Files\BibleTime\share\sword
49  */
50 const QDir &getApplicationSwordDir();
51 
52 /** Return the path to the shared Sword directory */
53 const QDir &getSharedSwordDir();
54 
55 #elif defined(Q_OS_MAC) // Mac only directories
56 /**
57  * Path to the Sword locales
58  */
59 const QDir &getSwordLocalesDir();
60 #endif
61 
62 /** Return the path to the icons. */
63 const QDir &getIconDir();
64 
65 /** Return the path to the license. */
66 QString const & getLicensePath();
67 
68 /** Return the path to the pictures. */
69 const QDir &getPicsDir();
70 
71 /** Return the path to the translation files. */
72 const QDir &getLocaleDir();
73 
74 /** \returns an absolute path to a handbook or QString() if not found. */
75 QString getHandbook();
76 
77 /** \returns an absolute path to a howto or QString() if not found. */
78 QString getHowto();
79 
80 /** Return the path to the default display template files. */
81 const QDir &getDisplayTemplatesDir();
82 
83 /** Return the path to the user's home directory.
84  %APPDATA% on Windows
85  $HOME on linux */
86 const QDir &getUserHomeDir();
87 
88 /** Return the path to the user's home .sword (or Sword) directory.
89  %APPDATA%\Sword on Windows
90  $HOME\.sword on linux */
91 const QDir &getUserHomeSwordDir();
92 
93 /** Return the path to the user's settings directory.*/
94 const QDir &getUserBaseDir();
95 
96 /** Return the path to the user's cache directory.*/
97 const QDir &getUserCacheDir();
98 
99 /** Return the path to the user's indices directory.*/
100 const QDir &getUserIndexDir();
101 
102 /** Return the path to the user's custom display templates directory.*/
103 const QDir &getUserDisplayTemplatesDir();
104 
105 } // namespace directory
106 } // namespace util
const QDir & getLocaleDir()
Definition: directory.cpp:283
const QDir & getUserCacheDir()
Definition: directory.cpp:346
QString getHandbook()
Definition: directory.cpp:326
const QDir & getUserHomeSwordDir()
Definition: directory.cpp:342
QString const & getLicensePath()
Definition: directory.cpp:272
QDir const & getIconDir()
Definition: directory.cpp:265
const QDir & getDisplayTemplatesDir()
Definition: directory.cpp:330
const QDir & getUserHomeDir()
Definition: directory.cpp:338
const QDir & getUserIndexDir()
Definition: directory.cpp:350
::qint64 getDirSizeRecursive(QString const &dir)
Definition: directory.cpp:226
bool initDirectoryCache()
Initializes the directory cache and returns whether it was successful.
Definition: directory.cpp:67
const QDir & getUserBaseDir()
Definition: directory.cpp:334
const QDir & getUserDisplayTemplatesDir()
Definition: directory.cpp:354
const QDir & getPicsDir()
Definition: directory.cpp:279
QString getHowto()
Definition: directory.cpp:328
Definition: cp1252.cpp:24