Diez B. Roggisch wrote:
> The link/unlink trick of Chetan sounds reasonable, though.
It will work only if both source and destination are on the same
file system, which means you can't move a file between mount
points - at least that's the way how it's defined by POSIX; NTFS
supports hard links a
Wolfgang Draxinger schrieb:
> Steven D'Aprano wrote:
>
>> But the source file always exists, otherwise there is nothing
>> to rename! Do you mean, open the destination filename?
>
> Of course I meant the destination file. Someone please spill some
> ice chilled water over me to get me awake again
Steven D'Aprano wrote:
> But the source file always exists, otherwise there is nothing
> to rename! Do you mean, open the destination filename?
Of course I meant the destination file. Someone please spill some
ice chilled water over me to get me awake again. Time to go to
bed :-P before I make mo
On Sun, 29 Oct 2006 00:29:06 +0200, Wolfgang Draxinger wrote:
> Steven D'Aprano wrote:
>
>> Open "the" file? There are potentially two files -- the source
>> and destination. I only want to do the rename if the
>> destination *doesn't* exist, so there is no destination file to
>> open. How will i
Steven D'Aprano wrote:
> Open "the" file? There are potentially two files -- the source
> and destination. I only want to do the rename if the
> destination *doesn't* exist, so there is no destination file to
> open. How will it help me to lock the source file? Have I
> misunderstood?
I forgot to
On Sat, 28 Oct 2006 16:48:37 +0200, Diez B. Roggisch wrote:
> Where does that help for new files? The OP was right in assuming that a
> race condition could occur when he tests for a file & then tries to
> create it, as in the meantime it could have been created.
Ah! "Race condition" -- that wa
On Sat, 28 Oct 2006 13:38:14 +0200, Wolfgang Draxinger wrote:
>> But on a multi-user system, it is possible that dest is created
>> in the time period between checking if it exists and attempting
>> the rename.
>>
>> Is there any way to prevent this? Or do I just try to keep the
>> check and the
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> I want to rename a file, but only if the destination file name doesn't
> already exist.
>
> I can do this:
>
> if os.path.exists(dest):
> # skip file, raise an exception, make a backup...
> do_something_else()
> else:
> os.rename(src, de
Diez B. Roggisch wrote:
>> 1: Open the file with os.open
>>
>> 2: Lock the file exclusively -> no other process can now
>> access it.
>>
>> 3: Use rename to rename the file; this causes a file system
>> level implicit unlink of the old file (it dissappears from the
>> file system) but the openin
Wolfgang Draxinger schrieb:
> Steven D'Aprano wrote:
>
>> I want to rename a file, but only if the destination file name
>> doesn't already exist.
>>
>> I can do this:
>>
>> if os.path.exists(dest):
>> # skip file, raise an exception, make a backup...
>> do_something_else()
>> else:
>>
Steven D'Aprano wrote:
> I want to rename a file, but only if the destination file name
> doesn't already exist.
>
> I can do this:
>
> if os.path.exists(dest):
> # skip file, raise an exception, make a backup...
> do_something_else()
> else:
> os.rename(src, dest)
>
>
> But on a m
I want to rename a file, but only if the destination file name doesn't
already exist.
I can do this:
if os.path.exists(dest):
# skip file, raise an exception, make a backup...
do_something_else()
else:
os.rename(src, dest)
But on a multi-user system, it is possible that dest is cre
12 matches
Mail list logo