3 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class PacmanFile(object):
28 def __init__(self
, root
, name
):
31 self
.filename
= os
.path
.join(self
.root
, self
.name
)
33 self
.checksum
= util
.getmd5sum(self
.filename
)
34 self
.mtime
= self
.getmtime()
37 return "%s (%s / %lu)" % (self
.name
, self
.checksum
, self
.mtime
)
40 if not os
.path
.exists(self
.filename
):
42 statbuf
= os
.lstat(self
.filename
)
43 return (statbuf
[stat
.ST_MTIME
], statbuf
[stat
.ST_CTIME
])
46 checksum
= util
.getmd5sum(self
.filename
)
47 mtime
= self
.getmtime()
49 util
.vprint("\tismodified(%s)" % self
.name
)
50 util
.vprint("\t\told: %s / %s" % (self
.checksum
, self
.mtime
))
51 util
.vprint("\t\tnew: %s / %s" % (checksum
, mtime
))
53 if self
.checksum
!= checksum \
54 or self
.mtime
[0] != mtime
[0] \
55 or self
.mtime
[1] != mtime
[1]:
60 # vim: set ts=4 sw=4 et: