|
|
#1 |
|
Junior Member
Join Date: May 2011
Posts: 25
|
NSIS FileOpen in read mode is shared?
Hello,
When I open a file in mode "r" - FileOpen "filename" r, does it lock the file for exclusive use? I believe, in "r" mode, the process shouldn't lock the resource. I have a common file which is written by a java program and read by NSIS. When NSIS opens the file in "r" mode and reads it, the java program throws an exception during its write with the message that the file is in use by another program. Is there a way in NSIS to open shared resource for reading without locking it? Thank you! |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 644
|
When a file is open for reading, it usually is shared for reading (i.e. no exclusive lock), but not for writing.
And it seems that is what NSIS does: PHP Code:
(And, as FILE_SHARE_READ is hardcoded, you cannot change it without re-compiling the EXE headers) My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc My source of inspiration: http://youtu.be/lCwY4_0W1YI |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Oct 2011
Posts: 9
|
Just made that, hope that can help..
![]() PHP Code:
${FileOpenEx} $0 "SomeFile.ext" "r" "rwd" "" ;; opens SomeFile.ext in read mode with full share access, if it exists * |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
|
It might be worth changing all those run time string comparisons to compile time (by using !if).
Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: May 2011
Posts: 25
|
Thank you, all
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Oct 2011
Posts: 9
|
If you really nead maximum speed, ex: if you open a large amount of files in a tight loop, you may want a more direct approach, something like:
PHP Code:
Last edited by Lloigor; 31st October 2011 at 13:19. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|