public override void Create(DataServer ds, string fileName) { ds.GetFreeze.WaitOne(); File file = new File(); string[] args = Util.SplitArguments(fileName); file.Version = Convert.ToInt64(args[0]); file.Content = new byte[1]; ds.CurrentDir = Environment.CurrentDirectory; string path = ds.CurrentDir + @"\" + ds.Name + @"\" + args[1] + @".txt"; Console.WriteLine("Create: " + path); Util.SerializeFile(path, file); ds.AddFile(args[1]); //add file to datainfo ds.DataInfo.AddFile(args[1]); }
public override int Write(DataServer ds, string localFile, byte[] bytearray) { ds.GetFreeze.WaitOne(); string[] content = Util.SplitArguments(Util.ConvertByteArrayToString(bytearray)); string version = content[0]; byte[] bytes = Util.ConvertStringToByteArray(content[1]); File newFile = new File(); File oldFile = new File(); string path = ds.CurrentDir + @"\" + ds.Name + @"\" + localFile + ".txt"; if (System.IO.File.Exists(path)) { oldFile = Util.DeserializeFile(path, oldFile); } if (oldFile.Version < Convert.ToInt64(version)) { newFile.Version = Convert.ToInt64(version); newFile.Content = bytes; ds.CurrentDir = Environment.CurrentDirectory; string readPath = ds.CurrentDir + @"\" + ds.Name + @"\" + localFile + @".txt"; Console.WriteLine("Write: " + readPath); Util.SerializeFile(readPath, newFile); ds.AddFile(localFile); //add access to this file ds.DataInfo.AddAccess(localFile); } //success return 0; }