//==============================================================================
Error createDirectory(const CString& dir)
{
	Error err = ErrorCode::NONE;
	if(CreateDirectory(dir.get(), NULL) == 0)
	{
		ANKI_LOGE("Failed to create directory %s", dir.get());
		err = ErrorCode::FUNCTION_FAILED;
	}

	return err;
}
//==============================================================================
Bool directoryExists(const CString& filename)
{
	DWORD dwAttrib = GetFileAttributes(filename.get());

	return dwAttrib != INVALID_FILE_ATTRIBUTES 
		&& (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
}
//==============================================================================
Error removeDirectory(const CString& dirname)
{
	Error err = ErrorCode::NONE;
	SHFILEOPSTRUCTA fileOperation;
	fileOperation.wFunc = FO_DELETE;
	fileOperation.pFrom = dirname.get();
	fileOperation.fFlags = FOF_NO_UI | FOF_NOCONFIRMATION;

	I result = SHFileOperationA(&fileOperation);
	if(result != 0) 
	{
		ANKI_LOGE("Could not delete directory %s", dirname.get());
		err = ErrorCode::FUNCTION_FAILED;
	}

	return err;
}
void IFPAnimationViewerWidget::reloadAnimationFile()
{
	if (currentAnim) {
		currentAnim = NULL;
	}
	if (anpk) {
		delete anpk;
		anpk = NULL;
	}

	ui.animSlider->setEnabled(false);

	ui.animList->clear();

	QString fname = ui.animField->text();
	File file(fname.toLocal8Bit().constData());

	if (!file.exists()) {
		Engine::StringResourceCache::Entry* entry = Engine::getInstance()->getAnimationCache()
				->getEntryPointer(fname.toLocal8Bit().constData()).getEntry();

		if (!entry)
			return;

		anpk = ((AnimationCacheEntry*) entry)->getPackage();
	} else {
		anpk = new AnimationPackage;

		IFPLoader ifp(file);

		IFPAnimation* ianim;
		while ((ianim = ifp.readAnimation())  !=  NULL) {
			Animation* anim = new Animation(ianim);
			anpk->addAnimation(CString(ianim->getName()).lower(), anim);
			delete ianim;
		}
	}

	for (AnimationPackage::AnimIterator it = anpk->getAnimationBegin() ; it != anpk->getAnimationEnd() ; it++) {
		Animation* anim = it->second;
		CString animName = it->first;
		ui.animList->addItem(animName.get());
	}

	StaticAnimationPackagePointer* anpkPtr = new StaticAnimationPackagePointer(anpk);
	renderWidget->setAnimationPackagePointer(anpkPtr);
}