Our website would like to use cookies to store information on your computer. You may delete and block all cookies from this site, but parts of the site will not work as a result. Find out more about how we use cookies.

Login or Register

Powered by
Powered by Novacaster
 
Impressive OSX-ery
by Bruce Ure at 11:35 18/01/08 (Blogs::Bruce)
A while back I thought I'd screwed up some file operation or other by moving the destination file to a different folder midway through whatever it was that was happening to it. I think it was just being moved from one place to another. I pretty much convinced myself I was dreaming, but just now I had a chance to test something similar, and blow me if it didn't work.
I was unRARing a huge file, and knew I wanted to move it after it was finished, but instead of waiting, I thought I'd give it a go mid-operation to see what happened.

I was expecting an OS message saying the file was in use, but instead, the file moved. Not only that but rather than end up with two half-files, as you might have expected, the unRAR utility continued to unRAR *to the moved file*.

Whether this is a file system thing or an unRAR thing, I have no idea, but my money's on the former.

Impressed.

--

<< NUSYSTEMS just made my shitlis... I'm a Mudlark -- it's official >>
View Comments (Threaded Mode) Printer Version
Impressive OSX-ery Bruce Ure - 11:35 18/01/08
Re: Impressive OSX-ery Steve - 12:36 18/01/08
It's the OS. OSX has long been capable of moving files that are in use. As I recall, the move is simply adjusting a pointer in the file system. The actual contents stay where they are (as expected).

However this won't work if you move the file to a different device since the OS has to physically move the bytes.

That said, apps need to be aware of this. If they cache the file's path then close and reopen the file at the cached path, you'll get an error. They can monitor the file system for move events.

--
stevepa

Re: Impressive OSX-ery Hugo van der Sanden - 17:16 18/01/08
I'd expect this to work fine on any Unix system even if you delete the file or move it to another filesystem during the operation - the OS knows the file is still in use, and does not free the disk sectors until the process using it closes the file handle.

Caveat: may not work on remote file systems if they have poor locking implementations, or if the remote OS doesn't support the same semantics.

Hugo