#ifndef LIBSARIA_FILES_H
#define LIBSARIA_FILES_H

#include <libsaria/idle.h>
#include <libsaria/print.h>

#include <sys/types.h>
#include <fstream>
using namespace std;

class SaveTask : public IdleTask
{
	private:
		void (* save_func)();

	public:
		SaveTask(void (*func)());
		~SaveTask();
		void run_task();
};

class OutFile
{
	private:
		ofstream out;
		bool new_line;

		void begin_write();
		void end_write(bool);

	public:
		OutFile(string);
		~OutFile();

		void write_str(string, bool);
		void write_int(int, bool);
		void write_ui(unsigned int, bool);
		void write_lui(long unsigned int, bool);
		void write_ino(ino_t, bool);
};

class InFile
{
	private:
		ifstream in;

	public:
		InFile(string);
		~InFile();
		bool good();
		string read_str();
		int read_int();
		unsigned int read_ui();
		long unsigned int read_lui();
		ino_t read_ino();
};

#endif /* LIBSARIA_FILES_H */
