//open a file for read write public override Stream OpenReadWrite() { lock (open_File_List) { // check too see if we can open and if (open_File_List[name].Item1 == 0 && open_File_List[name].Item2 == 0) { jaredstream temp = new jaredstream(); temp.fileName = name; storage.CopyTo(temp); // create a copy for the user to edit temp.SomethingHappened += DecrimateWrite; open_File_List[name] = Tuple.Create(open_File_List[name].Item1, open_File_List[name].Item2 + 1); return(temp); } else { return(null); } } }
// open the disk storage file public override Stream OpenReadOnly() { lock (open_File_List) { // if there arent any read writes open if (open_File_List[name].Item2 == 0) { jaredstream temp = new jaredstream(); temp.fileName = name; storage.CopyTo(temp); // create a copy for the user to edit temp.SomethingHappened += DecrimateRead; open_File_List[name] = Tuple.Create(open_File_List[name].Item1 + 1, open_File_List[name].Item2); return(temp); } else { return(null); } } }