I have to get files those has been created or modified after a particular file. I know the name of that par开发者_Python百科ticular file.
What operating system?
1) Get the date that file was created
2) Then get the files that were created after that date
To do this portably, use a combination of File::list(...)
, File::lastModified()
and File::listRoots()
to walk the file-system. The execution could be time consuming, however. Some Unix operating systems have a daemon that can tell you about file modifications more efficiently; I assume the daemon taps into the file-system code.
As an alternative:
1) Get all the possibly relevant files.
2) Sort by creation date.
3) Get all files after your marker file.
Advantage: you only access the file system once.
Disadvantage: uses more memory.
精彩评论