private RamFile AddUserFSFile(String userName, String path) { RamFile fs = null; fs = new OpenedFile(root_ + path); UserFS ufs; userFSList.TryGetValue(userName, out ufs); ufs.files.AddLast(fs); return fs; }
public int WriteFile(String filename, Byte[] buffer, ref uint writtenBytes, long offset, DokanFileInfo info) { RamFile fs = null; String userName = GetProcessOwner((int)info.ProcessId); try { if (!userFSList.ContainsKey(userName)) { fs = new OpenedFile(root_ + filename); UserFS ufs = new UserFS(); ufs.userName = userName; ufs.files = new System.Collections.Generic.LinkedList<RamFile>(); ufs.files.AddLast(fs); lock (userFSLock) { userFSList.Add(userName, ufs); } } else { fs = GetUserFSFile(userName, filename); if (fs == null) { lock (userFSLock) { fs = GetUserFSFile(userName, filename); if (fs == null) { fs = AddUserFSFile(userName, filename); } } } } fs.Seek(offset, SeekOrigin.Begin); fs.Write(buffer, 0, buffer.Length); writtenBytes = (uint)buffer.Length; return 0; } catch (Exception e) { logger.WriteLine("WriteFile error: " + e.Message + " " + e.StackTrace, Logger.MessagePriority.None); return -1; } }