|
|
#1 | |
|
Senior Member
|
FileOpen interferes with program
i have written a small function for my setup that constantly checks for a failure in a log file a started program gives out
the error line i am looking for looks like this (it always ends with 'i_am_the_federation' <- that is important) and is one of many lines the program attaches to that log: Quote:
so here is the function i included in my setup script code: Ok, the problem is not with the function itself, but with the fileopen command. the program cannot write to the file during the reading time of my setup, so the error cannot appear in the log. so do you have a suggestion what i could change that the setup doesn't block the program to write to the log file? DOCa Cola |
|
|
|
|
|
|
#2 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,338
|
NSIS opens files only with read sharing so that weird results won't come out when reading the file. If you want to open it with write sharing too you'd have to use System.dll:
!define GENERIC_READ 0x80000000 !define GENERIC_WRITE 0x40000000 !define FILE_SHARE_READ 1 !define FILE_SHARE_WRITE 2 !define CREATE_NEW 1 !define CREATE_ALWAYS 2 !define OPEN_EXISTING 3 !define OPEN_ALWAYS 4 System::Call "Kernel32::CreateFileA(t 'log.txt', i ${GENERIC_READ}, i ${FILE_SHARE_READ} | ${FILE_SHARE_WRITE}, i 0, i ${OPEN_EXISTING}, i 0, i 0)" NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#3 |
|
Senior Member
|
thx for the quick answer
no, i don't want to write to the file, just read it...so you say it shouldn't interfere with the program anyway when using FileOpen $0 "log.txt" "r" only? i tried you system.dll call but i couldn't find a command list for FILE_SHARE_READ, so i just tried code: DOCa Cola |
|
|
|
|
|
#4 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,338
|
Write sharing means other programs can write to the file while you're reading it. It doesn't mean you want to write to it.
FILE_SHARE_READ is a constant. What do you mean by command list? I have forgot to mention that the handle to the file is the return value of the system call. Add i .r0 to the end of the system call and the handle will be inserted into $0. Use IntCmp $0 -1 to make sure the file open hasn't failed. After that you can use the file handle just as a file handle FileOpen would have returned. NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#5 |
|
Senior Member
|
ok, i have done that now with the system call, but the problem that it cannot write to the log file during my setup reads it presists, i try to prepare you a ready to use sample...
|
|
|
|
|
|
#6 |
|
Senior Member
|
ok, here it is, size is 1.6 mb (self extracting 7zip archive)
http://www.borgcore.de/outerspace/nsis/a2testfiles.exe some instructions and info are inside the logfiletest.nsi DOCa Cola |
|
|
|
|
|
#7 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,338
|
Remove the spaces between ${FILE_SHARE_READ}, | and ${FILE_SHARE_WRITE} and you should be able to write to the file even between CreateFile and FileClose. I hope that's what you meant, I really couldn't understand where the problem was in your program so I've just created my own example.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#8 |
|
Senior Member
|
thank you! yes, that was what i meant! simply love that installer! i hope installshield/inno/wise setup users realize how much better nsis is
DOCa Cola |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|