annotate src/core/filesystem.cc @ 376:5d716acb2774

gui/dialog/dialog: fix win32 build
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 12:28:38 -0400
parents 47c9f8502269
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 18
diff changeset
1 #include "core/filesystem.h"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
2 #include "core/config.h"
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 61
diff changeset
3 #include "core/strings.h"
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
4
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
5 #include <QStandardPaths>
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
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
Paper <mrpapersonic@gmail.com>
parents: 1
diff changeset
8
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 namespace Filesystem {
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
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. */
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
13 void CreateDirectories(const std::filesystem::path &path)
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
14 {
158
80d6b28eb29f dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
15 if (path.empty())
80d6b28eb29f dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
16 return;
80d6b28eb29f dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
17
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
18 const auto &parent = path.parent_path();
158
80d6b28eb29f dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
19 if (!std::filesystem::exists(parent))
80d6b28eb29f dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents: 138
diff changeset
20 std::filesystem::create_directories(parent);
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
21 }
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
22
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
23 std::filesystem::path GetDotPath()
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
24 {
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
25 /*
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
26 * Windows: ~/AppData/Roaming/Minori
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
27 * macOS: ~/Library/Application Support/Minori
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
28 * ...: ~/.config/minori
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
29 *
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
30 * FIXME: are windows and mac properly cased?
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
31 */
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 7
diff changeset
32 #ifdef WIN32
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
33 return Strings::ToUtf8String(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
34 #else
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
35 return Strings::ToUtf8String(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 230
diff changeset
36 #endif
45
4b05bc7668eb filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
37 }
4b05bc7668eb filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
38
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
39 std::filesystem::path GetConfigPath()
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
40 {
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 134
diff changeset
41 return GetDotPath() / CONFIG_NAME;
118
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 106
diff changeset
42 }
39521c47c7a3 *: another huge megacommit, SORRY
Paper <mrpapersonic@gmail.com>
parents: 106
diff changeset
43
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
44 std::filesystem::path GetAnimeDBPath()
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
45 {
135
0a458cb26ff4 filesystem: move to using std::filesystem after C++17 switch
Paper <mrpapersonic@gmail.com>
parents: 134
diff changeset
46 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
47 }
4b05bc7668eb filesystem: split config path into dotpath and config, add anime db path
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
48
369
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
49 std::filesystem::path GetTorrentsPath()
47c9f8502269 *: clang-format all the things
Paper <paper@tflc.us>
parents: 258
diff changeset
50 {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 221
diff changeset
51 return GetDotPath() / "torrents";
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 221
diff changeset
52 }
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 221
diff changeset
53
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
54 } // namespace Filesystem