[1038] | 1 | %'dir_uvmat': list the content of a folder, extending 'dir' to the case of OpeNDAP server
|
---|
[1033] | 2 | %--------------------------------------------------------------------
|
---|
| 3 | %[RootPath,SubDir,RootFile,i1,i2,j1,j2,Ext,NomType]=fileparts_uvmat(FileInput)
|
---|
| 4 | %
|
---|
| 5 | %OUTPUT:
|
---|
| 6 | %ListFiles:
|
---|
| 7 | %
|
---|
| 8 | %INPUT:
|
---|
| 9 | %DirName: complete name of the folder to scan, including path
|
---|
| 10 |
|
---|
| 11 | %=======================================================================
|
---|
[1107] | 12 | % Copyright 2008-2022, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
---|
[1033] | 13 | % http://www.legi.grenoble-inp.fr
|
---|
| 14 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
| 15 | %
|
---|
| 16 | % This file is part of the toolbox UVMAT.
|
---|
| 17 | %
|
---|
| 18 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 19 | % it under the terms of the GNU General Public License as published
|
---|
| 20 | % by the Free Software Foundation; either version 2 of the license,
|
---|
| 21 | % or (at your option) any later version.
|
---|
| 22 | %
|
---|
| 23 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 26 | % GNU General Public License (see LICENSE.txt) for more details.
|
---|
| 27 | %=======================================================================
|
---|
| 28 |
|
---|
[1038] | 29 | function [ListFiles,errormsg] = dir_uvmat(DirName)
|
---|
[1070] | 30 | ListFiles=[];
|
---|
[1037] | 31 | errormsg='';
|
---|
[1070] | 32 | if ~ischar(DirName)
|
---|
| 33 | errormsg='the function dir_uvmat needs a character string input';
|
---|
| 34 | return
|
---|
| 35 | end
|
---|
[1022] | 36 | if regexp(DirName,'^http://')
|
---|
[1038] | 37 | % OpeNDAP case - read catalog.xml file
|
---|
[1022] | 38 | catalog=[DirName,'/catalog.xml'];
|
---|
[1037] | 39 | try
|
---|
[1022] | 40 | str=urlread(catalog);
|
---|
[1037] | 41 | catch ME
|
---|
| 42 | errormsg=ME.message;
|
---|
| 43 | return
|
---|
| 44 | end
|
---|
[1038] | 45 | ListFiles=(regexp(str,'xlink:title="(?<name>[^"]+)"','names'))'; % list subfolders
|
---|
[1022] | 46 | NumDir=numel(ListFiles);
|
---|
[1038] | 47 | ListFiles=[ListFiles;(regexp(str,'dataset name="(?<name>[^"]+)"','names'))']; % append files to the list
|
---|
[1022] | 48 | for ilist=1:numel(ListFiles)
|
---|
| 49 | ListFiles(ilist).date=0;
|
---|
| 50 | ListFiles(ilist).bytes=0;
|
---|
| 51 | ListFiles(ilist).isdir=false;
|
---|
| 52 | ListFiles(ilist).datenum=0;
|
---|
| 53 | end
|
---|
| 54 | for ilist=1:NumDir
|
---|
| 55 | ListFiles(ilist).isdir=true;
|
---|
| 56 | end
|
---|
[1037] | 57 | ListFiles(NumDir+1)=[];
|
---|
[1022] | 58 | else
|
---|
[1038] | 59 | % Standart case
|
---|
[1022] | 60 | ListFiles=dir(DirName);
|
---|
| 61 | end
|
---|
| 62 |
|
---|