Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
CURL.FileInfos
Queries file listing as JSON.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 8.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Result
Returns JSON or error.
Description
Queries file listing as JSON.Requires wild card being enabled (CURL.SetOptionWildCardMatch) and an URL with a pattern, e.g. * at the end.
Only for FTP protocol.
The JSON is an array of objects. Each object includes the following values:
hasFileName | Whether file name is known. |
hasFiletype | Whether file type is known. |
hasTime | Whether time is known. |
hasPerm | Whether file permissions are known. |
hasUID | Whether UID is known. |
hasGID | Whether GID is known. |
hasSize | Whether file size is known. |
hasHardLinkCount | Whether hard link count is known. |
FileName | The file name. |
FileType | The file type. Usually file, directory or symlink. |
Time | The time as returned from server. |
Perm | The permissions as returned from server. |
User | The user name as returned from server. |
Group | The group name as returned from server. |
Target | The target file path of the symbolic link. |
HardLinks | The number of hard links to this file. |
Size | The file size in bytes. |
UID | The user ID if known. |
GID | The group ID if known. |
Permissions | The file permissions as octal number as text, e.g. 755. |
TimeValue | The unix time stamp. |
Year | The year of the time, if available. |
Month | The month of the time, if available. |
Day | The day of the time, if available. |
Hour | The hour of the time, if available. |
Minute | The minute of the time, if available. |
Second | The second of the time, if available. |
As various servers return different listings, we can not always know all fields.
Some servers don't give the year, so we assume this year and last year depending on month and day.
For MBS Plugin 9.0 or newer you can alternatively run a custom request "MLSD" and then get file infos, too.
Examples
Query file list with wildcard:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $r ; Value: MBS( "CURL.SetOptionWildCardMatch"; $curl; 1 ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; CURL Test::URL & "*" ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionVerbose"; $curl; 1) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::listing ; MBS( "JSON.Colorize"; MBS("CURL.FileInfos"; $curl)) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
Query file list with MLSD:
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $r ; Value: MBS( "CURL.SetOptionWildCardMatch"; $curl; 1 ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; CURL Test::URL & "*" ) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionVerbose"; $curl; 1) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::listing ; MBS( "JSON.Colorize"; MBS("CURL.FileInfos"; $curl)) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
See also
- CURL.GetDebugMessages
- CURL.New
- CURL.Perform
- CURL.Release
- CURL.SetOptionPassword
- CURL.SetOptionURL
- CURL.SetOptionUserName
- CURL.SetOptionVerbose
- CURL.SetOptionWildCardMatch
- JSON.Colorize
Release notes
- Version 9.0
- Added new mode for CURL.FileInfos to get file infos from ftp listing with MLSD custom request.
- Improved parsing for CURL.FileInfos.
- Version 8.5
- Added CURL.FileInfos function to get file listings for FTP as JSON.
Example Databases
Blog Entries
This function checks for a license.
Created 16th October 2018, last changed 4th August 2023