ready to push 1.3

git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@6 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
remotes/git-svn
kohsuke 2008-11-01 06:10:00 +00:00
parent 0b36ee6a73
commit cee2f0a19e
2 changed files with 48 additions and 2 deletions

46
Main.cs
View File

@ -177,8 +177,54 @@ namespace winsw
o.Close();
}
/// <summary>
/// Process the file copy instructions, so that we can replace files that are always in use while
/// the service runs.
/// </summary>
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;

View File

@ -5,7 +5,7 @@
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<packaging>pom</packaging>
<version>1.2</version>
<version>1.3</version>
<name>Windows service wrapper</name>
<distributionManagement>
@ -40,7 +40,7 @@
<extension>
<groupId>org.jvnet.wagon-svn</groupId>
<artifactId>wagon-svn</artifactId>
<version>1.8</version>
<version>1.9</version>
</extension>
</extensions>
</build>