File indexing completed on 2024-05-12 05:48:50

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef VFSHELPERS_H
0006 #define VFSHELPERS_H
0007 
0008 #include <QObject>
0009 #include <QString>
0010 class QBuffer;
0011 
0012 #include <git2.h>
0013 
0014 #define DEFAULT_MODE_DIRECTORY 0040755
0015 #define DEFAULT_MODE_FILE 0100644
0016 
0017 class VintStream: public QObject {
0018     Q_OBJECT
0019 
0020 public:
0021     VintStream(const void *pData, int pSize, QObject *pParent);
0022 
0023     VintStream &operator>>(qint64 &pInt);
0024     VintStream &operator>>(quint64 &pUint);
0025     VintStream &operator>>(QString &pString);
0026     VintStream &operator>>(QByteArray &pByteArray);
0027 
0028 protected:
0029     QByteArray mByteArray;
0030     QBuffer *mBuffer;
0031 };
0032 
0033 struct Metadata {
0034     Metadata() {}
0035     explicit Metadata(qint64 pMode);
0036     qint64 mMode;
0037     qint64 mUid;
0038     qint64 mGid;
0039     qint64 mAtime;
0040     qint64 mMtime;
0041     qint64 mSize; //negative if invalid
0042     QString mSymlinkTarget;
0043 
0044     static qint64 mDefaultUid;
0045     static qint64 mDefaultGid;
0046     static bool mDefaultsResolved;
0047 };
0048 
0049 int readMetadata(VintStream &pMetadataStream, Metadata &pMetadata);
0050 quint64 calculateChunkFileSize(const git_oid *pOid, git_repository *pRepository);
0051 bool offsetFromName(const git_tree_entry *pEntry, quint64 &pUint);
0052 void getEntryAttributes(const git_tree_entry *pTreeEntry, uint &pMode, bool &pChunked, const git_oid *&pOid, QString &pName);
0053 QString vfsTimeToString(git_time_t pTime);
0054 
0055 #endif // VFSHELPERS_H