/* FileUtils.h */

/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
 *
 * This file is part of sayonara player
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SAYONARA_FILE_UTILS_H
#define SAYONARA_FILE_UTILS_H

#include <QList>
#include <utility>
#include "typedefs.h"

class QStringList;
class QString;
class QChar;
class QByteArray;

namespace Util
{
	namespace File
	{
		QString cleanFilename(const QString& filename);

		QByteArray getMD5Sum(const QString& filename);

		int removeFilesInDirectory(const QString& dirName, const QStringList& filters);
		int removeFilesInDirectory(const QString& dirName);

		int deleteFiles(const QStringList& files);

		QString getParentDirectory(const QString& path);

		QString getFilenameOfPath(const QString& path);

		void splitFilename(const QString& src, QString& dir, QString& filename);

		std::pair<QString, QString> splitFilename(const QString& src);

		QStringList splitDirectories(const QString& path);

		QString getFileExtension(const QString& filename);

		QStringList getParentDirectories(const QStringList& list);

		QString getAbsoluteFilename(const QString& filename);

		bool createDirectories(const QString& path);

		bool createSymlink(const QString& source, const QString& target);

		bool checkSymLink(const QString& symlinkPath);

		QString getFilesizeString(Filesize filesize);

		bool isAbsolute(const QString& filename);

		QList<QChar> invalidFilenameChars();

		bool writeFile(const QByteArray& raw_data, const QString& filename);

		bool readFileIntoString(const QString& filename, QString& content);

		bool readFileIntoByteArray(const QString& filename, QByteArray& content);

		bool checkFile(const QString& filepath);

		QString getCommonDirectory(const QStringList& paths);

		QString getCommonDirectory(QString dir1, QString dir2);

		bool createDir(const QString& dirName);

		bool copyDir(const QString& srcDir, const QString& targetDirectory, QString& new_filename);

		bool moveDir(const QString& srcDir, const QString& targetDirectory, QString& new_filename);

		bool renameDir(const QString& srcDir, const QString& newName);

		bool canCopyDir(const QString& srcDir, const QString& targetDirectory);

		bool moveFile(const QString& file, const QString& dir, QString& newName);

		bool copyFile(const QString& file, const QString& dir, QString& newName);

		bool moveFiles(const QStringList& files, const QString& dir, QStringList& newNames);

		bool renameFile(const QString& oldName, const QString& newName);

		bool copyFiles(const QStringList& files, const QString& dir, QStringList& new_files);

		bool isUrl(const QString& str);

		bool isWWW(const QString& str);

		bool isFile(const QString& filename);

		bool isDir(const QString& filename);

		bool isSoundFile(const QString& extension);

		bool isPlaylistFile(const QString& extension);

		bool isImageFile(const QString& extension);

		bool exists(const QString& filename);

		bool isSamePath(const QString& filename1, const QString& filename2);

		bool isSubdir(const QString& dir, const QString& parentDir);
	}
}

#endif // SAYONARA_FILE_UTILS_H
