File indexing completed on 2025-02-02 05:02:28

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef FILEHELPER_H
0008 #define FILEHELPER_H
0009 
0010 class QByteArray;
0011 class QString;
0012 class QUrl;
0013 
0014 /** File related helper methods. */
0015 namespace FileHelper
0016 {
0017 
0018 /** Returns whether @p url is a file that can be read by QFile directly without downloading.
0019  *  @note This differs from QUrl::isLocalFile in also supporting Android content: URLs.
0020  */
0021 bool isLocalFile(const QUrl &url);
0022 
0023 /** Returns a path for @p url that QFile can work with.
0024  *  @note This differs from QUrl::toLocalFile in also supporting Android content: URLs.
0025  */
0026 QString toLocalFile(const QUrl &url);
0027 
0028 /** Returns the file name of @p url taking the special case of Android content: URLs into account. */
0029 QString fileName(const QUrl &url);
0030 
0031 /** Checks whether @p data starts with the magic header of a ZIP file. */
0032 bool hasZipHeader(const QByteArray &data);
0033 
0034 }
0035 
0036 #endif // FILEHELPER_H