Re: [PATCH 1/2] Work around leftover temporary save file.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alex Riesen <raa.lkml@xxxxxxxxx> writes:

>On Tue, Sep 15, 2009 at 11:26, Pat Thoyts
><patthoyts@xxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> If a file exists and is hidden on Windows the Tcl open command will
>> fail as the attributes provided in the CREAT call fail to match those
>> of the existing file. Forcing removal of the temporary file before we
>> begin solves any problems caused by previous failures to save the
>> application settings. An alternative would be to remove the hidden
>> attribute before calling 'open'.
>>
>> Signed-off-by: Pat Thoyts <patthoyts@xxxxxxxxxxxxxxxxxxxxx>
>> ---
>>  gitk |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/gitk b/gitk
>> index 1306178..a0214b7 100755
>> --- a/gitk
>> +++ b/gitk
>> @@ -2526,6 +2526,7 @@ proc savestuff {w} {
>>     if {$stuffsaved} return
>>     if {![winfo viewable .]} return
>>     catch {
>> +       if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
>
>maybe another gitk instance is writing it at exactly same moment
>in time? Writing is known to take a few moments. Especially on Windows.

no - 'open $file w' is translated into O_WRONLY|O_CREAT|O_TRUNC
internally and passed to the win32 layer to get converted to a call to CreateFile with
GENERIC_WRITE, CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL. The file has
got FILE_ATTRIBUTE_HIDDEN though and as it exists and our attributes
do not match we get failed.
'open $file {O_WRONLY O_TRUNC}' would open it but we'd have to check
for non-existence and redo with O_CREAT if it was not already present.

See tclWinChan.c:TclpOpenFileChannel.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]