summaryrefslogtreecommitdiff
path: root/src/util/directory.h
blob: 9666c14e4bcf84ba9f850b240f825762a03b2782 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2008 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef UTIL_FILESDIRECTORYUTIL_H
#define UTIL_FILESDIRECTORYUTIL_H

#include <QDir>
#include <QIcon>
#include <QString>


namespace util {

/**
 * Tools for working with directories.
 * @author The BibleTime team <info@bibletime.info>
*/
namespace directory {

/**
  \brief Initializes the directory cache and returns whether it was successful.
  \note When this function returns unsuccessfully, the program should exit.
*/
bool initDirectoryCache();

/** Removes the given dir with all it's files and subdirs.
 *
 * \todo Check if it's suitable for huge dir trees, as it holds a QDir object
 * for each of it at the same time in the deepest recursion.
 * For really deep dir tree this may lead to a stack overflow.
 */
void removeRecursive(const QString &dir);

/** Returns the size of the directory including the size of all its files
 * and its subdirs.
 *
 * \todo Check if it's suitable for huge dir trees, as it holds a QDir object
 * for each of it at the same time in the deepest recursion.
 * For really deep dir tree this may lead to a stack overflow.
 *
 * @return The size of the dir in bytes
 */
unsigned long getDirSizeRecursive(const QString &dir);

/** Recursively copies one directory into another.  This WILL OVERWRITE
 * any existing files of the same name, and WILL NOT handle symlinks.
 *
 * This probably won't need to be used for large directory structures.
 */
void copyRecursive(const QString &src, const QString &dest);

/** Convert directory path separators to those for each platform 
 *  Windows = "\", Others = "/"
 */
QString convertDirSeparators(const QString& path);

#ifdef Q_WS_WIN  // Windows only directories

/** Return the path to the sword dir., Windows only 
    C:\Program Files\BibleTime\share\sword
 */
QDir getApplicationSwordDir();

/** Return the path to the %ALLUSERSPROFILE%\Sword directory */
QDir getSharedSwordDir();

#endif

/** Return the path to the icons. */
QDir getIconDir();

/** Return the path to the javascript. */
QDir getJavascriptDir();

/** Return the path to the license. */
QDir getLicenseDir();

/** Returns an icon with the given name */
QIcon getIcon(const QString &name);

/** Return the path to the pictures. */
QDir getPicsDir();

/** Return the path to the translation files. */
QDir getLocaleDir();

/** Return the path to the handbook files, either of the current locale or en as fallback. */
QDir getHandbookDir();

/** Return the path to the bible study howto files, either of the current locale or en as fallback. */
QDir getHowtoDir();

/** Return the path to the default display template files. */
QDir getDisplayTemplatesDir();

/** Return the path to the user's home directory.
    %APPDATA% on Windows
	$HOME on linux */
QDir getUserHomeDir();

/** Return the path to the user's home .sword (or Sword) directory.
    %APPDATA%\Sword on Windows
	$HOME\.sword on linux */
QDir getUserHomeSwordDir();

/** Return the path to the user's home .sword (or Sword) mods.d directory.
    %APPDATA%\Sword\mods.d on Windows
	$HOME\.sword\mods.d on linux */
QDir getUserHomeSwordModsDir();

/** Return the path to the user's settings directory.*/
QDir getUserBaseDir();

/** Return the path to the user's sessions directory.*/
QDir getUserSessionsDir();

/** Return the path to the user's cache directory.*/
QDir getUserCacheDir();

/** Return the path to the user's indices directory.*/
QDir getUserIndexDir();

/** Return the path to the user's custom display templates directory.*/
QDir getUserDisplayTemplatesDir();

} // namespace directory
} // namespace util

#endif