// UpdatedResponse.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, if you link this library with other files to
// produce an executable, this library does not by itself cause the
// resulting executable to be covered by the GNU General Public License.
// This exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
using System;
using System.IO;
using CVS.Misc;
namespace CVS.Responses{
public class UpdatedResponse : IResponse
{
public void Process(CvsStream cvsStream, IResponseServices services)
{
cvsStream.ReadLine();
string orgpath = cvsStream.ReadLine();
string localpath = services.Repository.ToLocalPath(orgpath);
string entry = cvsStream.ReadLine();
string flags = cvsStream.ReadLine();
string sizestr = cvsStream.ReadLine();
bool compress = sizestr[0] == 'z';
Console.WriteLine(orgpath);
Console.WriteLine(entry);
Console.WriteLine(flags);
Console.WriteLine(sizestr);
if (compress) {
sizestr = sizestr.Substring(1);
}
int size = Int32.Parse(sizestr);
string newdir = Path.GetDirectoryName(localpath);
if (!Directory.Exists(newdir)) {
Directory.CreateDirectory(Path.GetDirectoryName(localpath));
}
if (services.NextFile != null && services.NextFile.Length > 0) {
localpath = services.NextFile;
services.NextFile = null;
}
Entry e = new Entry(entry);
if (e.IsBinaryFile) {
services.UncompressedFileHandler.ReceiveBinaryFile(cvsStream, localpath, size);
} else {
services.UncompressedFileHandler.ReceiveTextFile(cvsStream, localpath, size);
}
e.Date = services.NextFileDate;
services.Repository.AddEntry(orgpath.Substring(0, orgpath.LastIndexOf('/')), e);
services.NextFileDate = null;
// set the timestamp from the server to the newly created file
e.TimeStamp = e.TimeStamp.ToLocalTime();
File.SetCreationTime(localpath, e.TimeStamp);
File.SetLastAccessTime(localpath, e.TimeStamp);
File.SetLastWriteTime(localpath, e.TimeStamp);
}
public bool IsTerminating {
get {
return false;
}
}
}
}
|