view include/core/filesystem.h @ 386:e89901683d72

now_playing: don't reset the timer every 5 seconds ahaha
author Paper <paper@tflc.us>
date Thu, 06 Nov 2025 08:59:44 -0500
parents 0265e125f680
children 963047512d34
line wrap: on
line source

#ifndef MINORI_CORE_FILESYSTEM_H_
#define MINORI_CORE_FILESYSTEM_H_
#include <filesystem>
#include <string>
#include <functional>

namespace Filesystem {

void CreateDirectories(const std::filesystem::path &path);
std::filesystem::path GetDotPath();    // %APPDATA%/minori/, ~/Library/Application Support/minori/, ~/.config/minori/...
std::filesystem::path GetConfigPath(); // (dotpath)/config.json
std::filesystem::path GetAnimeDBPath();      // (dotpath)/anime/db.json
std::filesystem::path GetTorrentsPath();     // (dotpath)/torrents/...
std::filesystem::path GetAnimePostersPath(); // (dotpath)/anime/posters/

/* ------------------------------------------------------------------------ */
/* Filesystem watcher interface. This is implemented differently on
 * different platforms :) */

struct IWatcher {
	enum Event {
		/* File/directory 'path' was created */
		Created,
		/* File/directory 'path' was deleted */
		Deleted,
	};

	using EventHandler = std::function<void(void *opaque, const std::filesystem::path &path, Event event)>;

	virtual ~IWatcher() = default;
	virtual void Process() = 0;
};

/* Constructor functions. Yes, I'm doing this the C way :) */
IWatcher *GetRecursiveFilesystemWatcher(void *opaque,
	const std::filesystem::path &path, IWatcher::EventHandler handler);
IWatcher *GetFilesystemWatcher(void *opaque, const std::filesystem::path &path, IWatcher::EventHandler handler);

} // namespace Filesystem

#endif // MINORI_CORE_FILESYSTEM_H_