blob: 949200b7a29124822177d5b728488e9b6d47b0ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// CacheEntry.java -- directory cache
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final class CacheEntry {
String dir;
String[] files;
long time;
CacheEntry (String d)
{
dir = d;
files = new File(dir).list();
time = System.currentTimeMillis ();
}
void touch ()
{
time = System.currentTimeMillis ();
}
final long EXPIRATION_TIME_MS = 1000;
boolean is_old () {
return (System.currentTimeMillis () - time) > EXPIRATION_TIME_MS;
}
public int hashCode () { return dir.hashCode(); }
boolean contains (String file) {
if (files == null)
return false;
int index = file.lastIndexOf(SearchPath.file_seperator_char);
String f;
if (index == -1)
f = file;
else
f = file.substring (index+1);
for (int i = 0; i < files.length; i++)
{
if (f.equals (files[i])) return true;
}
return false;
}
}
|