renaming an open file in nt like unix?

A

aaron.watters

Hi. I'm writing an archival system which I'd like to be portable
to Windows.

The system relies on the property of Unix which allows a
process to keep a file open even if another process renames
it while it is open. Neither process sees any anomaly or
error.

Do the NT file systems support this feature (which I think is
standard for POSIX systems)?

Inquiring minds want to know. -- Aaron Watters

===
an apple every 8 hours
will keep 3 doctors away. -- kliban
 
T

Thomas Heller

Hi. I'm writing an archival system which I'd like to be portable
to Windows.

The system relies on the property of Unix which allows a
process to keep a file open even if another process renames
it while it is open. Neither process sees any anomaly or
error.

Do the NT file systems support this feature (which I think is
standard for POSIX systems)?

Yes, you can do that. We implemented something like this to replace
dlls there are currently in use - rename the currently open file, create a new one
with the old name (newly started processes will use the new one then),
and delete the renamed one at the next possible occasion (usually at
the next reboot). I'm not so sure on which NT versions it works this
way, at least in w2000 and newer.

Thomas
 
S

Steve Holden

Thomas said:
Yes, you can do that. We implemented something like this to replace
dlls there are currently in use - rename the currently open file, create a new one
with the old name (newly started processes will use the new one then),
and delete the renamed one at the next possible occasion (usually at
the next reboot). I'm not so sure on which NT versions it works this
way, at least in w2000 and newer.

Thomas
You do have to be careful though, because sometimes Windows refuses to
let you rename a file because it's in use.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
 
A

aaron.watters

Thomas said:
(e-mail address removed) schrieb:=
...Do the NT file systems support [renaming an open file] (which I think is
standard for POSIX systems)?
Yes, you can do that. We implemented something like this to replace
dlls there are currently in use...

You do have to be careful though, because sometimes Windows refuses to
let you rename a file because it's in use.

At least on my laptop I see Steve's behaviour. fwiw:

C:\Documents and Settings\aaron\Desktop>opentest.py rename
rename sleeps 1
renamer sleeping 5
now renaming
Traceback (most recent call last):
File "C:\Documents and Settings\aaron\Desktop\opentest.py", line 69,
in <modul
e>
renameProcess()
File "C:\Documents and Settings\aaron\Desktop\opentest.py", line 31,
in rename
Process
os.rename(firstname, secondname)
WindowsError: [Error 13] The process cannot access the file because it
is being
used by another process

So it looks like the answer in general is "no: you can't do that
on Windows."

Drat! Foiled again.
-- Aaron Watters

===
Is a bear catholic?
Does the Pope ...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top