## The module "fileinfo" of the Mastrave modelling library

Daniele de Rigo

The file fileinfo.m is part of Mastrave.

Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.

#### Function declaration

[ file_path, file_name, bytes, attr, basedir, file_type ] =
fileinfo( file_pattern )



#### Description

Given a string file_pattern (which may contain wildcard characters), this module returns: - the file_path cell-array of strings listing the full path for each of
the matching files. - The file_name cell-array of strings listing the name for each of
the matching files. - The vector of integers bytes showing the amount of bytes allocated
to each file. - The structure attr whose fields consist of vectors of logicals being
true when the corresponding attribute belongs to a matching file, false
otherwise. The checked attributes are the followings:
- directory: for each element of file_path the corresponding row of
the field is_dir is true when the element is a directory, false
otherwise;
- writability: true values of the field is_writ indicate the
writabale elements of file_path ;
- executability: true values of the field is_exec indicate the
executable elements of file_path . - The string basedir indicating the common left part of each possible
instance of file_pattern (i.e. the substring starting from the first
character of file_pattern and not containing wildcards nor the file
name (with or without wildcards inside it). - The file_type cell-array of strings listing the file type description
for each of the matching files.

#### Input arguments


file_pattern      ::string::
String constraining the path and the name of the files to
match: it may contain wildcard characters



#### Example of usage


filelist = fileinfo( '*fi*.m' )

pattern  = '../{,*/}*fi*'
[ f_path, f_name, bytes, attr, base, f_type ] = fileinfo( pattern );
fprintf( 1 , 'the base directory is: "%s".\n' , base );
format   = sprintf( '%%10d   %%d   %%d   %%d   %%d   %%-%ds  %%s\n' , ...
max( cellfun( 'prodofsize' , f_name ) ) )
fprintf( 1 , '     bytes  dir  r   w   x\n' );
for i=1:numel(bytes)
fprintf(                                              ...
1              , format         , bytes(i)       , ...
attr.is_exec(i), f_name{i}      , f_path{i}        ...
);
fprintf( 1, '%s(%s)\n', repmat(' ',1,29), f_type{i} );
end


See also:
munix

Keywords:
file system, info

Version: 0.7.2

#### Support

The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science.  You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module.  Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable.  However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based.  Reporting a problem that you found using Mastrave may help the developer team to find a possible bug.  Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems.  Thank you for your collaboration.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Daniele de Rigo