/***************************************************************************

    supportware
    Copyright (C) 2001-2008 by c.holzheuer
    c.holzheuer@sourceworx.org

    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 2 of the License, or
    (at your option) any later version.

***************************************************************************/


#ifndef DDIOOBJECT_H
#define DDIOOBJECT_H

#include <ddstringrow.h>
#include <ddbasetime.h>
#include <sys/types.h>
#include <sys/stat.h>

using namespace std;


/// ddioobject ist die basis für alles was mit IO zu tun hat.
/**
  @see ddiourl
  @see ddioinfo
*/


class ddioobject : public ddbasestate
{

public:
  
  virtual ~ddioobject();

  bool is_local() const;
  bool is_remote() const;
  bool is_valid() const;
  bool is_relative() const;
  bool is_folder();
  bool is_stream() const;

  const ddioobject&	make_abs();
  const ddstring&		get_full_path() const;
  const ddstring&		get_path() const;
  const ddstring&		get_full_name() const;
  const ddstring&		get_file_name() const;
  const ddstring&		get_file_type() const;
  virtual ddstring&	get_file_content();
  size_t						get_file_size();

  // PFUSCH! time/date Aufräumen
  ddbasetime        get_last_accessed();
	ddbasetime        get_last_modified();
	ddbasetime        get_last_changed();

  // PFUSCH! time/date Aufräumen
	ddstring          get_last_accessed_str();
	ddstring          get_last_modified_str();
	ddstring          get_last_changed_str();

  virtual int				load_file_content();
  
  virtual ddstring  to_string() const;
  virtual void 		  dump() const;   

  virtual bool      init_path( const ddstring& path ) = 0;
  virtual bool      init_stat();
     
protected:

	ddioobject();
	 
	struct stat* _statbuf;
	
  enum dd_urlflags
  {
  	url_is_valid=1,
  	url_is_relative=2,
  	url_is_local=4,
  	url_is_folder=8,
  	url_is_stream=16
  	// exists
  };

  enum dd_urlfields
  {
  	url_fullpath=0,
   	url_path,	
		url_file,
  	url_file_body,
  	url_file_type,
  	url_content,
  	url_field_size
  };
  
  ddstringrow _data;

};


#endif
