Isis Developer Reference
|
File name manipulation and expansion. More...
#include <FileName.h>
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. | |
FileName & | operator= (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. | |
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
For example:
Isis::FileName::FileName | ( | ) |
Constructs an empty FileName object.
Referenced by addExtension(), createTempFile(), isDateVersioned(), isNumericallyVersioned(), and removeExtension().
Isis::FileName::FileName | ( | const char * | file | ) |
Constructs a FileName object using a char pointer as a file name.
file | char pointer representing new filename |
Isis::FileName::FileName | ( | const QString & | file | ) |
Constructs a FileName object using a QString as a file name.
file | Qstring representing new filename |
Isis::FileName::FileName | ( | const FileName & | other | ) |
Isis::FileName::~FileName | ( | ) |
Destroys the FileName object.
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.
newExtension | The new file extension to be added at the end of the file name after all exisiting extensions. |
References attributes(), extension(), FileName(), name(), and originalPath().
Referenced by setExtension().
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"
Referenced by addExtension(), removeExtension(), and Isis::CubeAttribute< ChildClass >::setAttributes().
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"
Referenced by Isis::PipelineApplication::BuildParamString(), createTempFile(), Isis::Pipeline::FinalOutput(), Isis::ProcessExportPds4::identificationArea(), and removeExtension().
Creates a temporary file and returns a FileName object created using the temporary file.
templateFileName | the file name used to create the temporary file. |
Isis::IException::Io |
References _FILEINFO_, baseName(), extension(), FileName(), Isis::IException::Io, original(), originalPath(), and path().
QDir Isis::FileName::dir | ( | ) | const |
Returns the path of the file's parent directory as a QDir object.
for a full file specification of: "/tmp/Peaks.cub+Bsq" dir() gives: "/tmp/"
References expanded().
Referenced by Isis::Project::addControl(), Isis::Control::copyToNewProjectRoot(), Isis::ControlList::save(), Isis::ImageList::save(), Isis::ShapeList::save(), Isis::TemplateList::save(), Isis::Control::updateFileName(), Isis::Image::updateFileName(), Isis::Shape::updateFileName(), Isis::UserInterface::UserInterface(), and Isis::UserInterface::UserInterface().
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.
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"
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().
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"
Referenced by addExtension(), createTempFile(), setExtension(), Isis::ImportImagesWorkOrder::setupExecution(), and Isis::ImportShapesWorkOrder::setupExecution().
bool Isis::FileName::fileExists | ( | ) | const |
Returns true if the file exists; false otherwise.
If the file is a symlink that points to a nonexistent file, false is returned.
References expanded().
Referenced by Isis::Application::Application(), Isis::InterestOperatorFactory::Create(), Isis::AutoRegFactory::Create(), Isis::PhotoModelFactory::Create(), Isis::PolygonSeederFactory::Create(), Isis::AtmosModelFactory::Create(), Isis::NormModelFactory::Create(), Isis::NormModelFactory::Create(), Isis::Process::MissionData(), and newVersion().
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.
References _FILEINFO_, isDateVersioned(), isNumericallyVersioned(), isVersioned(), name(), originalPath(), and Isis::IException::Unknown.
Referenced by Isis::Process::MissionData().
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.
References expanded(), and FileName().
Referenced by highestVersion(), isVersioned(), and newVersion().
bool Isis::FileName::isNumericallyVersioned | ( | ) | const |
Checks if the file name is versioned numerically.
Returns true if the file is versioned numerically; returns false otherwise.
References expanded(), and FileName().
Referenced by highestVersion(), isVersioned(), and newVersion().
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.
References isDateVersioned(), and isNumericallyVersioned().
Referenced by highestVersion(), and newVersion().
QString Isis::FileName::name | ( | ) | const |
Returns the name of the file excluding the path and the attributes in the file name.
for a full file specification of: "/tmp/Peaks.cub+Bsq" name() gives: "Peaks.cub"
Referenced by addExtension(), Isis::Directory::addTemplateEditorView(), Isis::ControlPointEditWidget::addTemplates(), Isis::Application::Application(), Isis::ObservationNumber::Compose(), Isis::SerialNumber::Compose(), Isis::Control::copyToNewProjectRoot(), Isis::Image::copyToNewProjectRoot(), Isis::Shape::copyToNewProjectRoot(), Isis::QnetPointCubeNameFilter::createCubeList(), Isis::MatchTool::createPoint(), Isis::ImportMapTemplateWorkOrder::execute(), Isis::ImportRegistrationTemplateWorkOrder::execute(), Isis::ControlMeasure::GetChooserName(), Isis::ControlPoint::GetChooserName(), Isis::CorrelationMatrix::hasCovMat(), highestVersion(), Isis::CorrelationMatrix::isValid(), Isis::JigsawRunWidget::JigsawRunWidget(), newVersion(), Isis::OverlapStatistics::OverlapStatistics(), Isis::QnetNavTool::resetList(), Isis::BundleSolutionInfo::save(), Isis::TemplateList::save(), Isis::JigsawSetupDialog::selectControl(), Isis::Pipeline::SetInputListFile(), Isis::ExportControlNetWorkOrder::setupExecution(), Isis::ProcessMapMosaic::StartProcess(), Isis::OverlapStatistics::toPvl(), Isis::Control::updateFileName(), Isis::Image::updateFileName(), Isis::Shape::updateFileName(), and Isis::Template::updateFileName().
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.
Isis::IException::Unknown |
References _FILEINFO_, fileExists(), isDateVersioned(), isNumericallyVersioned(), isVersioned(), name(), originalPath(), and Isis::IException::Unknown.
bool Isis::FileName::operator!= | ( | const FileName & | rhs | ) |
bool Isis::FileName::operator== | ( | const FileName & | rhs | ) |
Compares equality of two FileName objects.
Returns true if the two objects are equal and false otherwise.
References expanded().
QString Isis::FileName::original | ( | ) | const |
Returns the full file name including the file 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"
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().
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"
Referenced by Isis::Directory::addBundleObservationView(), addExtension(), createTempFile(), highestVersion(), newVersion(), and removeExtension().
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"
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().
FileName Isis::FileName::removeExtension | ( | ) | const |
Removes all extensions in the file name.
References attributes(), baseName(), FileName(), and originalPath().
Referenced by setExtension(), and Isis::ProcessMosaic::StartProcess().
FileName Isis::FileName::setExtension | ( | const QString & | newExtension | ) | const |
Sets all current file extensions to a new extension in the file name.
newExtension | The new file extension to replace any current file extensions with |
References addExtension(), extension(), and removeExtension().
Referenced by Isis::Image::copyToNewProjectRoot(), Isis::Shape::copyToNewProjectRoot(), Isis::Image::deleteFromDisk(), and Isis::Shape::deleteFromDisk().
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.
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"
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().