dir
List the current directory or given directory of an FTP server.
Attention: Valid only with Altair Communication Extension.
Syntax
dir(ftpObj)
dir(ftpObj, dirname)
R = dir(...)
Inputs
- ftpObj
- FTP object
- dirname
- Directory to list.
Outputs
- R
- A structure with the following fields: bytes, date, isdir, name.
Examples
List the contents of the root directory:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% If an output argument is not provided the contents of the directory
% will be printed in the console
disp('Contents of the root directory:')
dir(ftpObj)
close(ftpObj);
Contents of the root directory:
ans = drwxrwxrwx 1 owner group 0 Feb 19 10:00 Folder1
drwxrwxrwx 1 owner group 0 Feb 19 08:53 Folder2
-rw-rw-rw- 1 owner group 0 Feb 19 08:53 file1.txt
-rw-rw-rw- 1 owner group 0 Feb 19 08:53 file2.txt
Get the contents in a struct:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Get the contents of the directory in a struct
disp('Contents of the root directory:')
R = dir(ftpObj)
disp('File/directory names:')
R.name
close(ftpObj);
Contents of the root directory:
R = struct [
Struct array of size 1 x 4 with fields:
bytes
date
isdir
name
]
File/directory names:
ans = Folder1
ans = Folder2
ans = file1.txt
ans = file2.txt
List the contents of a directory:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Get the contents of 'Folder1' in a struct
disp('Contents of ''Folder1'':')
R = dir(ftpObj,'Folder1');
disp('File/directory names:')
R.name
close(ftpObj);
Contents of 'Folder1':
R = struct [
Struct array of size 1 x 2 with fields:
bytes
date
isdir
name
]
File/directory names:
ans = file1_1.txt
ans = file1_2.txt