• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A CLI tool for downloading from pixiv.net


Commit MetaInfo

Révision1338821d76a4a01f227cbfe0c4720d077a77a2e4 (tree)
l'heure2023-06-17 12:11:16
Auteurmio <stigma@disr...>
Commitermio

Message de Log

Update pixiv_down to use new directories API

Change Summary

Modification

--- a/source/app.d
+++ b/source/app.d
@@ -837,29 +837,28 @@ loadConfig()
837837 {
838838 Config config;
839839 string sessionid;
840- DirEntry homeDir = open(Directory.home);
841- DirEntry configDir = open(Directory.config);
842- DirEntry dataDir = open(Directory.data);
843840
844- string configDirPath = buildPath(configDir, "pixiv_down");
845- if (exists(configDirPath)) {
846- string configFilePath = buildPath(configDirPath, "settings.conf");
841+ ProjectDirectories dirs = getProjectDirectories(null, "YumeNeru Software",
842+ "pixiv_down");
843+ UserDirectories userDirs = getUserDirectories();
844+
845+ if (exists(dirs.configDir)) {
846+ string configFilePath = buildPath(dirs.configDir, "settings.conf");
847847 if (exists(configFilePath)) {
848848 scope parser = new ConfigParser();
849849 parser.read(configFilePath);
850850 config.baseFolder = parser.get("output", "base_folder",
851- buildPath(homeDir, "Pictures"));
851+ userDirs.pictureDir);
852852 }
853853 } else {
854854 // Set default values
855- config.baseFolder = buildPath(homeDir, "Pictures");
855+ config.baseFolder = userDirs.pictureDir;
856856 }
857857
858- string dataDirPath = buildPath(dataDir, "pixiv_down");
859- string idFilePath = buildPath(dataDirPath, ".phpsessid");
858+ string idFilePath = buildPath(dirs.dataDir, ".phpsessid");
860859
861- if (!exists(dataDirPath)) {
862- mkdirRecurse(dataDirPath);
860+ if (!exists(dirs.dataDir)) {
861+ mkdirRecurse(dirs.dataDir);
863862 sessionid = askForSessionID();
864863 storeSessionID(sessionid, idFilePath);
865864 } else {
--- a/source/directories.d
+++ b/source/directories.d
@@ -11,6 +11,9 @@
1111 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1212 */
1313
14+/// NOTE: pixiv_down uses a *slightly* modified version: it removes all
15+/// deprecations so no warnings are printed when compiling.
16+
1417 /**
1518 * This module provides quick & easy access to the common directories
1619 * for each operating system. Currently, only POSIX (XDG Base Directory
@@ -65,26 +68,6 @@
6568 */
6669 module directories;
6770
68-import std.file : DirEntry;
69-
70-///
71-/// Deprecated: Use the new `getBaseDirectories`, `getProjectDirectories`,
72-/// and `getUserDirectories` functions. This will be removed
73-/// in version 0.3.0.
74-///
75-deprecated("Use new get{Base,Project,User}Directories functions (remove 0.3.0)")
76-public enum Directory
77-{
78- home,
79- data,
80- config,
81- state,
82- // dataDirs, /* XDG */
83- // configDirs, /* XDG */
84- cache,
85- runtime,
86-}
87-
8871 ///
8972 /// Provides paths of user-invisible standard directories, following the
9073 /// conventions of the operating system the library is running on.
@@ -1138,104 +1121,8 @@ unittest
11381121 writeln(userDirs);
11391122 }
11401123
1141-/++
1142- Return a DirEntry pointing to `dt`.
1143-
1144- If the folder couldn't be found, an empty DirEntry is returned.
1145-
1146- Deprecated: Use the new `getBaseDirectories`, `getProjectDirectories`,
1147- and `getUserDirectories` functions. This will be removed
1148- in version 0.3.0.
1149-
1150- Examples:
1151- ----
1152- import directories;
1153- import std.stdio;
1154-
1155- int main()
1156- {
1157- DirEntry userConfDir = open(Directory.config);
1158- /* Handle error */
1159- if (0 == userConfDir.name.length)
1160- {
1161- stderr.writeln("Failed to find user config directory.");
1162- return 1;
1163- }
1164- writefln("User config directory is %s", userConfDir.name);
1165- return 0;
1166- }
1167- ----
1168-+/
1169-deprecated("Use new get{Base,Project,User}Directories functions (remove 0.3.0)")
1170-public DirEntry open(Directory dt) nothrow// @safe
1171-{
1172- /*
1173- * The Posix version covers a few operating systems, if your uses an
1174- * an alternative to XDG, let me know.
1175- */
1176- version (Posix) enum supported = true;
1177- else version (Windows) enum supported = true;
1178- else enum supported = false;
1179-
1180- static if (false == supported) {
1181- static assert(0, "Unsupported platform.");
1182- }
1183-
1184- immutable string path = getPath(dt);
1185- if (path is null) return DirEntry();
1186- try {
1187- return DirEntry(path);
1188- } catch (Exception e) {
1189- return DirEntry();
1190- }
1191-}
1192-
1193-///
1194-unittest
1195-{
1196- import std.conv : to;
1197- import std.stdio : stderr;
1198-
1199- DirEntry emptyDir;
1200-
1201- foreach(dir; Directory.min..Directory.max)
1202- {
1203- string dirAsString = to!string(dir);
1204- DirEntry dirEntry = open(dir);
1205- version (Windows)
1206- {
1207- // Neither of these directories are supported on Windows.
1208- if (dir == Directory.state || dir == Directory.runtime)
1209- continue;
1210- }
1211- assert(emptyDir != dirEntry, "Failed to open(Directory." ~ dirAsString ~ ")");
1212- stderr.writefln("Successfully opened Directory.%s: %s", dirAsString, dirEntry.name());
1213- }
1214-}
1215-
12161124 private:
12171125
1218-immutable(string) getPath(in Directory dt) nothrow @safe
1219-{
1220- switch (dt)
1221- {
1222- case Directory.home:
1223- return home();
1224- case Directory.data:
1225- return data();
1226- case Directory.config:
1227- return config();
1228- case Directory.cache:
1229- return cache();
1230- case Directory.state:
1231- return state();
1232- case Directory.runtime:
1233- return runtime();
1234- default:
1235- assert(false, "Unsupported Directory");
1236- }
1237-}
1238-
12391126 immutable(string) home() nothrow @trusted
12401127 {
12411128 version (Posix) {