From d01050f31604f742d4dbb5f4607d884f2948a297 Mon Sep 17 00:00:00 2001 From: Dylan Knutson Date: Sun, 18 Aug 2013 17:16:52 -0700 Subject: [PATCH 1/3] On Windows, look for config in dcd.conf, on posix default to ~/.config/dcd --- README.md | 2 +- server.d | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5c22a30..56b09c4 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ In future versions the client may start the server if it is not running, but for now it must be started manually. ## Configuration Files -The server will attempt to read the file ```~/.config/dcd``` on startup. +The server will attempt to read the file ```~/.config/dcd``` on Posix systems, or ```dcd.conf``` on Windows in the current working directory on startup. If it exists, each line of the file is interpreted as a path that should be searched when looking for module imports. diff --git a/server.d b/server.d index 0beedc1..33e7800 100644 --- a/server.d +++ b/server.d @@ -32,8 +32,14 @@ import messages; import autocomplete; import modulecache; -// TODO: Portability would be nice... -enum CONFIG_FILE_PATH = "~/.config/dcd"; +version(Posix) +{ + enum CONFIG_FILE_PATH = "~/.config/dcd"; +} +else version(Windows) +{ + enum CONFIG_FILE_PATH = "dcd.conf"; +} int main(string[] args) { @@ -135,19 +141,22 @@ int main(string[] args) return 0; } -version(linux) -{ string[] loadConfiguredImportDirs() { - string fullPath = expandTilde(CONFIG_FILE_PATH); - if (!exists(fullPath)) - return []; - File f = File(fullPath); - return f.byLine(KeepTerminator.no).map!(a => a.idup).filter!(a => a.exists()).array(); + version(Windows) + { + string fullPath = buildPath(getcwd(), CONFIG_FILE_PATH); + } + else version(Posix) + { + string fullPath = expandTilde(CONFIG_FILE_PATH); + } + + if (!exists(fullPath)) + return []; + File f = File(fullPath); + return f.byLine(KeepTerminator.no).map!(a => a.idup).filter!(a => a.exists()).array(); } -} -else - static assert (false, "Only Linux is supported at the moment"); void printHelp(string programName) { From 417703d10317df7b0c40092165276d9aea3c88c1 Mon Sep 17 00:00:00 2001 From: Dylan Knutson Date: Sun, 18 Aug 2013 17:17:22 -0700 Subject: [PATCH 2/3] Windows requires size_t to be passed to uninitializedArray() in modulecache.d --- modulecache.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modulecache.d b/modulecache.d index 4705619..3d0f3ab 100644 --- a/modulecache.d +++ b/modulecache.d @@ -87,7 +87,7 @@ struct ModuleCache try { File f = File(location); - ubyte[] source = uninitializedArray!(ubyte[])(f.size); + ubyte[] source = uninitializedArray!(ubyte[])(cast(size_t)f.size); f.rawRead(source); LexerConfig config; From a9de462c6b94c2c5ebeaf67521e3da6847d633e5 Mon Sep 17 00:00:00 2001 From: Dylan Knutson Date: Sun, 18 Aug 2013 17:17:45 -0700 Subject: [PATCH 3/3] Added preliminary .gitignore file --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98b59ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Windows binaries +*.exe +*.obj