From cdbe4f89d6eafc16ad3c57710ce8a4c1b9e911e5 Mon Sep 17 00:00:00 2001 From: Mathias Lang Date: Fri, 8 Mar 2024 18:37:04 +0100 Subject: [PATCH] Change all references to std.file in commandline to FQN This makes it more visible where std.file is used, as we want to reduce the number of places we do I/O, and as we have two ways to do I/O in Dub. --- source/dub/commandline.d | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 92092ad68..afdd7cd83 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -28,7 +28,7 @@ import std.array; import std.conv; import std.encoding; import std.exception; -import std.file; +static import std.file; import std.getopt; import std.path : absolutePath, buildNormalizedPath, expandTilde, setExtension; import std.process : environment, spawnProcess, wait; @@ -173,7 +173,7 @@ struct CommandLineHandler if (options.root_path.empty) { - options.root_path = getcwd(); + options.root_path = std.file.getcwd(); } else { @@ -281,7 +281,7 @@ unittest { auto args = new CommandArgs([]); handler.prepareOptions(args); - assert(handler.options.root_path == getcwd()); + assert(handler.options.root_path == std.file.getcwd()); } /// It can set a custom root_path @@ -386,8 +386,6 @@ unittest { */ int runDubCommandLine(string[] args) { - import std.file : tempDir; - static string[] toSinglePackageArgs (string args0, string file, string[] trailing) { return [args0, "run", "-q", "--temp-build", "--single", file, "--"] ~ trailing; @@ -450,11 +448,11 @@ int runDubCommandLine(string[] args) // we only consider the case where the file name is the first argument, // as the shell invocation cannot be controlled. else if (handler.getCommand(args[1]) is null && !args[1].startsWith("-")) { - if (exists(args[1])) { + if (std.file.exists(args[1])) { auto path = getTempFile("app", ".d"); - copy(args[1], path.toNativeString()); + std.file.copy(args[1], path.toNativeString()); args = toSinglePackageArgs(args[0], path.toNativeString(), args[2 .. $]); - } else if (exists(args[1].setExtension(".d"))) { + } else if (std.file.exists(args[1].setExtension(".d"))) { args = toSinglePackageArgs(args[0], args[1].setExtension(".d"), args[2 .. $]); } } @@ -2844,7 +2842,7 @@ class DustmiteCommand : PackageBuildCommand { logInfo("Starting", Color.light_green, "Executing dustmite..."); auto testcmd = appender!string(); testcmd.formattedWrite("%s dustmite --test-package=%s --build=%s --config=%s", - thisExePath, prj.name, this.baseSettings.buildType, this.baseSettings.config); + std.file.thisExePath, prj.name, this.baseSettings.buildType, this.baseSettings.config); if (m_compilerName.length) testcmd.formattedWrite(" \"--compiler=%s\"", m_compilerName); if (m_arch.length) testcmd.formattedWrite(" --arch=%s", m_arch);