This is the mail archive of the
cygwin-talk
mailing list for the cygwin project.
RE: Cannot write files if they are hidden
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'thread properly TITTTL'd!'" <cygwin-talk at cygwin dot com>
- Date: Fri, 22 Jul 2005 20:00:52 +0100
- Subject: RE: Cannot write files if they are hidden
- Reply-to: The Cygwin-Talk Malingering List <cygwin-talk at cygwin dot com>
----Original Message----
>From: Cliff Hones
>Sent: 22 July 2005 17:43
[ Bock-bock b'gawwwk! ]
> Well, aside from whether that's sensible, Cygwin doesn't actually achieve
> this as far as the user interface is concerned.
Well, it does as far as your original report was concerned (see the
subject line of this thread if you want to remind yourself what you
originally reported....)
----------------------------in cmd.exe----------------------------
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\dk>echo "hello world" > aaa
C:\Documents and Settings\dk>attrib +h aaa
C:\Documents and Settings\dk>echo "hello world" > aaa
Access is denied.
--------------------------in cygwin bash--------------------------
dk@mace ~> echo "hello world" > bbb
dk@mace ~> cmd /c attrib +h bbb
dk@mace ~> echo "hello world" > bbb
bash: bbb: Permission denied
dk@mace ~>
------------------------------------------------------------------
> Windows hidden files are listed by "ls" (but aren't by windows "dir").
Yes they are:
----------------------------in cmd.exe----------------------------
C:\Documents and Settings\dk>dir /ah aaa
Volume in drive C has no label.
Volume Serial Number is 942E-907E
Directory of C:\Documents and Settings\dk
22/07/2005 18:27 16 aaa
1 File(s) 16 bytes
0 Dir(s) 55,361,261,568 bytes free
------------------------------------------------------------------
Of course, "dir" filters lots of files by default, and you have to add
"/ah" to prevent it. Much like how "ls" filters out files beginning with
'.' by default, and you have to add "-a" to prevent it...
> Under Windows you can read and append, but not replace - this is same as
> Cygwin.
That's good.
> But Windows "del <hiddenfile>" reports file not found,
Perhaps you should read the help instructions for del?
----------------------------in cmd.exe----------------------------
C:\Documents and Settings\dk>echo "hello" >aaa
C:\Documents and Settings\dk>attrib +r aaa
C:\Documents and Settings\dk>del /f aaa
C:\Documents and Settings\dk>
------------------------------------------------------------------
> while Cygwin "rm" does delete the file.
Hmmm, this one is weird. Sometimes rm does, sometimes it doesn't. While
investigating with "rm -i", I sometimes saw "Remove write-protected file?",
and at other "Remove regular file"; but I couldn't reproduce it, and there
were too many varying factors for me to try systematically: whether the file
is empty or has contents makes a difference to how it behaves, whether it
was initially created by 'doze or Cygwin makes a difference, and possibly
other things too.
However, in general, Cygwin is a POSIX emulation layer, not a windows
emulation layer. So there's no reason why "ls" and "dir" should act the
same as each other, nor need "rm" and "del" be consistent.
> Would I be right in guessing there is no logic in Cygwin to specifically
> deal with the Windows "H" attribute, and what we are seeing is the result
> of the quirky Microsoft API behaviour?
That's not _your_ guess, *I* said that! Admittedly I only _implied_ it by
saying that the intended behaviour was "the same as" 'doze, but there ya
go.....
cheers,
DaveK
--
Can't think of a witty .sigline today....