changeset 11237:f53febae9f93 octave-forge

(none)
author abarth93
date Mon, 12 Nov 2012 15:02:29 +0000
parents 9eb4a3b222e2
children 4ad4a68fd5b3
files extra/ncArray/DESCRIPTION extra/ncArray/inst/cached_decompress.m
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/extra/ncArray/DESCRIPTION	Sun Nov 11 13:33:52 2012 +0000
+++ b/extra/ncArray/DESCRIPTION	Mon Nov 12 15:02:29 2012 +0000
@@ -4,7 +4,7 @@
 Author: Alexander Barth <barth.alexander@gmail.com>
 Maintainer: Alexander Barth <barth.alexander@gmail.com>
 Title: ncArray
-Description: Subsetting and concatenating of NetCDF files
+Description: Access a single or a collection of NetCDF files as a multi-dimensional array
 Categories: IO
 Depends: octave (>= 3.4.0), octcdf (>= 1.1.5)
 Autoload: yes
--- a/extra/ncArray/inst/cached_decompress.m	Sun Nov 11 13:33:52 2012 +0000
+++ b/extra/ncArray/inst/cached_decompress.m	Mon Nov 12 15:02:29 2012 +0000
@@ -7,25 +7,27 @@
 %
 % Output:
 %  fname: the filename of the uncompressed file
+%
+% Global variables:
+% CACHED_DECOMPRESS_DIR (default fullfile(getenv('HOME'),'tmp','Cache')):
+%    cache directory of decompressed files
+% CACHED_DECOMPRESS_LOG_FID (default 1): file id for log message
+% CACHED_DECOMPRESS_MAX_SIZE (default 1e10): maximum size of cache in bytes.
 
 % Alexander Barth, 2012-06-13
 %
-function [fname] = cached_decompress(url)
+function [fname]=cached_decompress(url)
 
 
 global CACHED_DECOMPRESS_DIR
 global CACHED_DECOMPRESS_LOG_FID
-
+global CACHED_DECOMPRESS_MAX_SIZE
 
 cache_dir = CACHED_DECOMPRESS_DIR;
 if isempty(cache_dir)
     cache_dir = fullfile(getenv('HOME'),'tmp','Cache');
 end
 
-% do nothing if
-% file is a a remote url (begins with http:)
-% or file does not end with .gz or .bz2
-
 if beginswith(url,'http:') || ~(endswith(url,'.gz') || endswith(url,'.bz2'))
   % opendap url or not compressed file
   fname = url;
@@ -69,7 +71,11 @@
 
 d=dir(cache_dir);
 cashe_size = sum([d.bytes]);
-max_cache_size = 1e10;
+max_cache_size = CACHED_DECOMPRESS_MAX_SIZE;
+
+if isempty(max_cache_size)
+  max_cache_size = 1e10;
+end
 
 if (cashe_size > max_cache_size)