/***************************************************************************
                            QFileInfo.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <qtc/qt_QFileInfo.h>
#include <qtobjc/QFileInfo.h>

@implementation  QFileInfo

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


- init
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileInfo()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileInfo1((qt_QString *) [file toQString: &_qstring_file])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithFile: (QFile *)arg1
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileInfo2((qt_QFile *) [arg1 qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDir: (QDir *)arg1 fileName: (NSString *)fileName
{
static qt_QString * _qstring_fileName = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QFileInfo3((qt_QDir *) [arg1 qt], (qt_QString *) [fileName toQString: &_qstring_fileName])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	QFileInfo * aCopy;
	aCopy = [[(QFileInfo *)[[self class] allocWithZone: zone] setQt: qt_new_QFileInfo4([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			qt_del_QFileInfo((qt_QFileInfo *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- setFileWithName: (NSString *)file
{
static qt_QString * _qstring_file = 0L;
	qt_QFileInfo_setFile((qt_QFileInfo *)[self qt], (qt_QString *) [file toQString: &_qstring_file]);
	return self;
}

- setFileWithFile: (QFile *)arg1
{
	qt_QFileInfo_setFile1((qt_QFileInfo *)[self qt], (qt_QFile *) [arg1 qt]);
	return self;
}

- setFileWithDirectory: (QDir *)arg1 fileName: (NSString *)fileName
{
static qt_QString * _qstring_fileName = 0L;
	qt_QFileInfo_setFile2((qt_QFileInfo *)[self qt], (qt_QDir *) [arg1 qt], (qt_QString *) [fileName toQString: &_qstring_fileName]);
	return self;
}

- (BOOL) exists
{
	return (BOOL) qt_QFileInfo_exists((qt_QFileInfo *)[self qt]);
}

- refresh
{
	qt_QFileInfo_refresh((qt_QFileInfo *)[self qt]);
	return self;
}

- (BOOL) caching
{
	return (BOOL) qt_QFileInfo_caching((qt_QFileInfo *)[self qt]);
}

- setCaching: (BOOL)arg1
{
	qt_QFileInfo_setCaching((qt_QFileInfo *)[self qt], (int)arg1);
	return self;
}

- (NSString *) filePath
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_filePath((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) fileName
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_fileName((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) absFilePath
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_absFilePath((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) baseName: (BOOL)complete
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_baseName((qt_QFileInfo *)[self qt], (int)complete);
	return [NSString fromQString: _qstring];
}

- (NSString *) extension: (BOOL)complete
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_extension((qt_QFileInfo *)[self qt], (int)complete);
	return [NSString fromQString: _qstring];
}

- (NSString *) dirPath: (BOOL)absPath
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_dirPath((qt_QFileInfo *)[self qt], (int)absPath);
	return [NSString fromQString: _qstring];
}

- (QDir*) dir: (BOOL)absPath
{
	return (QDir*) [QtSupport objectForQtKey: qt_QFileInfo_dir((qt_QFileInfo *)[self qt], (int)absPath) withClass: [QDir class] allocatedInObjcWorld: YES];
}

- (QDir*) dir
{
	return (QDir*) [QtSupport objectForQtKey: qt_QFileInfo_dir((qt_QFileInfo *)[self qt], 0) withClass: [QDir class] allocatedInObjcWorld: YES];
}

- (BOOL) isReadable
{
	return (BOOL) qt_QFileInfo_isReadable((qt_QFileInfo *)[self qt]);
}

- (BOOL) isWritable
{
	return (BOOL) qt_QFileInfo_isWritable((qt_QFileInfo *)[self qt]);
}

- (BOOL) isExecutable
{
	return (BOOL) qt_QFileInfo_isExecutable((qt_QFileInfo *)[self qt]);
}

- (BOOL) isRelative
{
	return (BOOL) qt_QFileInfo_isRelative((qt_QFileInfo *)[self qt]);
}

- (BOOL) convertToAbs
{
	return (BOOL) qt_QFileInfo_convertToAbs((qt_QFileInfo *)[self qt]);
}

- (BOOL) isFile
{
	return (BOOL) qt_QFileInfo_isFile((qt_QFileInfo *)[self qt]);
}

- (BOOL) isDir
{
	return (BOOL) qt_QFileInfo_isDir((qt_QFileInfo *)[self qt]);
}

- (BOOL) isSymLink
{
	return (BOOL) qt_QFileInfo_isSymLink((qt_QFileInfo *)[self qt]);
}

- (NSString *) readLink
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_readLink((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) owner
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_owner((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (unsigned int) ownerId
{
	return (unsigned int) qt_QFileInfo_ownerId((qt_QFileInfo *)[self qt]);
}

- (NSString *) group
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QFileInfo_group((qt_QFileInfo *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (unsigned int) groupId
{
	return (unsigned int) qt_QFileInfo_groupId((qt_QFileInfo *)[self qt]);
}

- (BOOL) permission: (int)permissionSpec
{
	return (BOOL) qt_QFileInfo_permission((qt_QFileInfo *)[self qt], (int)permissionSpec);
}

- (unsigned int) size
{
	return (unsigned int) qt_QFileInfo_size((qt_QFileInfo *)[self qt]);
}

- (NSDate *) created
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QFileInfo_created((qt_QFileInfo *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDateTime: _qdate];
}

- (NSDate *) lastModified
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QFileInfo_lastModified((qt_QFileInfo *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDateTime: _qdate];
}

- (NSDate *) lastRead
{
static qt_QDateTime * _qdate = 0L;
	_qdate = qt_QFileInfo_lastRead((qt_QFileInfo *)[self qt]);
	return (NSDate *) [[NSDate alloc] initWithQDateTime: _qdate];
}

+ (int) ReadUser
{
	return (int) QFILEINFO_ReadUser;
}

+ (int) WriteUser
{
	return (int) QFILEINFO_WriteUser;
}

+ (int) ExeUser
{
	return (int) QFILEINFO_ExeUser;
}

+ (int) ReadGroup
{
	return (int) QFILEINFO_ReadGroup;
}

+ (int) WriteGroup
{
	return (int) QFILEINFO_WriteGroup;
}

+ (int) ExeGroup
{
	return (int) QFILEINFO_ExeGroup;
}

+ (int) ReadOther
{
	return (int) QFILEINFO_ReadOther;
}

+ (int) WriteOther
{
	return (int) QFILEINFO_WriteOther;
}

+ (int) ExeOther
{
	return (int) QFILEINFO_ExeOther;
}

@end
