Export to GitHub

pngcs - issue #9

OpenFileForReading should perform Read-only access on file


Posted on Nov 9, 2013 by Quick Monkey

By view point of parallelism, sometimes we access .png files by multiple threads simultaneously. Current pngcs implementation prevents things from working properly because OpenFileForReading method in FileHelper performs Read/Write (calling FileStream(String, FileMode) constructor without passing third argument; FileAccess, result in R/W access) and perform locks on files.

So, I propose applying the following patch on FileHelper.cs

  • isx = new FileStream(file, FileMode.Open);
  • isx = new FileStream(file, FileMode.Open, FileAccess.Read);

Comment #1

Posted on Nov 9, 2013 by Quick Monkey

Just forgot to note. Please refer to http://msdn.microsoft.com/en-us/library/47ek66wy(v=vs.110).aspx for more detail about FileStream constructor behaviour.

Comment #2

Posted on Jul 16, 2015 by Massive Giraffe

Had the exact same problem with the component and fixed the code thanks to your comment. I my case the file was placed on a network drive and FileAccess.Read was the only way to open the file for reading.

Status: New

Labels:
Type-Defect Priority-Medium