   # un-needed files in cache?
   for oldfile in oldfiles when oldfile.path? and not oldfile.needed 
     cache.files.push oldfile
+
+get_filename_for_component = (h) ->
+  if h=='' 
+    return '_'
+  h = encodeURIComponent h
+  return h.replace("~","_")
+  # is that enough??
 
 # get local cache path for an URL - like java cacheing,
 # maps domain name elements and path elements to folders

# shorturl for each 
make_shorturls = (feed,shorturls) ->
  console.log 'make_shorturls...'
  # TODO

  # atom url -> get url
  baseurl = get_baseurl feed
  geturl = baseurl+'get.html'

  # work out URLs to be shortened
  # get.html?u=URL&t=TITLE&a=HELPERURL...

data = fs.readFileSync atomfn, 'utf8'
console.log 'read '+data.length+' bytes'

# try reading shorturls.json
shorturls = []
shorturlsfn = 'shorturls.json'
try 
  shorturlsdata = fs.readFileSync shorturlsfn,'utf8'
  shorturls = JSON.parse shorturlsdata
catch e
  console.log 'could not read '+shorturlsfn+': '+e

# try reading cache.json
cache = {}
cachefn = 'cache.json'
try 
  cachedata = fs.readFileSync cachefn,'utf8'
  cache = JSON.parse cachedata
