Skip to content
Snippets Groups Projects
Commit 890fa987 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

Création class System

parent e1bbe123
Branches
Tags
No related merge requests found
/*=========================================================================
Programme : OTB (ORFEO ToolBox)
Auteurs : CS - T. Feuvrier
Language : C++
Date : 28 juin 2006
Version :
Role : System operation
$Id$
=========================================================================*/
#include "otbSystem.h"
namespace otb
{
//GetExtension from uiig library.
std::string
System::GetExtension( const std::string& filename )
{
// This assumes that the final '.' in a file name is the delimiter
// for the file's extension type
const std::string::size_type it = filename.find_last_of( "." );
// This determines the file's type by creating a new string
// who's value is the extension of the input filename
// eg. "myimage.gif" has an extension of "gif"
std::string fileExt( filename, it+1, filename.length() );
return( fileExt );
}
//GetRootName from uiig library.
std::string
System::GetRootName( const std::string& filename )
{
const std::string fileExt = GetExtension(filename);
// Create a base filename
// i.e Image.ent --> Image
if( fileExt.length() > 0 )
{
const std::string::size_type it = filename.find_last_of( fileExt );
std::string baseName( filename, 0, it-fileExt.length() );
return( baseName );
}
//Default to return same as input when the extension is nothing (Analyze)
return( filename );
}
}
/*=========================================================================
Programme : OTB (ORFEO ToolBox)
Auteurs : CS - T. Feuvrier
Language : C++
Date : 28 juin 2006
Version :
Role : System operations
$Id$
=========================================================================*/
#ifndef _otbSystem_h
#define _otbSystem_h
#include <string>
namespace otb
{
/** \class System
* \brief System operations.
*
* System operations, filename manipulations, etc.
*
*/
class System
{
public:
/** Standard class typedefs. */
typedef System Self;
/** Get the extension of the file name */
static std::string GetExtension( const std::string& filename );
/** Get the root name */
static std::string GetRootName( const std::string& filename );
};
} // namespace otb
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment