Beispiel #1
0
    Ogre::String File::absPath() const
    {
        if(isPathAbsolute())
            return fullPath();

        return File::getCurrentDirectory()/fullPath();
    }
/**
* @internal
* @brief Initializes the class so it becomes valid.
*
* @param[in] width		width resolution capture
* @param[in] height		height resolution capture
* @param[in] fileName	Output file name
* @param[in] fps		frames per second to capture
*/
bool BaseVideoRecorder::init( int width, int height, const std::string& fileName, float fps /*= 25*/)
{
	// Build absolute path
	m_path = fileName;
	if ( isPathAbsolute( m_path ) == false )
	{	
		m_path = dataFolder + m_path;
	}

	if( m_path.size() == 0 )
	{
		LOG_CRITICAL("OCVVideoRecorder::init() - Output file name inside VideoRecorder is empty, you must provide a name for the output file");
		m_bIsValid = false;
		return false;
	}

	// Store data
	m_width			= width;
	m_height		= height;
	m_fps			= fps;

	// The class is now initialized
	m_bIsValid = true;

	return true;
}
Beispiel #3
0
 static inline std::string getAbsolutePath(PathNode &node,
                                           std::string const &path) {
     if (isPathAbsolute(path)) {
         return path;
     }
     return getFullPath(treePathRetrieve(node, path));
 }
Beispiel #4
0
/* in rfc: path = path-abempty | path-absolute | path-noscheme | path-rootless | path-empty
 * This function implements one rule: 
 * path = path-absolute ; begins with "/" but not  "//"
 */
int
isValidPath(char *path)
{
	if (path == NULL) {
		printf("a");
		return 0;
	}

	return isPathAbsolute(path);
}
Beispiel #5
0
string BASE_SESSION_CLASS::getAbsolutePixelPathname(char *filename_ptr)

//  DESCRIPTION     : Get the absolute pixel pathname by checking the incoming
//					  filename and combining it with the script root where necessary.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	char buffer[_MAX_PATH];
	string pathname = "";

	// check if the filename is already absolute
	if (isPathAbsolute(filename_ptr))
	{
		// filename is absolute
		pathname = filename_ptr;
	}
	else
	{
		// add the script root
		strcpy(buffer, getDicomScriptRoot());

//		// add the filename
//#ifdef _WINDOWS
//		strcat(buffer, "\\");
//#else
//		strcat(buffer, "/");
//#endif
		strcat(buffer, filename_ptr);

		// reduce pathname to its shortest form
		reducePathname(buffer);

		// filename is now absolute
		pathname = buffer;
	}

	// log the pixel filename
	if (loggerM_ptr)
	{
		loggerM_ptr->text(LOG_DEBUG, 1, "Pixel filename: \"%s\"", pathname.c_str());
	}

	// return absolute pixel file pathname
	return pathname;
}
Beispiel #6
0
 bool addAlias(PathNode &node, std::string const &source,
               AliasPriority priority) {
     ParsedAlias newSource(source);
     if (!newSource.isValid()) {
         /// @todo signify invalid route in some other way?
         OSVR_DEV_VERBOSE("Could not parse source: " << source);
         return false;
     }
     if (!isPathAbsolute(newSource.getLeaf())) {
         /// @todo signify not to pass relative paths here in some other way?
         OSVR_DEV_VERBOSE(
             "Source contains a relative path, not permitted: " << source);
         return false;
     }
     return addAliasImpl(node, newSource.getAlias(), priority);
 }
Beispiel #7
0
	/**
	 * Builds an absolute path to the file that will be loaded into the player
	 * @return true if there was no problem
	 */
	bool MediaPlayerOCV::buildPathToFile( const std::string& path )
	{
		// Store incomming path as the filename (if it's a local file, the use would have passed the file path
		// relative to the data folder)
		 m_fileName = path;
        
        if ( isPathAbsolute(path) )
            m_filePath = path;
        else
            m_filePath = dataFolder + path;
		
        if ( !fileExists( m_filePath ) )
		{
			LOG_ERROR( "MediaPlayer: File %s not found in data folder.", path.c_str() );
			return false;
		}
		
		return true;
	}
Beispiel #8
0
void BASE_SESSION_CLASS::addDefinitionDirectory(string definitionDirectory)

//  DESCRIPTION     : Add a Definition Directory to the Session list.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	string lDefinitionDirectory;

	// check if the filename is already absolute
	if (isPathAbsolute((char*) definitionDirectory.c_str()))
	{
		lDefinitionDirectory = definitionDirectory;
	}
	else
	{
		// start from session directory
		lDefinitionDirectory = sessionDirectoryM;

		// save the absolute results file root
		makeRootAbsolute(lDefinitionDirectory, (char*) definitionDirectory.c_str());
	}

    //
    // Add backslash at the end of the lDefinitionDirectory directory path
    //
    if (lDefinitionDirectory[lDefinitionDirectory.length()-1] != '\\')
    {
        lDefinitionDirectory += "\\";
    }

	// log the definition directory
	if (loggerM_ptr)
	{
		loggerM_ptr->text(LOG_DEBUG, 1, "Definition directory: \"%s\"", lDefinitionDirectory.c_str());
	}

    // add the directory to the list
    definitionDirectoryM.push_back(lDefinitionDirectory);
}
	/**
	* @brief Adds another resource location to be loaded (which may contain any asset: material scripts, shaders, textures, models...)
	* 
	* @param path Path to the folder to be added. It may be an absolute path, or relative to the executable
	* @param recursive If true, all the folders contained within the specified path will be added recursively. If false, only 
	* the specified folder will be added.
	* @note This method must be called first thing in the setup(), before creating the window with size/fullscreen
	*/
	void ResourceManager::addResourceLocation( const std::string path, bool recursive /*= true*/ )
	{	
		if ( !isValid() )
		{
			LOG_ERROR( "ResourceManager::addResourceLocation. Error: Trying to add a resource location before the ResourceManager has been initialized" );
			return;
		}

		std::string absPath = path;
		// if the path is not absolute, build it
		if ( isPathAbsolute( absPath ) == false )
			absPath = userExecPath + path;

		// Add the resource and initialise it
		//static int idCounter = 0;
		//std::string newResourceGroupName = userResourcesGroupName + toString(idCounter++);
		//Ogre::ResourceGroupManager::getSingleton().addResourceLocation( absPath, "FileSystem", userResourcesGroupName, recursive );
		//Ogre::ResourceGroupManager::getSingleton().loadResourceGroup( userResourcesGroupName );
		m_userAdditionalResourceLocations.push_back( ResourceLocation(absPath, recursive) );
	}
Beispiel #10
0
void BASE_SESSION_CLASS::makeRootAbsolute(string &root, char *root_ptr)

//  DESCRIPTION     : Take the root pointer and turn it into an absolute root.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	// copy the session directory
	char buffer[_MAX_PATH];
	strcpy(buffer, (char*) sessionDirectoryM.c_str());
    if (sessionDirectoryM[sessionDirectoryM.length()-1] != '\\')
        strcat(buffer, "\\");

   // check for current directory
   if (strcmp(root_ptr, ".\\") == 0)
   {
	   	// return session directory
		root = sessionDirectoryM;
		return;
   }

	// check if the root is already absolute
	if (isPathAbsolute(root_ptr))
	{
		// pathname is absolute
		strcpy(buffer, root_ptr);
	}
	else
	{
		// add current working directory
		strcat(buffer, root_ptr);
	}

	// reduce pathname to its shortest form
	reducePathname(buffer);

	// copy store result
	root = buffer;
}
Beispiel #11
0
void BASE_SESSION_CLASS::setDescriptionDirectory(string descriptionDirectory)

//  DESCRIPTION     : Set the Description Directory - directory where the test script descriptions are stored.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	// check if the filename is already absolute
	if (isPathAbsolute((char*) descriptionDirectory.c_str()))
	{
		descriptionDirectoryM = descriptionDirectory;
	}
	else
	{
		// start from session directory
		descriptionDirectoryM = sessionDirectoryM;

		// save the absolute results file root
		makeRootAbsolute(descriptionDirectoryM, (char*) descriptionDirectory.c_str());
	}

    //
    // Add backslash at the end of the descriptionDirectory directory path
    //
    if (descriptionDirectoryM[descriptionDirectoryM.length()-1] != '\\')
    {
        descriptionDirectoryM += "\\";
    }

	// log the description directory
	if (loggerM_ptr)
	{
		loggerM_ptr->text(LOG_DEBUG, 1, "Description directory: \"%s\"", descriptionDirectoryM.c_str());
	}
}
Beispiel #12
0
bool BASE_SESSION_CLASS::unloadDefinition(string definitionFileName)

//  DESCRIPTION     : Unload the given definition file.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	DEFINITION_FILE_CLASS* definitionFile_ptr = 0;
	UINT i = 0;
	bool found = false;
	AE_SESSION_CLASS ae_session;

	ae_session.SetName (this->getApplicationEntityName ());
	ae_session.SetVersion (this->getApplicationEntityVersion ());

	while ( i < definitionFileM_ptr.getSize() && !found)
	{
		definitionFile_ptr = definitionFileM_ptr[i];
		const char* defFileName = definitionFile_ptr->getFilename();
		if(!isPathAbsolute((char*)defFileName))
		{
			defFileName = definitionFile_ptr->getAbsoluteFilename();
		}
		if (strcmp(defFileName, definitionFileName.c_str()) == 0)
		{
			// We have found the definition file
			// Remove it and pass the filename to the definition component for removal
			string sopClassUid;
			if (definitionFile_ptr->IsLoaded())
			{
				definitionFile_ptr->Unload();
				sopClassUid = DEFINITION->GetLastSopUidRemoved();
			}
			definitionFileM_ptr.removeAt(i);


			if (sopClassUid.length())
			{
				// check if we are dealing with a print sop class
				if (DEFINITION->IsPrintSop(sopClassUid, &ae_session))
				{
					// try to get containing meta sop class from sop class
					string metaSopUid = DEFINITION->GetMetaSopUid(sopClassUid);
					if (metaSopUid.length())
					{
						// meta sop class uid is the key for removal
						sopClassUid = metaSopUid;
					}
				}
beginLoop:
				// now check if the abstract mappings should be updated
				for (UINT i = 0; i < abstractMapM.getSize(); i++)
				{
					if (abstractMapM[i].isSopClassUid(sopClassUid))
					{
						// we need to remove this mapping
						if (loggerM_ptr)
						{
							loggerM_ptr->text(LOG_DEBUG, 1, "Removed abstract mapping for %s", sopClassUid.c_str());
						}
						abstractMapM.removeAt(i);

						// this is done on purpose as abstractMapM.getSize() is affected by the removal
						// of items
						goto beginLoop;
					}
				}
			}

			found = true;
		}

		++i;
	}

	// return the unload result
	return found;
}
Beispiel #13
0
bool BASE_SESSION_CLASS::loadDefinition(string definitionFileName)

//  DESCRIPTION     : Load the given definition file.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      :
//  NOTES           :
//<<===========================================================================
{
	bool result = false;

    bool loaded = false;
    UINT nrOfDefinitionFiles = noDefinitionFiles();
    for (UINT index = 0; index < nrOfDefinitionFiles; index++)
    {
        DEFINITION_FILE_CLASS* pDefFile = getDefinitionFile(index);
		const char* defFileName = pDefFile->getFilename();
		if(!isPathAbsolute((char*)defFileName))
		{
			defFileName = pDefFile->getAbsoluteFilename();
		}
        if (strcmp(defFileName, definitionFileName.c_str()) == 0)
        {
            loaded = true;
            result = true;
            break;
        }
    }
    // Skip loading if already loaded.
    if (loaded) return result;

	// allocate a new defintion file
	DEFINITION_FILE_CLASS	*definitionFile_ptr = new DEFINITION_FILE_CLASS(this, definitionFileName);

	if (definitionFile_ptr)
	{
		if (loggerM_ptr)
		{
			loggerM_ptr->text(LOG_NONE, 1, "Loading Definition File: -");
			loggerM_ptr->text(LOG_NONE, 1, "\t%s", definitionFile_ptr->getFilename());
		}

		// load defintion file
		result = definitionFile_ptr->Load();

		// on success add file to session list
		if (result)
		{
			addDefinitionFile(definitionFile_ptr);

			// check if the abstract mapping need setting up
			checkAbstractMappings();
		}
		else
		{
			// failed to load definition file
			if (loggerM_ptr)
			{
				loggerM_ptr->text(LOG_NONE, 1, "%s %s", VAL_PREFIX_FAILED, definitionFile_ptr->getFilename());
			}

			delete definitionFile_ptr;
		}
	}

	// return the load result
	return result;
}