Made more code portable to Windows
This commit is contained in:
parent
3338104b0f
commit
de1ff9f24a
10
main.d
10
main.d
|
@ -83,16 +83,16 @@ string findAbsPath(string[] dirs, string moduleName)
|
||||||
// For file names
|
// For file names
|
||||||
if (endsWith(moduleName, ".d") || endsWith(moduleName, ".di"))
|
if (endsWith(moduleName, ".d") || endsWith(moduleName, ".di"))
|
||||||
{
|
{
|
||||||
if (startsWith(moduleName, "/"))
|
if (isAbsolute(moduleName))
|
||||||
return moduleName;
|
return moduleName;
|
||||||
else
|
else
|
||||||
return getcwd() ~ "/" ~ moduleName;
|
return buildPath(getcwd(), moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the file name from a module name like "std.stdio"
|
// Try to find the file name from a module name like "std.stdio"
|
||||||
foreach(dir; dirs)
|
foreach(dir; dirs)
|
||||||
{
|
{
|
||||||
string fileLocation = dir ~ "/" ~ replace(moduleName, ".", "/");
|
string fileLocation = buildPath(dir, replace(moduleName, ".", dirSeparator));
|
||||||
string dfile = fileLocation ~ ".d";
|
string dfile = fileLocation ~ ".d";
|
||||||
if (exists(dfile) && isFile(dfile))
|
if (exists(dfile) && isFile(dfile))
|
||||||
{
|
{
|
||||||
|
@ -109,14 +109,14 @@ string findAbsPath(string[] dirs, string moduleName)
|
||||||
|
|
||||||
string[] loadConfig()
|
string[] loadConfig()
|
||||||
{
|
{
|
||||||
string path = expandTilde("~/.dscanner");
|
string path = expandTilde("~" ~ dirSeparator ~ ".dscanner");
|
||||||
string[] dirs;
|
string[] dirs;
|
||||||
if (exists(path))
|
if (exists(path))
|
||||||
{
|
{
|
||||||
auto f = File(path, "r");
|
auto f = File(path, "r");
|
||||||
scope(exit) f.close();
|
scope(exit) f.close();
|
||||||
|
|
||||||
auto trimRegex = ctRegex!("\\s*$");
|
auto trimRegex = ctRegex!(`\s*$`);
|
||||||
foreach(string line; lines(f))
|
foreach(string line; lines(f))
|
||||||
{
|
{
|
||||||
dirs ~= replace(line, trimRegex, "");
|
dirs ~= replace(line, trimRegex, "");
|
||||||
|
|
Loading…
Reference in New Issue