fixed a compilation problem. Does this mean I committed a broken code?

git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@37 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
remotes/git-svn
kohsuke_kawaguchi 2009-07-22 00:15:27 +00:00
parent eef81d98d0
commit edb8ee971f
1 changed files with 11 additions and 11 deletions

22
Main.cs
View File

@ -481,17 +481,17 @@ namespace winsw
/// <summary> /// <summary>
/// Works like the CopyStream method but does a log rotation. /// Works like the CopyStream method but does a log rotation.
/// </summary> /// </summary>
private void CopyStreamWithRotation(FileStream i, string baseName, string ext) private void CopyStreamWithRotation(Stream data, string baseName, string ext)
{ {
int THRESHOLD = 10 * 1024 * 1024; // rotate every 10MB. should be made configurable. int THRESHOLD = 10 * 1024 * 1024; // rotate every 10MB. should be made configurable.
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
FileStream w = new FileStream(baseName + ext,FileMode.Append); FileStream w = new FileStream(baseName + ext,FileMode.Append);
int sz = new FileInfo(baseName + ext).Length; long sz = new FileInfo(baseName + ext).Length;
while (true) while (true)
{ {
int len = i.Read(buf,0,buf.Length); int len = data.Read(buf, 0, buf.Length);
if (len == 0) break; if (len == 0) break;
if (sz + len < THRESHOLD) if (sz + len < THRESHOLD)
{// typical case. write the whole thing into the current file {// typical case. write the whole thing into the current file
@ -516,11 +516,11 @@ namespace winsw
{ {
for (int j = 8; j >= 0; j--) for (int j = 8; j >= 0; j--)
{ {
string d = baseName + "." + (j + 1) + ext; string dst = baseName + "." + (j + 1) + ext;
string s = baseName + "." + (j + 0) + ext; string src = baseName + "." + (j + 0) + ext;
if (File.Exists(d)) if (File.Exists(dst))
File.Delete(d); File.Delete(dst);
File.Move(s, d); File.Move(src, dst);
} }
File.Move(baseName + ext, baseName + ".0" + ext); File.Move(baseName + ext, baseName + ".0" + ext);
} }
@ -534,7 +534,7 @@ namespace winsw
} }
} }
} }
i.Close(); data.Close();
w.Close(); w.Close();
} }
@ -606,8 +606,8 @@ namespace winsw
if (descriptor.Logmode == "rotate") if (descriptor.Logmode == "rotate")
{ {
string logName = Path.Combine(logDirectory, baseName); string logName = Path.Combine(logDirectory, baseName);
new Thread(delegate() { CopyStreamWithRotation(process.StandardOutput, logName, ".out.log"); }).Start(); new Thread(delegate() { CopyStreamWithRotation(process.StandardOutput.BaseStream, logName, ".out.log"); }).Start();
new Thread(delegate() { CopyStreamWithRotation(process.StandardError, logName, ".err.log"); }).Start(); new Thread(delegate() { CopyStreamWithRotation(process.StandardError.BaseStream, logName, ".err.log"); }).Start();
return; return;
} }