4 ms·
Can someone with knowledge of the underlying OS mechanisms answer this for me: What is the deal with file access on Windows? In Linux (on the Mac too, I think)
by chancho 18y ago
Can someone with knowledge of the underlying OS mechanisms answer this for me: What is the deal with file access on Windows? In Linux (on the Mac too, I think) I can move, copy and delete files freely, regardless of what applications currently have that file open. On Windows, I always run into some situation where it won't let me do what I want to do because the file is open. So I have to hunt through 10-20 windows to see who has it (9 times out of 10 its a command prompt or explorer window holding on to a directory that I'm trying to delete.)
I don't use windows often so maybe I'm exaggerating, but this is the single most infuriating windows usability nitpick I have. Have they fixed this in Vista or 7?
- Jem 18y agoI don't know whether or not it's fixed in more recent versions, but there are programs which get around this for you (by killing processes, or telling you which process is using the file/folder). E.g. Unlocker http://ccollomb.free.fr/unlocker/ http://ccollomb.free.fr/unlocker/
- trezor 18y agoCan someone with knowledge of the underlying OS mechanisms answer this for me: What is the deal with file access on Windows? The Windows locking defaults when opening file-handles actually includes locking and has done so for such a long time that applications have come to depend on it. If you check the Win32 API you will see applications have several options for requesting (or not requesting) file-locks when doing file-operations, but not using them, the defaults are to play it safe and ensure that no data is lost due to improper access. Technologically speaking, this is kinda the same as you have in Linux, except that the defaults are the polar opposite. Changing the defaults now would break havoc among multiple applications relying on the defaults and cause massive amounts of corrupted data. So Microsoft have kept them as is. IOW: If you are having issues with file-locking, you need to blame the application-developer for not properly signalling what level and type of locking is actually required, because Windows will respect the locks set on file-handles. Maybe I'm the exception, but I consider that a good thing.
- halo 18y agoIt's fixed in Windows 7 by telling you which application is using the file (http://lifehacker.com/5132227/windows-7-tells-you-why-you-cant-touch-that-file http://lifehacker.com/5132227/windows-7-tells-you-why-you-ca...).
- nfg 18y agoFor anyone being annoyed by this in earlier versions Process Explorer http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx http://technet.microsoft.com/en-us/sysinternals/bb896653.asp... allows you to quickly search for handles and identify the offending process.
- old-gregg 18y agoThis happens because of underlying implementation of file systems. UNIX-based systems have the notion of "linking/unlinking" files: a file is a link to a set of sectors on your hard drive. One can create many more links to the same data (using ln command). Deleting is the same as unlinking, i.e. removing a link. When the last link disappears, the file is considered "deleted". When an application opens a file, it creates yet another link to it, so nothing stops you from removing the link - the file isn't deleted yet since your app still uses its own. I'm not sure how Windows can be "fixed" in this regard, since their filesystems don't have the notion of hard linking nor does Win32 API: there is no way you can move/delete file on Win32 while keeping existing open file handles alive. However, the biggest issue with Windows, in my opinion, is Registry. Nearly all "popular" Windows gripes can be tracked down to registry abuse: decreasing performance over time, adware/spyware, viruses, etc... Registry is like a secondary file system, but much slower, more primitive, less secure and, most importantly, nearly completely hidden from the users: there are no tools with exception of primitive regedit, to deal with it.
- briansmith 18y agoWindows has had hard links for a decade or so. Vista even ships with "mklink" which can make three different kinds of links. Before that, you could download utilities to make them. Windows won't unlink a link that is in use because its normal filesystem API promises that behavior. You can use different APIs to get different behavior. The registry exists in the format it is in to boost performance, not hinder performance. It supports approximately the same ACLs as the filesystem so there is nothing that makes it inherently less secure than the filesystem. And, the registry is designed to be exposed by custom GUIs, not by regedit. For example, to change the registry setting for the default program to open ".html" files with, you could* use regedit, but the Windows philosphy says there should be a dedicated UI for it instead (the "Default Programs" UI in this case).
- anigbrowl 18y ago'Strue. I do get frustrated with the registry model, although I've gotten good at dealing with it. On the other hand, custom GUIs help to improve Linux penetration, since many people are intimidated the command line or configuration file editing. I like Win and Linux, Mac seems to me to combine the worst of both. Sure, it's personal. Application compatibility matters, Linux lags badly on video & audio editing tools. When I first ran Linux around 1993, what really annoyed me were Emacs & vi. Sure, they're powerful, but extremely alienating to new users. DOS had Edit, or Windows 3 had Notepad. Ubuntu and like distros succeed because most people just want to drive without learning how to be a mechanic. Linux's biggest problem is people's perception that there's no 'standard' distribution and that they're going to have do an awful lot of icky maintenance.