//	utf-8

/*	Copyright  (c)	Günter Woigk   2001-2003
  					mailto:kio@little-bat.de

	This file is free software

 	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.  

 	Permission to use, copy, modify, distribute, and sell this software and
 	its documentation for any purpose is hereby granted without fee, provided
 	that the above copyright notice appear in all copies and that both that
 	copyright notice and this permission notice appear in supporting
 	documentation, and that the name of the copyright holder not be used
 	in advertising or publicity pertaining to distribution of the software
 	without specific, written prior permission. The copyright holder makes no
 	representations about the suitability of this software for any purpose.
 	It is provided "as is" without express or implied warranty.

 	THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 	INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 	EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 	CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 	DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 	TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 	PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef _file_utilities_h_
#define	_file_utilities_h_

#include "kio/kio.h"

typedef enum
{
	s_none	= M4('n','o','n','e'),
	s_file	= M4('f','i','l','e'),
	s_dir	= M4('d','i','r',' '),
	s_tty	= M4('t','t','y',' '),
	s_pipe	= M4('p','i','p','e'),
	s_sock	= M4('s','o','c','k'),
	s_block	= M4('b','l','o','k'),
	s_link	= M4('l','i','n','k'),
	s_null	= M4('n','u','l','l'),
	s_unkn	= M4('u','n','k','n')
}
s_type;


s_type ClassifyFile ( mode_t mode );
s_type ClassifyFile ( int    fd   );
s_type ClassifyFile ( FILE*  file );
s_type ClassifyFile ( cstr   path );



void SetBlocking ( int fd, bool onoff );
void SetAsync ( int fd, bool onoff );
void SetBlocking ( FILE*, bool onoff );
void SetAsync ( FILE*, bool onoff );


time_t FileMTime ( cstr path );		// modification time
time_t FileATime ( cstr path );		// last access time



off_t FileLength ( cstr  path );
off_t FileLength ( int   fd   );
off_t FileLength ( FILE* file );


cstr FileNameFromPath ( cstr path );
cstr ExtensionFromPath ( cstr path );
cstr BasenameFromPath ( cstr path );
cstr DirectoryPathFromPath ( cstr path );
cstr FullPath ( cstr path );


cstr TempFileName ( cstr file );


void TerminalSize	( int tty, uint& rows, uint& cols );
uint TerminalRows	( int tty );
uint TerminalCols	( int tty );
uint TerminalWidth	( int tty );
uint TerminalHeight	( int tty );


#endif


