#ifndef __File_h__
#define __File_h__

#include <string>
#include <fcntl.h>
#include "ZString.h"

///
/// File
///
/// File abstraction class for accessing local file system files.
///

namespace coreutils {

   class File {

    public:
      File(ZString fileName, int mode = O_RDONLY, int authority = 0664);
      virtual ~File();
      void setBufferSize(size_t size);
      int read();
      int readLine();
      void write(std::string data);
      void write(coreutils::ZString &data);
      std::string asString();
      coreutils::ZString asZString();
      char *buffer;
      size_t size;
      bool eof();

      coreutils::ZString fileName;

    private:
      void open(coreutils::ZString fileName, int mode, int authority);
      int fd;
      coreutils::ZString zstring;
      bool mEof = false;

   };

}

#endif
