From d9eff064bafce035ed4b80162a24e3fc679c3459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sun, 18 Jul 1999 00:06:42 -0700 Subject: [PATCH] now uses Cache.pike Rev: tutorial/Gfx.pmod:1.6 --- tutorial/Gfx.pmod | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/tutorial/Gfx.pmod b/tutorial/Gfx.pmod index d7cf3926c7..3d885491b1 100644 --- a/tutorial/Gfx.pmod +++ b/tutorial/Gfx.pmod @@ -2,32 +2,10 @@ */ -int image_num; -mapping(string:array(string)) image_cache=([]); -mapping(string:array) illustration_cache=([]); +object image_cache=.Cache("illustration_cache"); +object illustration_cache=.Cache("image_cache"); -void save_image_cache() -{ - rm("illustration_cache"); - Stdio.write_file("illustration_cache", - encode_value( ({ - image_num, - image_cache, - illustration_cache, - }))); -} - -void create() -{ - if(file_stat("illustration_cache")) - { - [image_num,image_cache,illustration_cache]= - decode_value(Stdio.read_file("illustration_cache")); - } - werror("Illustration caches: %d %d\n",sizeof(image_cache), sizeof(illustration_cache)); -} - string cached_write(string data, string ext) { @@ -44,8 +22,8 @@ string cached_write(string data, string ext) return file; } } - - image_num++; + + int image_num=image_cache[0]++; mkdir("gfx"); string filename="gfx/i"+image_num+"."+ext; rm(filename); @@ -57,8 +35,6 @@ string cached_write(string data, string ext) else image_cache[key]=({filename}); - save_image_cache(); - return filename; } @@ -242,7 +218,6 @@ array convret(string key, { array tmp=({ret, dpi}); illustration_cache[key]=tmp; - save_image_cache(); return tmp; } -- GitLab