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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
# IMDELETE -- Delete an image.
procedure imdelete (image)
char image[ARB]
char cache[SZ_FNAME], fname[SZ_FNAME], extn[SZ_FNAME]
char root[SZ_FNAME], src[SZ_FNAME]
int status, len, ip
int envgets(), strlen(), iki_access(), imaccess()
bool streq()
begin
# Delete a cached version of the file.
if (envgets ("cache", cache, SZ_PATHNAME) > 0) {
status = iki_access (image, root, extn, READ_ONLY)
len = strlen (root)
for (ip = len; ip > 0; ip=ip-1) {
if (root[ip] == '/') {
call strcpy (root[ip+1], root, SZ_FNAME)
break
}
}
# Make sure the name has the image extension.
len = strlen (image)
if (! streq (extn, image[len-strlen(extn)+1])) {
call strcat (".", root, SZ_FNAME)
call strcat (extn, root, SZ_FNAME)
}
# Note that if the file in the cache was added using
# a full path and/or image type extension, it will not
# be found in the cache and deleted.
if (status > 0) {
call fclookup (cache, image, fname, extn, SZ_FNAME)
if (fname[1] != EOS) {
call fcdelete (cache, fname)
call fcsrc (cache, image, src, SZ_FNAME)
if (src[1] != EOS) {
call fclookup (cache, src, fname, extn, SZ_FNAME)
call fcdelete (cache, fname)
call fcdelete (cache, src)
}
}
}
}
if (imaccess (image, READ_ONLY) == YES) {
call iki_init()
call iki_delete (image)
}
end
|