From cee2f0a19e00a7feab0cdf14b0c789412de58828 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 1 Nov 2008 06:10:00 +0000 Subject: [PATCH] ready to push 1.3 git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@6 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa --- Main.cs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 4 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Main.cs b/Main.cs index 69f2259..9d02fe1 100644 --- a/Main.cs +++ b/Main.cs @@ -177,8 +177,54 @@ namespace winsw o.Close(); } + /// + /// Process the file copy instructions, so that we can replace files that are always in use while + /// the service runs. + /// + private void HandleFileCopies() + { + var file = descriptor.BasePath + ".copies"; + if (!File.Exists(file)) + return; // nothing to handle + + try + { + using (var tr = new StreamReader(file,Encoding.UTF8)) + { + string line; + while ((line = tr.ReadLine()) != null) + { + try + { + EventLog.WriteEntry("Handling copy: " + line); + string[] tokens = line.Split('>'); + if (tokens.Length > 2) + { + EventLog.WriteEntry("Too many delimiters in " + line); + continue; + } + + File.Delete(tokens[1]); + File.Move(tokens[0], tokens[1]); + } + catch(IOException e) + { + EventLog.WriteEntry("Failed to copy :"+line+" because "+e.Message); + } + } + } + } + finally + { + File.Delete(file); + } + + } + protected override void OnStart(string[] args) { + HandleFileCopies(); + EventLog.WriteEntry("Starting "+descriptor.Executable+' '+descriptor.Arguments); string baseName = descriptor.BasePath; diff --git a/pom.xml b/pom.xml index d3f861f..d1ce7ff 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.sun.winsw winsw pom - 1.2 + 1.3 Windows service wrapper @@ -40,7 +40,7 @@ org.jvnet.wagon-svn wagon-svn - 1.8 + 1.9