76
77 return h;
78 }
79
80
81 /**
82 * Get a shared FileHistory object for a specified file and path to work directory.
83 * @param wdFile The path th work directory in which the history file is maintained.
84 * @param name The name of the file within the work direectory's jtData/
85 * subdirectory.
86 * @return the specified FileHistory object
87 */
88 public static FileHistory getFileHistory(File wdFile, String name) {
89 if (cache == null)
90 cache = new WeakHashMap<>(8);
91
92 if (!WorkDirectory.isWorkDirectory(wdFile))
93 return null;
94
95 // let's find in the cache work dir corresponding to the path
96 Iterator it = cache.keySet().iterator();
97 WorkDirectory wd = null;
98 while (it.hasNext()) {
99 WorkDirectory tempWD = ((WorkDirectory)it.next());
100 if (tempWD.getRoot().equals(wdFile)) {
101 wd = tempWD;
102 break;
103 }
104 }
105 if (wd != null)
106 return FileHistory.getFileHistory(wd, name);
107 else
108 return null;
109 }
110
111 /**
112 * Add a new file to the history.
113 * The file in the work directory for this history will be updated.
114 * @param file the file to be added to the history
115 */
116 public void add(File file) {
117 ensureEntriesUpToDate();
118
119 file = file.getAbsoluteFile();
|
76
77 return h;
78 }
79
80
81 /**
82 * Get a shared FileHistory object for a specified file and path to work directory.
83 * @param wdFile The path th work directory in which the history file is maintained.
84 * @param name The name of the file within the work direectory's jtData/
85 * subdirectory.
86 * @return the specified FileHistory object
87 */
88 public static FileHistory getFileHistory(File wdFile, String name) {
89 if (cache == null)
90 cache = new WeakHashMap<>(8);
91
92 if (!WorkDirectory.isWorkDirectory(wdFile))
93 return null;
94
95 // let's find in the cache work dir corresponding to the path
96 Iterator<WorkDirectory> it = cache.keySet().iterator();
97 WorkDirectory wd = null;
98 while (it.hasNext()) {
99 WorkDirectory tempWD = it.next();
100 if (tempWD.getRoot().equals(wdFile)) {
101 wd = tempWD;
102 break;
103 }
104 }
105 if (wd != null)
106 return FileHistory.getFileHistory(wd, name);
107 else
108 return null;
109 }
110
111 /**
112 * Add a new file to the history.
113 * The file in the work directory for this history will be updated.
114 * @param file the file to be added to the history
115 */
116 public void add(File file) {
117 ensureEntriesUpToDate();
118
119 file = file.getAbsoluteFile();
|