Mercurial > minori
annotate src/core/filesystem.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 02:43:44 -0400 |
parents | c130f47f6f48 |
children |
rev | line source |
---|---|
36 | 1 #include "core/filesystem.h" |
15 | 2 #include "core/config.h" |
62 | 3 #include "core/strings.h" |
250 | 4 |
5 #include <QStandardPaths> | |
6 | |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
7 #include <filesystem> |
2 | 8 |
11 | 9 namespace Filesystem { |
10 | |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
11 /* this runs fs::create_directories() on the |
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
12 PARENT directory. */ |
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
13 void CreateDirectories(const std::filesystem::path& path) { |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
14 if (path.empty()) |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
15 return; |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
16 |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
17 const auto& parent = path.parent_path(); |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
18 if (!std::filesystem::exists(parent)) |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
138
diff
changeset
|
19 std::filesystem::create_directories(parent); |
11 | 20 } |
21 | |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
22 std::filesystem::path GetDotPath() { |
250 | 23 /* |
24 * Windows: ~/AppData/Roaming/Minori | |
25 * macOS: ~/Library/Application Support/Minori | |
26 * ...: ~/.config/minori | |
27 * | |
28 * FIXME: are windows and mac properly cased? | |
258 | 29 */ |
9 | 30 #ifdef WIN32 |
250 | 31 return Strings::ToUtf8String(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); |
32 #else | |
33 return Strings::ToUtf8String(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)); | |
34 #endif | |
45
4b05bc7668eb
filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents:
44
diff
changeset
|
35 } |
4b05bc7668eb
filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents:
44
diff
changeset
|
36 |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
37 std::filesystem::path GetConfigPath() { |
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
38 return GetDotPath() / CONFIG_NAME; |
118
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
106
diff
changeset
|
39 } |
39521c47c7a3
*: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents:
106
diff
changeset
|
40 |
135
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
41 std::filesystem::path GetAnimeDBPath() { |
0a458cb26ff4
filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents:
134
diff
changeset
|
42 return GetDotPath() / "anime" / "db.json"; |
45
4b05bc7668eb
filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents:
44
diff
changeset
|
43 } |
4b05bc7668eb
filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents:
44
diff
changeset
|
44 |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
221
diff
changeset
|
45 std::filesystem::path GetTorrentsPath() { |
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
221
diff
changeset
|
46 return GetDotPath() / "torrents"; |
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
221
diff
changeset
|
47 } |
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
221
diff
changeset
|
48 |
15 | 49 } // namespace Filesystem |