Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e9547fed5d1c5c9370713521f72b489da40c714f
Ticket: 1622579fffffffffffffffffffffffffffffffff
open fails to open hidden files for writing
User & Date: patthoyts on 2007-01-03 20:40:45
Changes

  1. closedate changed to: "2007-01-03T13:40:45"
  2. closer changed to: "patthoyts"
  3. icomment:
    Logged In: YES 
    user_id=202636
    Originator: NO
    
    "give it the readonly attribute"
    You mean hidden.
    
    The issue here is that the file exists already with non-default attributes. Mode 'w' means WRONLY|CREAT|TRUNC which is translated into OPEN_ALWAYS and as we look like we are creating the file we expect to set the attributes to FILE_ATTRIBUTE_NORMAL. As the file exists but has FILE_ATTRIBUTE_HIDDEN we get a permission denied from windows.
    
    The solution is to open with appropriate flags:
    % set f [open z.txt w]; puts $f test; close $f
    % file attributes z.txt -hidden 1
    %
    % list [set f [open z.txt w]] [close $f]
    couldn't open "z.txt": permission denied
    % list [set f [open z.txt a]] [close $f]
    filea260e8 {}
    % list [set f [open z.txt a+]] [close $f]
    filea21648 {}
    % list [set f [open z.txt "WRONLY CREAT"]] [close $f]
    filea26150
    % list [set f [open z.txt "WRONLY CREAT TRUNC"]] [close $f]
    couldn't open "z.txt": permission denied
    
    I don't think this is a bug myself.
    
    
  4. login: "patthoyts"
  5. mimetype: "text/plain"
  6. resolution changed to: "Wont Fix"
  7. status changed to: "Pending"
  8. username: "patthoyts"