/*
 * The UDS Collection
 * Copyright (C) 2001  Julian v. Bock
 *
 * 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.
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *	(See file COPYING for more information)
 */

#ifndef _uds_fileinfo_hh
#define _uds_fileinfo_hh


// includes

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


namespace uds
{

/** file infromation class. Provides info about a file as stat() does.
	\author Julian v. Bock */
class FileInfo
{
public:
	/** default constructor */
	FileInfo();
	
	/** \param fd file descriptor */
	FileInfo( int fd );
	
	/** \param fn file name */
	FileInfo( const char* fn );
	
	/** destructor */
	~FileInfo();
	
	/** \return device */
	dev_t
	Device() const { return st.st_dev; }
	
	/** \return inode */
	ino_t
	Inode() const { return st.st_ino; }
	
	/** \return protection mode */
	mode_t
	Protection() const { return st.st_mode; }
	
	/** \return number of hard links */
	nlink_t
	NLink() const { return st.st_nlink; }
	
	/** \return user id of owner */
	uid_t
	UserID() const { return st.st_uid; }
	
	/** \return group id of owner */
	gid_t
	GroupID() const { return st.st_gid; }
	
	/** \return device type */
	dev_t
	DevType() const { return st.st_rdev; }
	
	/** \return file size in bytes */
	off_t
	Size() const { return st.st_size; }
	
	/** \return block size */
	unsigned long
	BlockSize() const { return st.st_blksize; }
	
	/** \return number of blocks allocated */
	unsigned long
	Blocks() const { return st.st_blocks; }
	
	/** \return time of last access */
	time_t
	ATime() const { return st.st_atime; }
	
	/** \return time of last modification */
	time_t
	MTime() const { return st.st_mtime; }
	
	/** \return time of last change */
	time_t
	CTime() const { return st.st_ctime; }
	
private:
	/// stat structure
	struct stat	st;
};

}

#endif // _uds_fileinfo_hh
