// TODO: We need a nice way to deal with removal of text private FileWrite InsertToWriteCache(string filePath, long localStartOffset, long localEndOffset, long bytesWritten, long bytesAdded) { var writeInfo = new FileWrite(localStartOffset, localEndOffset, bytesWritten, bytesAdded); if (!writeCache.ContainsKey(filePath)) { writeCache.Add(filePath, new List <FileWrite>()); } writeCache[filePath].Add(writeInfo); return(writeInfo); }
public bool CanWrite(IWriteContent content, FileWrite write) { long contentLength = content.EndOffset.HasValue ? content.EndOffset.Value - content.StartOffset : 0; long contentEndOffset = content.StartOffset + contentLength; bool startsInRange = content.StartOffset > write.localStartOffset && content.StartOffset < write.localEndOffset; bool endsInRange = contentEndOffset > write.localStartOffset && contentEndOffset < write.localEndOffset; // We're attempting to write to a section of the file that has been modified by another if (startsInRange || (content.Replace && endsInRange)) { return(false); } return(true); }