QFtpCompat 1.0.0
Qt6-compatible async FTP client library
Loading...
Searching...
No Matches
qftpcompatdirentry.h
Go to the documentation of this file.
1
5
6// SPDX-License-Identifier: MIT
7
8#pragma once
9
10#include <QDateTime>
11#include <QString>
12#include <QVector>
13
14class QByteArray;
15
30class QFtpCompatDirEntry
31{
32public:
33 QFtpCompatDirEntry() = default;
34
35 // -----------------------------------------------------------------
36 // Factory
37 // -----------------------------------------------------------------
38
45 [[nodiscard]] static QVector<QFtpCompatDirEntry> parseList(const QByteArray &rawListing);
46
47 // -----------------------------------------------------------------
48 // Accessors
49 // -----------------------------------------------------------------
50
52 [[nodiscard]] QString name() const noexcept { return m_name; }
53
55 [[nodiscard]] QString permissions() const noexcept { return m_permissions; }
56
58 [[nodiscard]] QString owner() const noexcept { return m_owner; }
59
61 [[nodiscard]] QString group() const noexcept { return m_group; }
62
64 [[nodiscard]] qint64 size() const noexcept { return m_size; }
65
67 [[nodiscard]] QDateTime lastModified() const noexcept { return m_lastModified; }
68
70 [[nodiscard]] bool isDirectory() const noexcept { return m_isDirectory; }
71
73 [[nodiscard]] bool isSymLink() const noexcept { return m_isSymLink; }
74
76 [[nodiscard]] QString linkTarget() const noexcept { return m_linkTarget; }
77
79 [[nodiscard]] QString toString() const;
80
81private:
82 // -----------------------------------------------------------------
83 // Per-format parsers (return default-constructed entry on failure)
84 // -----------------------------------------------------------------
85 [[nodiscard]] static QFtpCompatDirEntry parseMlsd (const QString &line);
86 [[nodiscard]] static QFtpCompatDirEntry parseUnix (const QString &line);
87 [[nodiscard]] static QFtpCompatDirEntry parseWindows(const QString &line);
88
89 // -----------------------------------------------------------------
90 // Data
91 // -----------------------------------------------------------------
92 QString m_name;
93 QString m_permissions;
94 QString m_owner;
95 QString m_group;
96 qint64 m_size{0};
97 QDateTime m_lastModified;
98 bool m_isDirectory{false};
99 bool m_isSymLink{false};
100 QString m_linkTarget;
101};
Represents a single entry from an FTP LIST response.
QString group() const noexcept
Owning group name. Empty when not available.
QString owner() const noexcept
Owning user name. Empty when not available.
bool isSymLink() const noexcept
true for symbolic links.
QString name() const noexcept
File or directory name (never includes the path).
QString toString() const
Returns a human-readable summary for debug output.
static QVector< QFtpCompatDirEntry > parseList(const QByteArray &rawListing)
Parses a full LIST / MLSD response body into directory entries.
QDateTime lastModified() const noexcept
Last-modification timestamp. May be approximate (year inferred when absent).
QString permissions() const noexcept
Unix permission string, e.g. "-rw-r--r--". Empty for Windows listings.
bool isDirectory() const noexcept
true for directory entries.
QString linkTarget() const noexcept
Symlink target path. Empty when isSymLink() is false.
qint64 size() const noexcept
File size in bytes. 0 for directories.