[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Question about getmtime

Brandon

2/19/2010 4:05:00 PM

Hi everyone,

Does copying or moving a file affect the return value of
os.path.getmtime(path)?

Thank you,
Brandon
6 Answers

Krister Svanlund

2/19/2010 4:26:00 PM

0

On Fri, Feb 19, 2010 at 5:05 PM, Brandon <btaylordesign@gmail.com> wrote:
> Hi everyone,
>
> Does copying or moving a file affect the return value of
> os.path.getmtime(path)?
>
> Thank you,
> Brandon

Wouldn't it be easier to make a script and see for yourself then to
write a mail about it?

Brandon

2/19/2010 4:31:00 PM

0

On Feb 19, 10:26 am, Krister Svanlund <krister.svanl...@gmail.com>
wrote:
> On Fri, Feb 19, 2010 at 5:05 PM, Brandon <btaylordes...@gmail.com> wrote:
> > Hi everyone,
>
> > Does copying or moving a file affect the return value of
> > os.path.getmtime(path)?
>
> > Thank you,
> > Brandon
>
> Wouldn't it be easier to make a script and see for yourself then to
> write a mail about it?

Gee, thanks for the help. I guess.

MRAB

2/19/2010 6:07:00 PM

0

Brandon wrote:
> Hi everyone,
>
> Does copying or moving a file affect the return value of
> os.path.getmtime(path)?
>
The modification time of a copied file should be the same as the
original.

The creation time of a copied file will be the time at which it was
copied, so that can result in the paradoxical state of a file having
been modified _before_ it was created! :-)

Dave Angel

2/19/2010 7:02:00 PM

0

Brandon wrote:
> On Feb 19, 10:26 am, Krister Svanlund <krister.svanl...@gmail.com>
> wrote:
>
>> On Fri, Feb 19, 2010 at 5:05 PM, Brandon <btaylordes...@gmail.com> wrote:
>>
>>> Hi everyone,
>>>
>>> Does copying or moving a file affect the return value of
>>> os.path.getmtime(path)?
>>>
>>> Thank you,
>>> Brandon
>>>
>> Wouldn't it be easier to make a script and see for yourself then to
>> write a mail about it?
>>
>
> Gee, thanks for the help. I guess.
>
>
Well, copying the file won't affect the getmtime, since it's still
there, and unmodified. Moving it will cause the getmtime to to get an
os.error, because the file no longer exists.

Probably you mean you're adjusting the path variable to point to the new
location for the file. But the answer is still "it depends." How about
if you get more specific? If you write a copy utility using two opens,
a read() and a write(), then the new file will certainly get a new
timestamp unless you do something to prevent it. If you copy the file
from a DOS box in Windows XP, using the COPY command, then the getmtime
on the new file will be identical to the one on the old. If you do it
on an Amiga using pip, I have no idea.

Perhaps you're writing a copy/move utility of your own, and you want to
know how to cause a new file to have the same attributes as the
original. If so, be more specific.

DaveA

Sean DiZazzo

2/19/2010 10:10:00 PM

0

On Feb 19, 10:06 am, MRAB <pyt...@mrabarnett.plus.com> wrote:
> Brandon wrote:
> > Hi everyone,
>
> > Does copying or moving a file affect the return value of
> > os.path.getmtime(path)?
>
> The modification time of a copied file should be the same as the
> original.
>
> The creation time of a copied file will be the time at which it was
> copied, so that can result in the paradoxical state of a file having
> been modified _before_ it was created! :-)

ctime does not stand for creation time. I went through this a couple
of months ago. It's updated whenever the inode is updated, so
changing permissions, among other things will update it.

It blew me away when I finally found this out.

~Sean

MRAB

2/19/2010 11:18:00 PM

0

Sean DiZazzo wrote:
> On Feb 19, 10:06 am, MRAB <pyt...@mrabarnett.plus.com> wrote:
>> Brandon wrote:
>>> Hi everyone,
>>> Does copying or moving a file affect the return value of
>>> os.path.getmtime(path)?
>> The modification time of a copied file should be the same as the
>> original.
>>
>> The creation time of a copied file will be the time at which it was
>> copied, so that can result in the paradoxical state of a file having
>> been modified _before_ it was created! :-)
>
> ctime does not stand for creation time. I went through this a couple
> of months ago. It's updated whenever the inode is updated, so
> changing permissions, among other things will update it.
>
> It blew me away when I finally found this out.
>
On Windows ctime doesn't change when the file permissions are changed.