diff --git a/DokanPbo.Core/PboFS.cs b/DokanPbo.Core/PboFS.cs index 156feb8..17b6d3e 100644 --- a/DokanPbo.Core/PboFS.cs +++ b/DokanPbo.Core/PboFS.cs @@ -97,7 +97,7 @@ private void DeleteNode(string filename) private IPboFsNode GetNodeFast(string filename, DokanFileInfo info) { - if (info.Context is IPboFsNode node) + if (info?.Context is IPboFsNode node) return node; return FindNode(filename); } @@ -564,6 +564,8 @@ public NtStatus SetFileTime(string filename, DateTime? ctime, DateTime? atime, D if (node is PboFsRealFile file) { + //#TODO we can't do this while file is open. Optimally we just want to queue tasks to be executed once the file is closed. + if (file.IsOpenForWriting) return DokanResult.Success; if (ctime != null) { System.IO.File.SetCreationTime(file.GetRealPath(), ctime.Value); diff --git a/DokanPbo.Core/PboFSNode.cs b/DokanPbo.Core/PboFSNode.cs index bd87029..f62374e 100644 --- a/DokanPbo.Core/PboFSNode.cs +++ b/DokanPbo.Core/PboFSNode.cs @@ -1,4 +1,4 @@ -using DokanNet; +using DokanNet; using SwiftPbo; using System; using System.Collections.Generic; @@ -277,9 +277,10 @@ public class PboFsRealFile : IPboFsFile, IPboFsRealObject { public System.IO.FileInfo file; private bool? wantsOpenWrite; - private FileMode openMode; + private FileMode openMode = FileMode.Open; private System.IO.FileStream readStream = null; private System.IO.FileStream writeStream = null; + public bool IsOpenForWriting => writeStream != null; //In case someone tries to set lastWriteTime while we have a Write stream open. private DateTime? lastWriteTimeTodo; @@ -300,6 +301,7 @@ public PboFsRealFile(System.IO.FileInfo inputFile, PboFsFolder inputParent) : ba }; } + //writeableStream is from newly created file public PboFsRealFile(System.IO.FileInfo inputFile, PboFsFolder inputParent, System.IO.FileStream writeableStream) : this(inputFile, inputParent) { writeStream = writeableStream;