lsl.m 590 B

12345678910111213141516171819
  1. function [ lsoutp ] = lsl ( directory )
  2. %LS Substitute 'ls' function to return compatible output on Win and Unix
  3. % The default 'ls' function behave differently on Windows and Unix platforms.
  4. % This function returns a char matrix contains 'ls' results including ., ..,
  5. % files, and folders). Spaces are appended to each string as necessary to form
  6. % a valid matrix.
  7. if nargin < 1
  8. directory = '.';
  9. end
  10. if ispc
  11. lsoutp = ls ( directory );
  12. elseif isunix || ismac
  13. dirtmp = dir ( directory );
  14. lsoutp = strvcat ( {dirtmp.name} );
  15. else
  16. error ( 'unknow platform' );
  17. end