Isis Developer Reference
Isis::FileName Class Reference

File name manipulation and expansion. More...

#include <FileName.h>

Collaboration diagram for Isis::FileName:
Collaboration graph

Public Member Functions

 FileName ()
 Constructs an empty FileName object.
 
 FileName (const char *fileName)
 Constructs a FileName object using a char pointer as a file name.
 
 FileName (const QString &fileName)
 Constructs a FileName object using a QString as a file name.
 
 FileName (const FileName &other)
 Constructs a copy of a FileName object using another FileName object.
 
 ~FileName ()
 Destroys the FileName object.
 
QString originalPath () const
 Returns the path of the original file name.
 
QString path () const
 Returns the path of the file name.
 
QString attributes () const
 Returns a QString of the attributes in a filename, attributes are expected to be of type CubeAttributeInput or CubeAttributeOutput.
 
QString baseName () const
 Returns the name of the file without the path and without extensions.
 
QString name () const
 Returns the name of the file excluding the path and the attributes in the file name.
 
QString extension () const
 Returns the last extension of the file name.
 
QString expanded () const
 Returns a QString of the full file name including the file path, excluding the attributes.
 
QString original () const
 Returns the full file name including the file path.
 
FileName addExtension (const QString &extension) const
 Adds a new extension to the file name.
 
FileName removeExtension () const
 Removes all extensions in the file name.
 
FileName setExtension (const QString &extension) const
 Sets all current file extensions to a new extension in the file name.
 
bool isVersioned () const
 Checks to see if a file name is versioned by date or numerically.
 
bool isNumericallyVersioned () const
 Checks if the file name is versioned numerically.
 
bool isDateVersioned () const
 Checks if the file name is versioned by date.
 
FileName highestVersion () const
 Searches the directory specified in the file name for the highest version of the file name.
 
FileName newVersion () const
 Updates the file name to be the latest version.
 
bool fileExists () const
 Returns true if the file exists; false otherwise.
 
QDir dir () const
 Returns the path of the file's parent directory as a QDir object.
 
QString toString () const
 Returns a QString of the full file name including the file path, excluding the attributes with any Isis Preferences or environment variables indicated by $, changed to what they represent.
 
FileNameoperator= (const FileName &rhs)
 Clears the current contents of the FileName object and reinitializes it with the argument.
 
bool operator== (const FileName &rhs)
 Compares equality of two FileName objects.
 
bool operator!= (const FileName &rhs)
 Compares equality of two FileName objects.
 

Static Public Member Functions

static FileName createTempFile (FileName templateFileName="$TEMPORARY/temp")
 Creates a temporary file and returns a FileName object created using the temporary file.
 

Detailed Description

File name manipulation and expansion.

This class is used for manipulating filenames. It allows access to the path, extension, base name and Isis attributes. A standard Isis filename takes the form of

/path/base.extension+attribute
QString path() const
Returns the path of the file name.
Definition FileName.cpp:103

For example:

/work1/mars.cub+5
Author
2002-06-11 Jeff Anderson

Constructor & Destructor Documentation

◆ FileName() [1/4]

Isis::FileName::FileName ( )

◆ FileName() [2/4]

Isis::FileName::FileName ( const char * file)

Constructs a FileName object using a char pointer as a file name.

Parameters
filechar pointer representing new filename

◆ FileName() [3/4]

Isis::FileName::FileName ( const QString & file)

Constructs a FileName object using a QString as a file name.

Parameters
fileQstring representing new filename

◆ FileName() [4/4]

Isis::FileName::FileName ( const FileName & other)

Constructs a copy of a FileName object using another FileName object.

Parameters
&otherFileName object to copy.

◆ ~FileName()

Isis::FileName::~FileName ( )

Destroys the FileName object.

Member Function Documentation

◆ addExtension()

FileName Isis::FileName::addExtension ( const QString & newExtension) const

Adds a new extension to the file name.

If the current extension is the same as the new extension it will return an unchanged FileName object.

Parameters
newExtensionThe new file extension to be added at the end of the file name after all exisiting extensions.
Returns
FileName object with added extension

References attributes(), extension(), FileName(), name(), and originalPath().

Referenced by setExtension().

◆ attributes()

QString Isis::FileName::attributes ( ) const

Returns a QString of the attributes in a filename, attributes are expected to be of type CubeAttributeInput or CubeAttributeOutput.

Filenames without any attributes return an empty QString.

  for a full file specification of:
   "/tmp/Peaks.cub+Bsq"
  attributes() gives:
   "Bsq"
Returns
QString of the attributes specified in the filename.

Referenced by addExtension(), removeExtension(), and Isis::CubeAttribute< ChildClass >::setAttributes().

◆ baseName()

QString Isis::FileName::baseName ( ) const

Returns the name of the file without the path and without extensions.

  for a full file specification of:
   "/tmp/Peaks.cub.gz"
  baseName() gives:
   "Peaks"
Returns
QString containing every character excluding the path and all extensions.

Referenced by Isis::PipelineApplication::BuildParamString(), createTempFile(), Isis::Pipeline::FinalOutput(), Isis::ProcessExportPds4::identificationArea(), and removeExtension().

◆ createTempFile()

FileName Isis::FileName::createTempFile ( FileName templateFileName = "$TEMPORARY/temp")
static

Creates a temporary file and returns a FileName object created using the temporary file.

Parameters
templateFileNamethe file name used to create the temporary file.
Returns
FileName object created using the temporary file
Exceptions
Isis::IException::Io

References _FILEINFO_, baseName(), extension(), FileName(), Isis::IException::Io, original(), originalPath(), and path().

◆ dir()

QDir Isis::FileName::dir ( ) const

◆ expanded()

QString Isis::FileName::expanded ( ) const

Returns a QString of the full file name including the file path, excluding the attributes.

Any Isis Preferences or environment variables indicated by $, are changed to what they represent.

Returns
QString
  for a full file specification of:
   QString(ISISROOT) + "/tmp/Peaks.cub+Bsq"
  expanded() gives:
   "/usgs/pkgs/isis3/isis/tmp/Peaks.cub"

Any Isis Preferences or environment variables indicated by $, are changed to what they represent.

  for a full file specification of:
   "$ISISROOT/tmp/Peaks.cub+Bsq"
  expanded() gives:
   "/usgs/pkgs/isis3/isis/tmp/Peaks.cub"
Returns
QString

Referenced by Isis::SerialNumberList::add(), Isis::SerialNumberList::add(), Isis::CubeDataThread::AddCube(), Isis::GuiParameter::AddHelpers(), Isis::Application::Application(), Isis::Blob::Blob(), Isis::CorrelationMatrix::computeCorrelationMatrix(), Isis::Cube::create(), Isis::ControlPointEditWidget::createControlPoint(), dir(), Isis::ImportMapTemplateWorkOrder::execute(), Isis::ImportRegistrationTemplateWorkOrder::execute(), Isis::ProcessImportFits::extraFitsLabel(), fileExists(), Isis::Cube::fileName(), Isis::SerialNumberList::fileNameIndex(), Isis::ProcessImportFits::fitsImageLabel(), Isis::MosaicTool::getIcon(), Isis::GuiFileNameParameter::GuiFileNameParameter(), Isis::BundleSolutionInfo::inputControlNetFileName(), Isis::BundleSolutionInfo::inputLidarDataFileName(), isDateVersioned(), isNumericallyVersioned(), Isis::Mariner10Camera::Mariner10Camera(), Isis::MdiCubeViewport::MdiCubeViewport(), Isis::Process::MissionData(), Isis::ObservationNumberList::observationNumber(), Isis::Cube::open(), Isis::CubeManager::OpenCube(), operator==(), Isis::BundleSolutionInfo::outputHeader(), path(), Isis::CorrelationMatrix::pvlObject(), Isis::ImageOverlapSet::ReadImageOverlaps(), Isis::Cube::reopen(), Isis::BundleSolutionInfo::save(), Isis::SerialNumberList::serialNumber(), Isis::CorrelationMatrix::setCovarianceFileName(), Isis::Pipeline::SetInputListFile(), Isis::MdiCubeViewport::setLinked(), Isis::ImportImagesWorkOrder::setupExecution(), Isis::ImportShapesWorkOrder::setupExecution(), Isis::ProcessMosaic::StartProcess(), Isis::Tool::Tool(), toString(), Isis::BundleSolutionInfo::updateFileName(), Isis::BlinkTool::updateTool(), Isis::VikingCamera::VikingCamera(), Isis::WarningWidget::WarningWidget(), Isis::Cube::write(), Isis::ImageOverlapSet::WriteImageOverlaps(), and Isis::QnetNavTool::~QnetNavTool().

◆ extension()

QString Isis::FileName::extension ( ) const

Returns the last extension of the file name.

  for a full file specification of:
   "/tmp/Peaks.cub.gz"
  extension() gives:
   "gz"
Returns
QString containing every character in the file name after the last "." character.

Referenced by addExtension(), createTempFile(), setExtension(), Isis::ImportImagesWorkOrder::setupExecution(), and Isis::ImportShapesWorkOrder::setupExecution().

◆ fileExists()

bool Isis::FileName::fileExists ( ) const

◆ highestVersion()

FileName Isis::FileName::highestVersion ( ) const

Searches the directory specified in the file name for the highest version of the file name.

Returns a FileName object with the file name changed to reflect the highest version.

Returns
FileName object

References _FILEINFO_, isDateVersioned(), isNumericallyVersioned(), isVersioned(), name(), originalPath(), and Isis::IException::Unknown.

Referenced by Isis::Process::MissionData().

◆ isDateVersioned()

bool Isis::FileName::isDateVersioned ( ) const

Checks if the file name is versioned by date.

Returns true if the file is versioned by date; returns false otherwise.

Returns
Boolean

References expanded(), and FileName().

Referenced by highestVersion(), isVersioned(), and newVersion().

◆ isNumericallyVersioned()

bool Isis::FileName::isNumericallyVersioned ( ) const

Checks if the file name is versioned numerically.

Returns true if the file is versioned numerically; returns false otherwise.

Returns
Boolean

References expanded(), and FileName().

Referenced by highestVersion(), isVersioned(), and newVersion().

◆ isVersioned()

bool Isis::FileName::isVersioned ( ) const

Checks to see if a file name is versioned by date or numerically.

Returns true if file is versioned by date or numerically; returns false otherwise.

Returns
Boolean

References isDateVersioned(), and isNumericallyVersioned().

Referenced by highestVersion(), and newVersion().

◆ name()

QString Isis::FileName::name ( ) const

◆ newVersion()

FileName Isis::FileName::newVersion ( ) const

Updates the file name to be the latest version.

If the file is versioned by date the newest version will be the current date. If the file is versioned numerically, the newest version will be the current version plus one.

Returns
FileName object with the new version file name.
Exceptions
Isis::IException::Unknown

References _FILEINFO_, fileExists(), isDateVersioned(), isNumericallyVersioned(), isVersioned(), name(), originalPath(), and Isis::IException::Unknown.

◆ operator!=()

bool Isis::FileName::operator!= ( const FileName & rhs)

Compares equality of two FileName objects.

Returns false if the two objects are equal and true otherwise.

Parameters
rhsFileName to compare the current FileName object to.
Returns
Boolean

◆ operator=()

FileName & Isis::FileName::operator= ( const FileName & rhs)

Clears the current contents of the FileName object and reinitializes it with the argument.

Parameters
rhsFileName to replace the current contents of the object.
Returns
void

◆ operator==()

bool Isis::FileName::operator== ( const FileName & rhs)

Compares equality of two FileName objects.

Returns true if the two objects are equal and false otherwise.

Parameters
rhsFileName to compare the current FileName object to.
Returns
Boolean

References expanded().

◆ original()

QString Isis::FileName::original ( ) const

Returns the full file name including the file path.

Returns
QString containing every character in the file name and the path
  for a full file specification of:
   QString(ISISROOT) + "/tmp/Peaks.cub+Bsq"
  original() gives:
   QString(ISISROOT) + "/tmp/Peaks.cub+Bsq"
  for a full file specification of:
   "$ISISROOT/tmp/Peaks.cub+Bsq"
  original() gives:
   "$ISISROOT/tmp/Peaks.cub+Bsq"
Returns
QString containing every character in the file name and the path

Referenced by Isis::Cube::create(), createTempFile(), Isis::Process::MissionData(), Isis::Cube::relocateDnData(), Isis::ControlList::save(), Isis::ImageList::save(), Isis::ShapeList::save(), Isis::TemplateList::save(), Isis::ImportImagesWorkOrder::setupExecution(), and Isis::ImportShapesWorkOrder::setupExecution().

◆ originalPath()

QString Isis::FileName::originalPath ( ) const

Returns the path of the original file name.

For *nix operating systems this includes everything up to but not including the last slash "/". For filenames created without any slashes the current working directory will be returned.

  for a full file specification of:
   "/home/me/img/picture.jpg"
  originalPath() gives:
   "/home/me/img"
Returns
QString of the path portion of the original filename.

Referenced by Isis::Directory::addBundleObservationView(), addExtension(), createTempFile(), highestVersion(), newVersion(), and removeExtension().

◆ path()

QString Isis::FileName::path ( ) const

Returns the path of the file name.

For *nix operating systems this includes everything up to but not including the last slash "/". For filenames created without any slashes the current working directory will be returned.

  for a full file specification of:
   "/home/me/img/picture.jpg"
  path() gives:
   "/home/me/img"
Returns
QString of the path portion of the filename.

References expanded().

Referenced by createTempFile(), Isis::Image::deleteFromDisk(), Isis::Shape::deleteFromDisk(), Isis::Pipeline::FinalOutput(), Isis::Blob::Find(), Isis::Cube::open(), Isis::BundleSolutionInfo::save(), Isis::ControlList::save(), Isis::ImageList::save(), Isis::ShapeList::save(), Isis::TemplateList::save(), Isis::ImportImagesWorkOrder::setupExecution(), Isis::ImportShapesWorkOrder::setupExecution(), and Isis::ProcessMosaic::StartProcess().

◆ removeExtension()

FileName Isis::FileName::removeExtension ( ) const

Removes all extensions in the file name.

Returns
FileName object with all extensions removed

References attributes(), baseName(), FileName(), and originalPath().

Referenced by setExtension(), and Isis::ProcessMosaic::StartProcess().

◆ setExtension()

FileName Isis::FileName::setExtension ( const QString & newExtension) const

Sets all current file extensions to a new extension in the file name.

Parameters
newExtensionThe new file extension to replace any current file extensions with
Returns
FileName object with all existing extensions replaced by the new extension

References addExtension(), extension(), and removeExtension().

Referenced by Isis::Image::copyToNewProjectRoot(), Isis::Shape::copyToNewProjectRoot(), Isis::Image::deleteFromDisk(), and Isis::Shape::deleteFromDisk().

◆ toString()

QString Isis::FileName::toString ( ) const

Returns a QString of the full file name including the file path, excluding the attributes with any Isis Preferences or environment variables indicated by $, changed to what they represent.

Returns
QString
  for a full file specification of:
   QString(ISISROOT) + "/tmp/Peaks.cub+Bsq"
  toString() gives:
   "/usgs/pkgs/isis3/isis/tmp/Peaks.cub"
  for a full file specification of:
   "$ISISROOT/tmp/Peaks.cub+Bsq"
  toString() gives:
   "/usgs/pkgs/isis3/isis/tmp/Peaks.cub"
Returns
QString

References expanded().

Referenced by Isis::Control::copyToNewProjectRoot(), Isis::Image::copyToNewProjectRoot(), Isis::Shape::copyToNewProjectRoot(), Isis::ProcessImportFits::extraFitsLabel(), Isis::ProcessImportFits::fitsImageLabel(), Isis::BundleSolutionInfo::save(), Isis::ControlList::save(), Isis::ImageList::save(), Isis::ShapeList::save(), and Isis::TemplateList::save().


The documentation for this class was generated from the following files: