]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/Common/org/tianocore/common/cache/FileTimeStamp.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Common / org / tianocore / common / cache / FileTimeStamp.java
CommitLineData
4b134847 1/** @file\r
2This file is to define the FileTimeStamp class for speeding up the dependency check.\r
3\r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14package org.tianocore.common.cache;\r
15\r
16import java.io.File;\r
17import java.util.Map;\r
18import java.util.TreeMap;\r
19import java.util.HashMap;\r
20\r
21/**\r
22 FileTimeStamp class is used to cache the time stamp of accessing file, which\r
23 will speed up the dependency check for build\r
24 **/\r
25public class FileTimeStamp {\r
26 //\r
27 // cache the modified timestamp of files accessed, to speed up the depencey check\r
28 // \r
29 private static Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
30\r
31 /**\r
32 Get the time stamp of given file. It will try the cache first and then\r
33 get from file system if no time stamp of the file is cached.\r
34\r
35 @param file File name\r
36 \r
37 @return long The time stamp of the file\r
38 **/\r
39 synchronized public static long get(String file) {\r
40 long timeStamp = 0;\r
41\r
42 Long value = timeStampCache.get(file);\r
43 if (value != null) {\r
44 timeStamp = value.longValue();\r
45 } else {\r
46 timeStamp = new File(file).lastModified();\r
47 timeStampCache.put(file, new Long(timeStamp));\r
48 }\r
49\r
50 return timeStamp;\r
51 }\r
52\r
53 /**\r
54 Force update the time stamp for the given file\r
55\r
56 @param file File name\r
57 @param timeStamp The time stamp of the file\r
58 **/\r
59 synchronized public static void update(String file, long timeStamp) {\r
60 timeStampCache.put(file, new Long(timeStamp));\r
61 }\r
62\r
63 /**\r
64 Force update the time stamp for the given file\r
65\r
66 @param file File name\r
67 **/\r
68 synchronized public static void update(String file) {\r
69 long timeStamp = new File(file).lastModified();\r
70 timeStampCache.put(file, new Long(timeStamp));\r
71 }\r
72\r
73 /**\r
74 Check if the time stamp of given file has been cached for not\r
75\r
76 @param file The file name\r
77 \r
78 @return boolean\r
79 **/\r
80 synchronized public static boolean containsKey(String file) {\r
81 return timeStampCache.containsKey(file);\r
82 }\r
83}\r