changeset 10566:95100da0eebe octave-forge

(none)
author abarth93
date Wed, 18 Jul 2012 09:47:09 +0000
parents d9104349d058
children 717877001d22
files extra/ncArray/inst/cached_decompress.m
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/extra/ncArray/inst/cached_decompress.m	Wed Jul 18 09:08:03 2012 +0000
+++ b/extra/ncArray/inst/cached_decompress.m	Wed Jul 18 09:47:09 2012 +0000
@@ -23,16 +23,16 @@
     cache_dir = fullfile(getenv('HOME'),'tmp','Cache');
 end
 
+if beginswith(url,'http:') || ~endswith(url,'.gz') || ~endswith(url,'.bz2')
+  % opendap url or not compressed file
+  fname = url;
+  return
+end
 
-if endswith(url,'.gz') || endswith(url,'.bz2')
-    if exist(cache_dir,'dir') ~= 7
-        error(['cache directory for compressed files does not exist. '...
-            'Please create the directory %s or change le value of the '...
-            'global variable CACHED_DECOMPRESS_DIR'],cache_dir);
-    end
-else
-    fname = url;
-    return    
+if exist(cache_dir,'dir') ~= 7
+  error(['cache directory for compressed files does not exist. '...
+         'Please create the directory %s or change le value of the '...
+         'global variable CACHED_DECOMPRESS_DIR'],cache_dir);
 end
     
 % where to print logs? default to screen
@@ -91,6 +91,16 @@
 end
 end
 
+function t = beginswith(s,pre)
+
+if length(pre) <= length(s)
+    t = strcmp(s(1:length(pre)),pre);
+else
+    t = 0;
+end
+end
+
+
 function t = endswith(s,ext)
 
 if length(ext) <= length(s)