]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Common/org/tianocore/common/cache/FileTimeStamp.java
2 This file is to define the FileTimeStamp class for speeding up the dependency check.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 package org
.tianocore
.common
.cache
;
18 import java
.util
.TreeMap
;
19 import java
.util
.HashMap
;
22 FileTimeStamp class is used to cache the time stamp of accessing file, which
23 will speed up the dependency check for build
25 public class FileTimeStamp
{
27 // cache the modified timestamp of files accessed, to speed up the depencey check
29 private static Map
<String
, Long
> timeStampCache
= new HashMap
<String
, Long
>();
32 Get the time stamp of given file. It will try the cache first and then
33 get from file system if no time stamp of the file is cached.
37 @return long The time stamp of the file
39 synchronized public static long get(String file
) {
42 Long value
= timeStampCache
.get(file
);
44 timeStamp
= value
.longValue();
46 timeStamp
= new File(file
).lastModified();
47 timeStampCache
.put(file
, new Long(timeStamp
));
54 Force update the time stamp for the given file
57 @param timeStamp The time stamp of the file
59 synchronized public static void update(String file
, long timeStamp
) {
60 timeStampCache
.put(file
, new Long(timeStamp
));
64 Force update the time stamp for the given file
68 synchronized public static void update(String file
) {
69 long timeStamp
= new File(file
).lastModified();
70 timeStampCache
.put(file
, new Long(timeStamp
));
74 Check if the time stamp of given file has been cached for not
76 @param file The file name
80 synchronized public static boolean containsKey(String file
) {
81 return timeStampCache
.containsKey(file
);