|
Isis 3.0 Object Programmers' Reference |
Home |
#include <Filename.h>
Inheritance diagram for Isis::Filename:


This class is used for manipulating filenames. It allows access to the path, extension, base name and attributes. A standard Isis filename takes the form of
/path/base.extension:attribute
/work1/mars.cub:5
For internal use only.
Definition at line 90 of file Filename.h.
Public Member Functions | |
| Filename () | |
| Constructs an empty Filename object. | |
| Filename (const std::string &filename) | |
| Constructs a Filename object and expands environment variables and Preferences from the DataDirectory group embedded in the filename. | |
| Filename (const std::string &Name, const std::string &extension) | |
| Creates a temporary filename from the arguments. | |
| ~Filename () | |
| Destroys the Filename object. | |
| void | operator= (const std::string &filename) |
| Clears the current contents of the Filename object and reinitializes it with the argument. | |
| void | operator= (const char *filename) |
| Clears the current contents of the Filename object and reinitializes it with the argument. | |
| std::string | Path () const |
| Returns the path Returns the path portion of a filename. | |
| std::string | Basename () const |
| Returns the basename Returns the file name only. | |
| std::string | Name () const |
| Returns the filename. | |
| std::string | Extension () const |
| Returns the extension (Does not include . | |
| std::string | Expanded () const |
| Returns the full filename (path, basename and extension(s)) Returns a fully expanded version of the file name. | |
| std::string | OriginalPath () const |
| Returns the path used to initialize the Filename object, if any. | |
| void | AddExtension (const std::string &extension) |
| Adds an extension to the filename. | |
| void | RemoveExtension () |
| Removes all extensions from the file name. | |
| void | HighestVersion () |
| Searches for a filename with the highest integer version number. | |
| void | NewVersion () |
| Creates a filename with a version number one higher than the previous highest integer version number. | |
| bool | Exists () |
| Returns whether the file exists or not. | |
| void | MakeDirectory () |
| Makes a directory. | |
| void | Temporary (const std::string &name, const std::string &extension) |
| Create a temporary file. | |
Private Member Functions | |
| std::string | Expand (const std::string &file) |
| Expand any $xxxxx into Isis preference and environment variables. | |
| void | CheckVersion () const |
| Check the current filename for a valid version sequence of "?"s. | |
Private Attributes | |
| std::string | p_original |
| The original filename saved at construction. | |
| Isis::Filename::Filename | ( | ) |
Constructs an empty Filename object.
Definition at line 36 of file Filename.cpp.
References p_original.
| Isis::Filename::Filename | ( | const std::string & | file | ) |
Constructs a Filename object and expands environment variables and Preferences from the DataDirectory group embedded in the filename.
| file | A string containing a filename. |
Definition at line 46 of file Filename.cpp.
References Expand(), and p_original.
| Isis::Filename::Filename | ( | const std::string & | name, | |
| const std::string & | extension | |||
| ) |
Creates a temporary filename from the arguments.
The new filename is checked to make sure it doesn't exist, but race conditions could still occur between the time the file is checked for existance and the application attempts to create the file.
| name | Name of the temporary file. | |
| extension | Extension of the temporary file. |
Definition at line 62 of file Filename.cpp.
References Temporary().
| Isis::Filename::~Filename | ( | ) |
| void Isis::Filename::AddExtension | ( | const std::string & | ext | ) |
Adds an extension to the filename.
If the existing extension is the same nothing is added. If it is different then the existing extensions is added to the basename. For example, base="temp", ext="cub" and invoking AddExtension("jpg") gives base="temp.cub" and ext="jpg". If the existing extension is null then it is replaced.
| ext | Extention to add. |
Definition at line 182 of file Filename.cpp.
References Expanded(), and Extension().
Referenced by Isis::Cube::Create(), Isis::TextFile::Open(), Isis::Cube::Open(), and Isis::Cube::Write().
| std::string Isis::Filename::Basename | ( | ) | const |
Returns the basename Returns the file name only.
This excludes any path and the last extension. For *nix operating systems this includes everything following the last slash "/" and upto the last dot ".". If a file name contains multiple extensions, all but the last one will be returned. If a file name has no extension, Basename returns the same as Name
Definition at line 116 of file Filename.cpp.
Referenced by Isis::ProcessPolygons::AppendOutputCube(), Qisis::MosaicItem::MosaicItem(), RemoveExtension(), Isis::ProcessPolygons::SetOutputCube(), and Isis::ProcessGroundPolygons::SetOutputCube().
| void Isis::Filename::CheckVersion | ( | ) | const [private] |
Check the current filename for a valid version sequence of "?"s.
| Isis::iException::Programmer | - File does not contain a version | |
| Isis::iException::Programmer | - File has too many version sequences, only one is allowed |
Definition at line 472 of file Filename.cpp.
References _FILEINFO_, Expanded(), Isis::iException::Message(), and pos.
Referenced by HighestVersion(), and NewVersion().
| bool Isis::Filename::Exists | ( | ) |
Returns whether the file exists or not.
Definition at line 160 of file Filename.cpp.
Referenced by Isis::DatabaseFactory::addAccessProfile(), Isis::Application::Application(), Isis::CameraFactory::CameraVersion(), Isis::NormModelFactory::Create(), Isis::UserInterface::LoadHistory(), KernelDb::LoadSystemDb(), Isis::Process::MissionData(), Isis::operator<<(), Isis::Preference::Preferences(), and Isis::UserInterface::SaveHistory().
| string Isis::Filename::Expand | ( | const std::string & | file | ) | [private] |
Expand any $xxxxx into Isis preference and environment variables.
Note: "DataDirectory" is the only group search in Preferences.
| file | The file to be expanded. |
Definition at line 410 of file Filename.cpp.
References Isis::PvlObject::FindGroup(), Isis::PvlContainer::HasKeyword(), pos, Isis::Preference::Preferences(), and value.
Referenced by Filename(), and operator=().
| std::string Isis::Filename::Expanded | ( | ) | const |
Returns the full filename (path, basename and extension(s)) Returns a fully expanded version of the file name.
This will include the expansion of any Isis Preference variables, environment variables and operating system shortcuts such as ".", "..", or "~"
Definition at line 151 of file Filename.cpp.
Referenced by Qisis::HelpTool::aboutProgram(), Isis::Gui::AboutProgram(), AddExtension(), Isis::PvlTranslationTable::AddTable(), Isis::Pvl::Append(), Isis::Application::Application(), Isis::CameraFactory::CameraVersion(), CheckVersion(), Isis::Mgs::MocLabels::Compute(), Isis::Cube::Create(), Qisis::MosaicItem::createFootprint(), Qisis::MosaicItem::displayControlPoints(), Qisis::MosaicItem::drawImage(), Isis::GetEnviromentInfo(), KernelDb::GetFile(), Isis::GetLibraryDependencies(), Isis::GetUnameInfo(), HighestVersion(), Isis::Cassini::VimsSkyMap::Init(), Isis::Mgs::MocLabels::InitWago(), Isis::Spice::Load(), Isis::UserInterface::LoadHistory(), Isis::iTime::LoadLeapSecondKernel(), KernelDb::LoadSystemDb(), MakeDirectory(), Isis::Process::MissionData(), Isis::TextFile::Open(), Isis::Cube::Open(), Isis::operator<<(), Isis::ProcessImport::ProcessBil(), Isis::ProcessImport::ProcessBip(), Isis::ProcessImport::ProcessBsq(), Isis::ProcessImportPds::ProcessPdsImageLabel(), Isis::ProcessImportPds::ProcessPdsQubeLabel(), Isis::PvlTranslationTable::PvlTranslationTable(), Isis::Pvl::Read(), Isis::FileList::Read(), Qisis::TableMainWindow::readItemSettings(), Qisis::ViewportMainWindow::readSettings(), Qisis::TableMainWindow::readSettings(), Qisis::SpecialPixelTool::readSettings(), Qisis::PlotWindow::readSettings(), Qisis::PanTool::readSettings(), Qisis::PaletteWindow::readSettings(), Qisis::MosaicMainWindow::readSettings(), Qisis::MainWindow::readSettings(), Qisis::FileDialog::readSettings(), Qisis::BlinkTool::readSettings(), Isis::UserInterface::SaveHistory(), Isis::Pipeline::SetInputFile(), Isis::Pipeline::SetInputListFile(), Isis::Pipeline::SetOutputFile(), Isis::Pipeline::SetOutputListFile(), Isis::ProcessExportPds::StandardImageImage(), Isis::SystemDiskSpace(), Isis::Projection::TargetRadii(), Isis::ProcessImportPds::TranslateIsis2BandBin(), Isis::ProcessImportPds::TranslateIsis2Instrument(), Isis::ProcessImportPds::TranslatePdsArchive(), Isis::ProcessImportPds::TranslatePdsBandBin(), Isis::ProcessImportPds::TranslatePdsProjection(), Isis::Pvl::Write(), Isis::FileList::Write(), Isis::Cube::Write(), Qisis::ViewportMainWindow::writeSettings(), Qisis::TableMainWindow::writeSettings(), Qisis::SpecialPixelTool::writeSettings(), Qisis::PlotWindow::writeSettings(), Qisis::PanTool::writeSettings(), Qisis::PaletteWindow::writeSettings(), Qisis::MosaicMainWindow::writeSettings(), Qisis::MainWindow::writeSettings(), Qisis::FileDialog::writeSettings(), and Qisis::BlinkTool::writeSettings().
| std::string Isis::Filename::Extension | ( | ) | const |
Returns the extension (Does not include .
) Returns the extension of the filename. If multiple extensions exist, then only the last one will be returned.
Definition at line 140 of file Filename.cpp.
Referenced by AddExtension(), and Isis::ProcessPolygons::AppendOutputCube().
| void Isis::Filename::HighestVersion | ( | ) |
Searches for a filename with the highest integer version number.
Version numbers are defined as a sequence of question marks "?" in the filename. Only one sequence is allowed per filename. The already internalized filename is used as the directory to be searched, and it is used as the template for where the version number is located. The search is not recursive. The original name stored in the Filename object will be overwritten with the results of the search.
| Isis::iException::Io | - The path does not exist | |
| Isis::iException::Programmer | - No versions available for the file |
Definition at line 211 of file Filename.cpp.
References _FILEINFO_, CheckVersion(), Expanded(), Isis::iException::Message(), Name(), Path(), and Isis::version().
Referenced by KernelDb::GetFile(), Isis::iTime::LoadLeapSecondKernel(), KernelDb::LoadSystemDb(), Isis::Process::MissionData(), and Isis::Projection::TargetRadii().
| void Isis::Filename::MakeDirectory | ( | ) |
Makes a directory.
| Isis::iException::Programmer | - Unable to create the directory |
Definition at line 342 of file Filename.cpp.
References _FILEINFO_, Expanded(), and Isis::iException::Message().
Referenced by Isis::Preference::Preferences().
| std::string Isis::Filename::Name | ( | ) | const |
Returns the filename.
Returns the file name and all extensions of the filename. For *nix operating systems this includes everything following the last slash "/".
Definition at line 131 of file Filename.cpp.
Referenced by Isis::Application::Application(), Isis::Cube::Create(), KernelDb::GetFile(), HighestVersion(), Isis::UserInterface::LoadCommandLine(), Qisis::MosaicItem::MosaicItem(), NewVersion(), Isis::OverlapStatistics::OverlapStatistics(), Isis::Cube::ReformatOldIsisLabel(), Qisis::MeasureTool::updateDist(), Qisis::AdvancedTrackTool::updateRow(), and Isis::Cube::Write().
| void Isis::Filename::NewVersion | ( | ) |
Creates a filename with a version number one higher than the previous highest integer version number.
Version numbers are defined as a sequence of question marks "?" in the filename. Only one sequence is allowed per filename. The already internalized filename is used as the directory to be searched, and it is used as the template for where the version number is located. The search is not recursive. As is the case with HighestVersion, The original name stored in the Filename object will be overwritten with the results of the search. Thus, a user may operate on a Filename to change the sequence of question marks to the highest version, or the new version, but may not do both operations on the same Filename.
| Isis::iException::Io | - The path does not exist | |
| Isis::iException::Programmer | - No versions available for the file |
Definition at line 281 of file Filename.cpp.
References _FILEINFO_, CheckVersion(), Isis::iException::Message(), Name(), Path(), and Isis::version().
| void Isis::Filename::operator= | ( | const char * | file | ) |
Clears the current contents of the Filename object and reinitializes it with the argument.
| file | File name to replace the current contents of the object. |
Definition at line 86 of file Filename.cpp.
References Expand(), and p_original.
| void Isis::Filename::operator= | ( | const std::string & | file | ) |
Clears the current contents of the Filename object and reinitializes it with the argument.
| file | File name to replace the current contents of the object. |
Definition at line 75 of file Filename.cpp.
References Expand(), and p_original.
| std::string Isis::Filename::OriginalPath | ( | ) | const |
Returns the path used to initialize the Filename object, if any.
Definition at line 167 of file Filename.cpp.
References p_original.
Referenced by KernelDb::GetFile().
| std::string Isis::Filename::Path | ( | ) | const |
Returns the path Returns the path portion of a filename.
For *nix operating systems this includes everything upto but not including the last slash "/". For file names 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"
Definition at line 104 of file Filename.cpp.
Referenced by Isis::ProcessPolygons::AppendOutputCube(), HighestVersion(), NewVersion(), Isis::Cube::Open(), Isis::ProcessImportPds::ProcessPdsImageLabel(), Isis::ProcessImportPds::ProcessPdsQubeLabel(), Isis::ProcessPolygons::SetOutputCube(), Isis::ProcessGroundPolygons::SetOutputCube(), Qisis::MeasureTool::updateDist(), and Qisis::AdvancedTrackTool::updateRow().
| void Isis::Filename::RemoveExtension | ( | ) |
Removes all extensions from the file name.
Definition at line 195 of file Filename.cpp.
References Basename().
Referenced by Isis::Cube::Create(), Isis::Cube::Open(), and Isis::Cube::Write().
| void Isis::Filename::Temporary | ( | const std::string & | name, | |
| const std::string & | extension | |||
| ) |
Create a temporary file.
If the Preference "DataDirectory->Temporary" exists then the file will be created there. If not the file will be created using only what is specified in the current filename. The filename will consist of the current name with a number between 100000 and 999999 appended to the name portion.
| name | The name of the temporary file. | |
| extension | The extension of the temporary file. |
| Isis::iException::Io | - No temporary files available for the given name and extension |
Definition at line 367 of file Filename.cpp.
References _FILEINFO_, add, Isis::PvlObject::FindGroup(), Isis::PvlObject::HasGroup(), Isis::iException::Message(), p_original, and Isis::Preference::Preferences().
Referenced by Filename(), Isis::GetEnviromentInfo(), Isis::GetLibraryDependencies(), Isis::GetUnameInfo(), and Isis::SystemDiskSpace().
std::string Isis::Filename::p_original [private] |
The original filename saved at construction.
Definition at line 161 of file Filename.h.
Referenced by Filename(), operator=(), OriginalPath(), and Temporary().