static bool _BuildExecutablePath( const VFilePath &inPath, VFilePath& outExecutablePath)
{
	bool ok;
	if (inPath.IsFile())
	{
		outExecutablePath = inPath;
		ok = true;
	}
	else if (inPath.IsFolder())
	{
		// if path is a folder named truc.someextension,
		// look at truc.someextension\Contents\Windows\truc.dll
		
		// afabre : finally, we look the dll near the exe file
		VString name;
		inPath.GetName( name);
		outExecutablePath = inPath;
		outExecutablePath = outExecutablePath.ToParent().ToParent();
		outExecutablePath.SetFileName( name);
		outExecutablePath.SetExtension( CVSTR( "dll"));
		ok = true;
	}
	else
	{
		ok = false;
	}

	return ok;
}
VProjectItem* VProjectItemFile::Instantiate( const XBOX::VURL& inURL, VProjectItem *inParent, bool inExternalReference)
{
	VProjectItem *result = NULL;

	VFilePath path;
	if (inURL.GetFilePath( path))
	{
		if (path.IsFile())
		{
			VString fileName;
			path.GetFileName( fileName);

			VProjectItemFile *behaviour = new VProjectItemFile( NULL);
			if (behaviour != NULL)
			{
				result = new VProjectItem( behaviour);
				if (result != NULL)
				{
					result->SetURL( inURL);
					result->SetName( fileName);
					result->SetDisplayName( fileName);
					result->SetExternalReference( inExternalReference);

					if (inParent != NULL)
						inParent->AttachChild( result);
				}
			}
		}
	}
	return result;
}
VFile* XLinuxLibrary::RetainExecutableFile(const VFilePath &inFilePath) const
{
    //jmo - What are we supposed to retain ? First we try the exact path...

	if(inFilePath.IsFile())
		return new VFile(inFilePath);

    //jmo - If exact path doesn't work, we assume inFilePath to be part of a bundle
    //      and try to find the corresponding shared object.
    
    VFilePath bundlePath=inFilePath;

    while(!bundlePath.MatchExtension(CVSTR("bundle"), true /*case sensitive*/) && bundlePath.IsValid())
        bundlePath=bundlePath.ToParent();

    if(!bundlePath.IsValid())
        return NULL;

    VString name;
    bundlePath.GetFolderName(name, false /*no ext.*/);

    if(name.IsEmpty())
        return NULL;

    VString soSubPath=CVSTR("Contents/Linux/")+VString(name)+CVSTR(".so");

    VFilePath soPath;
    soPath.FromRelativePath(bundlePath, soSubPath, FPS_POSIX);
            
    if(soPath.IsFile())
        return new VFile(soPath);
    
    return NULL;
}
VFile* VProjectItemFile::RetainFile() const
{
	VFile *file = NULL;

	if (fOwner != NULL)
	{
		VFilePath path;
		if (fOwner->GetFilePath( path) && path.IsFile())
			file = new VFile( path);
	}
	return file;
}
bool VProjectItemFile::ConformsTo( const VString& inFileKindID) const
{
	bool result = false, done = false;

	if (fOwner != NULL)
	{
	#if 0	// sc 08/09/2011, optimization
		VFilePath path;
		if (fOwner->GetFilePath( path) && path.IsFile())
		{
			VFile file( path);
			if (file.Exists())
			{
				result = file.ConformsTo( inFileKindID);
				done = true;
			}
		}
	#endif

		if (!done)
		{
			VString extension;
			fOwner->GetExtension( extension);

			VFileKind *itemKind = VFileKindManager::Get()->RetainFirstFileKindMatchingWithExtension( extension);
			if (itemKind != NULL)
			{
				VFileKind *refKind = VFileKindManager::Get()->RetainFileKind( inFileKindID);
				if (refKind != NULL)
				{
					result = itemKind->ConformsTo( *refKind);
					ReleaseRefCountable( &refKind);
				}
				ReleaseRefCountable( &itemKind);
			}
		}
	}

	return result;
}