File name unification This class handles everything related to file names the file names are internal generally UTF-8 encoded on all platforms. More...
#include <FileInfo.h>
Public Types | |
enum | Permissions { WriteOnly = 0x01, ReadOnly = 0x02, ReadWrite = 0x03 } |
Public Member Functions | |
FileInfo (const char *_FileName="") | |
Construction. More... | |
FileInfo (const std::string &_FileName) | |
void | setFile (const char *name) |
Set a new file name. More... | |
void | setFile (const std::string &name) |
Set a new file name. More... | |
extraction of information | |
std::string | filePath () const |
Returns the file name, including the path (which may be absolute or relative). More... | |
std::string | dirPath () const |
Returns the dir path name (which may be absolute or relative). More... | |
std::string | fileName () const |
Returns the name of the file, excluding the path, including the extension. More... | |
std::string | fileNamePure () const |
Returns the name of the file, excluding the path and the extension. More... | |
std::wstring | toStdWString () const |
Convert the path name into a UCS-2 encoded wide string format. More... | |
std::string | extension () const |
Returns the extension of the file. More... | |
std::string | completeExtension () const |
Returns the complete extension of the file. More... | |
bool | hasExtension (const char *Ext) const |
Checks for a special extension, NOT case sensetive. More... | |
methods to test the status of the file or dir | |
bool | exists () const |
Does the file exist? More... | |
bool | isReadable () const |
Checks if the file exist and is readable. More... | |
bool | isWritable () const |
Checks if the file exist and is writable. More... | |
bool | setPermissions (Permissions) |
Tries to set the file permission. More... | |
bool | isFile () const |
Checks if it is a file (not a directory) More... | |
bool | isDir () const |
Checks if it is a directory (not a file) More... | |
unsigned int | size () const |
The size of the file. More... | |
TimeInfo | lastModified () const |
Returns the time when the file was last modified. More... | |
TimeInfo | lastRead () const |
Returns the time when the file was last read (accessed). More... | |
Directory management | |
bool | createDirectory (void) const |
Creates a directory. Returns true if successful; otherwise returns false. More... | |
std::vector< Base::FileInfo > | getDirectoryContent (void) const |
Get a list of the directory content. More... | |
bool | deleteDirectory (void) const |
Delete an empty directory. More... | |
bool | deleteDirectoryRecursive (void) const |
Delete a directory and all its content. More... | |
bool | deleteFile (void) const |
Delete the file. More... | |
bool | renameFile (const char *NewName) |
Rename the file. More... | |
bool | copyTo (const char *NewName) const |
Rename the file. More... | |
Tools | |
std::string | FileName |
static std::string | getTempFileName (const char *FileName=0, const char *path=0) |
Get a unique File Name in the given or (if 0) in the temp path. More... | |
static const std::string & | getTempPath (void) |
Get the path to the dir which is considered to temp files. More... | |
Detailed Description
File name unification This class handles everything related to file names the file names are internal generally UTF-8 encoded on all platforms.
Member Enumeration Documentation
◆ Permissions
Constructor & Destructor Documentation
◆ FileInfo() [1/2]
FileInfo::FileInfo | ( | const char * | _FileName = "" | ) |
◆ FileInfo() [2/2]
FileInfo::FileInfo | ( | const std::string & | _FileName | ) |
References setFile().
Member Function Documentation
◆ completeExtension()
std::string FileInfo::completeExtension | ( | ) | const |
◆ copyTo()
bool FileInfo::copyTo | ( | const char * | NewName | ) | const |
Rename the file.
References FileName, and toStdWString().
Referenced by TechDraw::DrawUtil::copyFile(), and App::PropertyFileIncluded::Paste().
◆ createDirectory()
bool FileInfo::createDirectory | ( | void | ) | const |
Creates a directory. Returns true if successful; otherwise returns false.
References FileName, and toStdWString().
Referenced by App::VRMLObject::makeDirectories(), App::Document::onChanged(), Gui::AutoSaver::slotCreateDocument(), Gui::RecoveryWriter::writeFiles(), and Base::FileWriter::writeFiles().
◆ deleteDirectory()
bool FileInfo::deleteDirectory | ( | void | ) | const |
Delete an empty directory.
References FileName, isDir(), and toStdWString().
Referenced by deleteDirectoryRecursive().
◆ deleteDirectoryRecursive()
bool FileInfo::deleteDirectoryRecursive | ( | void | ) | const |
Delete a directory and all its content.
References deleteDirectory(), getDirectoryContent(), isDir(), and ReadWrite.
Referenced by App::Document::~Document().
◆ deleteFile()
bool FileInfo::deleteFile | ( | void | ) | const |
Delete the file.
References FileName, and toStdWString().
Referenced by StdCmdDuplicateSelection::activated(), Gui::MainWindow::closeEvent(), App::DocumentPy::getTempFileName(), App::Document::importLinks(), MeshPartGui::Mesh2ShapeGmsh::loadOutput(), MeshGui::RemeshGmsh::loadOutput(), App::PropertyFileIncluded::Paste(), Fem::FemMesh::RestoreDocFile(), Fem::PropertyPostDataObject::RestoreDocFile(), Part::PropertyPartShape::RestoreDocFile(), Gui::Application::runApplication(), Fem::FemMesh::SaveDocFile(), Fem::PropertyPostDataObject::SaveDocFile(), and Part::PropertyPartShape::SaveDocFile().
◆ dirPath()
std::string FileInfo::dirPath | ( | ) | const |
Returns the dir path name (which may be absolute or relative).
References FileName.
Referenced by Mesh::AmfExporter::AmfExporter(), Import::ImportOCAF2::ImportOCAF2(), Mesh::MeshObject::load(), App::VRMLObject::onChanged(), App::PropertyFileIncluded::Paste(), App::VRMLObject::RestoreDocFile(), Mesh::MeshObject::save(), Import::ImportOCAF2::setMode(), and App::PropertyFileIncluded::setValue().
◆ exists()
bool FileInfo::exists | ( | ) | const |
Does the file exist?
References FileName, and toStdWString().
Referenced by Gui::ViewProviderVRMLObject::addResource(), Mesh::AmfExporter::AmfExporter(), Gui::MainWindow::closeEvent(), App::PropertyFileIncluded::getUniqueFileName(), Part::ImportStepParts(), isDir(), isFile(), lastModified(), lastRead(), MeshCore::MeshInput::LoadAny(), Drawing::FeaturePage::onChanged(), App::Document::onChanged(), Raytracing::RayProject::onDocumentRestored(), Raytracing::LuxProject::onDocumentRestored(), Drawing::FeaturePage::onDocumentRestored(), App::Application::openDocumentPrivate(), App::PropertyFileIncluded::Paste(), Import::StepShape::read(), App::PropertyFileIncluded::RestoreDocFile(), App::PropertyFileIncluded::Save(), MeshCore::MeshOutput::SaveAny(), App::VRMLObject::SaveDocFile(), App::PropertyFileIncluded::setValue(), and Gui::Application::sLoadFile().
◆ extension()
std::string FileInfo::extension | ( | ) | const |
Returns the extension of the file.
The extension consists of all characters in the file after (but not including) the last '.' character.
References FileName.
Referenced by Gui::Application::exportTo(), Base::Writer::getUniqueFileName(), hasExtension(), Gui::Application::importFrom(), TechDraw::DrawViewSection::makeLineSets(), Gui::Application::open(), App::Application::processCmdLineFiles(), Fem::PropertyPostDataObject::RestoreDocFile(), App::PropertyFileIncluded::setValue(), and Gui::Application::sLoadFile().
◆ fileName()
std::string FileInfo::fileName | ( | ) | const |
Returns the name of the file, excluding the path, including the extension.
References FileName.
Referenced by Mesh::AmfExporter::AmfExporter(), TechDraw::DrawSVGTemplate::execute(), Drawing::FeaturePage::execute(), Base::FileException::FileException(), fileNamePure(), Drawing::FeaturePage::getEditableTextsFromTemplate(), TechDraw::DrawSVGTemplate::getEditableTextsFromTemplate(), Base::FileException::getFileName(), Base::FileException::getPyObject(), App::VRMLObject::getRelativePath(), Raytracing::RayProject::onDocumentRestored(), Raytracing::LuxProject::onDocumentRestored(), Drawing::FeaturePage::onDocumentRestored(), App::PropertyFileIncluded::Paste(), TechDrawGui::QGVPage::postProcessXml(), and App::PropertyFileIncluded::setValue().
◆ fileNamePure()
std::string FileInfo::fileNamePure | ( | ) | const |
Returns the name of the file, excluding the path and the extension.
References fileName().
Referenced by Base::Writer::getUniqueFileName(), Part::ImportIgesParts(), Part::ImportStepParts(), App::Application::openDocumentPrivate(), Fem::FemMesh::read(), Gui::Application::sAddCommand(), Mesh::MeshObject::save(), App::Document::saveAs(), App::PropertyFileIncluded::setValue(), and Fem::FemMesh::write().
◆ filePath()
std::string FileInfo::filePath | ( | ) | const |
Returns the file name, including the path (which may be absolute or relative).
References FileName.
Referenced by Mesh::AmfExporter::AmfExporter(), App::PropertyFileIncluded::Copy(), Gui::MainWindow::createMimeDataFromSelection(), TechDraw::DrawViewSymbolPy::dumpSymbol(), Raytracing::LuxProject::execute(), Raytracing::RayProject::execute(), TechDraw::DrawSVGTemplate::execute(), Drawing::FeaturePage::execute(), Gui::Application::exportTo(), WebGui::FcCookieJar::FcCookieJar(), Drawing::FeaturePage::getEditableTextsFromTemplate(), TechDraw::DrawSVGTemplate::getEditableTextsFromTemplate(), CDxfWrite::getPlateFile(), App::DocumentPy::getTempFileName(), App::PropertyFileIncluded::getUniqueFileName(), Gui::Application::importFrom(), App::Document::onChanged(), Raytracing::LuxProject::onDocumentRestored(), Raytracing::RayProject::onDocumentRestored(), Drawing::FeaturePage::onDocumentRestored(), Gui::Application::open(), App::Application::openDocumentPrivate(), Gui::SoSVGVectorOutput::openFile(), Gui::SoU3DVectorOutput::openFile(), App::PropertyFileIncluded::Paste(), Fem::FemPostPipeline::read(), Fem::FemMesh::read(), Part::TopoShape::read(), Fem::FemMesh::RestoreDocFile(), Fem::PropertyPostDataObject::RestoreDocFile(), Part::PropertyPartShape::RestoreDocFile(), Gui::Application::sAddCommand(), App::PropertyFileIncluded::Save(), Fem::FemMesh::SaveDocFile(), Fem::PropertyPostDataObject::SaveDocFile(), Part::PropertyPartShape::SaveDocFile(), App::PropertyFileIncluded::setValue(), Fem::FemMesh::write(), Part::TopoShape::write(), and MeshGui::RemeshGmsh::writeProject().
◆ getDirectoryContent()
std::vector< Base::FileInfo > FileInfo::getDirectoryContent | ( | void | ) | const |
Get a list of the directory content.
References FileInfo(), FileName, and toStdWString().
Referenced by deleteDirectoryRecursive().
◆ getTempFileName()
|
static |
Get a unique File Name in the given or (if 0) in the temp path.
References FileName, and getTempPath().
Referenced by App::PropertyFileIncluded::getExchangeTempFile(), App::DocumentPy::getTempFileName(), and App::Application::getTempFileName().
◆ getTempPath()
|
static |
Get the path to the dir which is considered to temp files.
References isDir().
Referenced by getTempFileName().
◆ hasExtension()
bool FileInfo::hasExtension | ( | const char * | Ext | ) | const |
Checks for a special extension, NOT case sensetive.
References extension().
Referenced by Fem::FemPostPipeline::canRead(), Gui::View3DInventorViewer::dumpToFile(), Gui::Application::importFrom(), Points::PointsAlgos::Load(), MeshCore::MeshInput::LoadAny(), Gui::Application::open(), Fem::FemPostPipeline::read(), Fem::FemMesh::read(), Part::TopoShape::read(), Part::PropertyPartShape::RestoreDocFile(), Gui::View3DInventorPy::saveVectorGraphic(), Fem::FemMesh::write(), Part::TopoShape::write(), and Gui::SoFCDB::writeToFile().
◆ isDir()
bool FileInfo::isDir | ( | ) | const |
Checks if it is a directory (not a file)
References exists(), FileName, and toStdWString().
Referenced by deleteDirectory(), deleteDirectoryRecursive(), and getTempPath().
◆ isFile()
bool FileInfo::isFile | ( | ) | const |
Checks if it is a file (not a directory)
References exists(), FileName, and toStdWString().
Referenced by MeshCore::MeshInput::LoadAny(), and Gui::Application::sLoadFile().
◆ isReadable()
bool FileInfo::isReadable | ( | ) | const |
Checks if the file exist and is readable.
References FileName, and toStdWString().
Referenced by TechDraw::DrawUtil::copyFile(), TechDraw::DrawParametricTemplate::execute(), Raytracing::LuxProject::execute(), Raytracing::RayProject::execute(), Part::CurveNet::execute(), Part::ImportBrep::execute(), Part::ImportIges::execute(), TechDraw::DrawSVGTemplate::execute(), Part::ImportStep::execute(), Drawing::FeaturePage::execute(), TechDraw::DrawGeomHatch::getDecodedSpecsFromFile(), Drawing::FeaturePage::getEditableTextsFromTemplate(), TechDraw::DrawSVGTemplate::getEditableTextsFromTemplate(), CDxfWrite::getPlateFile(), App::DocumentPy::load(), Points::PointsAlgos::Load(), MeshCore::MeshInput::LoadAny(), TechDraw::DrawViewSection::makeLineSets(), TechDraw::DrawViewSection::onChanged(), TechDraw::DrawTileWeld::onChanged(), TechDraw::DrawHatch::onDocumentRestored(), TechDraw::DrawTileWeld::onDocumentRestored(), TechDraw::DrawGeomHatch::onDocumentRestored(), TechDraw::DrawViewSection::onDocumentRestored(), Fem::FemPostPipeline::read(), Fem::FemMesh::read(), Part::TopoShape::read(), App::DocumentPy::restore(), and App::DocumentPy::save().
◆ isWritable()
bool FileInfo::isWritable | ( | ) | const |
Checks if the file exist and is writable.
References FileName, and toStdWString().
Referenced by Mesh::AmfExporter::AmfExporter(), App::PropertyFileIncluded::RestoreDocFile(), and MeshCore::MeshOutput::SaveAny().
◆ lastModified()
TimeInfo FileInfo::lastModified | ( | ) | const |
Returns the time when the file was last modified.
References exists(), FileName, Base::TimeInfo::null(), Base::TimeInfo::setTime_t(), and toStdWString().
◆ lastRead()
TimeInfo FileInfo::lastRead | ( | ) | const |
Returns the time when the file was last read (accessed).
References exists(), FileName, Base::TimeInfo::null(), Base::TimeInfo::setTime_t(), and toStdWString().
◆ renameFile()
bool FileInfo::renameFile | ( | const char * | NewName | ) |
Rename the file.
References FileName, and toStdWString().
Referenced by App::Document::onChanged(), and App::PropertyFileIncluded::Paste().
◆ setFile() [1/2]
void FileInfo::setFile | ( | const char * | name | ) |
Set a new file name.
References FileName.
Referenced by TechDraw::DrawSVGTemplate::execute(), Drawing::FeaturePage::execute(), FileInfo(), Drawing::FeaturePage::getEditableTextsFromTemplate(), TechDraw::DrawSVGTemplate::getEditableTextsFromTemplate(), App::PropertyFileIncluded::getUniqueFileName(), Base::Writer::getUniqueFileName(), Mesh::MeshObject::load(), Raytracing::LuxProject::onDocumentRestored(), Raytracing::RayProject::onDocumentRestored(), Drawing::FeaturePage::onDocumentRestored(), App::PropertyFileIncluded::Paste(), Mesh::MeshObject::save(), App::VRMLObject::SaveDocFile(), Base::FileException::setPyObject(), and App::PropertyFileIncluded::setValue().
◆ setFile() [2/2]
void Base::FileInfo::setFile | ( | const std::string & | name | ) |
Set a new file name.
◆ setPermissions()
bool FileInfo::setPermissions | ( | Permissions | perms | ) |
Tries to set the file permission.
References FileName, ReadOnly, toStdWString(), and WriteOnly.
Referenced by App::PropertyFileIncluded::Copy(), App::PropertyFileIncluded::Paste(), App::PropertyFileIncluded::Restore(), and App::PropertyFileIncluded::RestoreDocFile().
◆ size()
unsigned int FileInfo::size | ( | ) | const |
The size of the file.
Referenced by PathScripts.PostUtils.GCodeEditorDialog::done().
◆ toStdWString()
std::wstring FileInfo::toStdWString | ( | ) | const |
Convert the path name into a UCS-2 encoded wide string format.
References FileName.
Referenced by copyTo(), createDirectory(), deleteDirectory(), deleteFile(), exists(), getDirectoryContent(), isDir(), isFile(), isReadable(), isWritable(), lastModified(), lastRead(), Gui::SoSVGVectorOutput::openFile(), Gui::SoU3DVectorOutput::openFile(), renameFile(), Gui::PythonDebugger::runFile(), Base::InterpreterSingleton::runFile(), setPermissions(), zipios::ZipFile::ZipFile(), and zipios::ZipInputStream::ZipInputStream().
Member Data Documentation
◆ FileName
|
protected |
Referenced by completeExtension(), copyTo(), createDirectory(), deleteDirectory(), deleteFile(), dirPath(), exists(), extension(), fileName(), filePath(), getDirectoryContent(), getTempFileName(), isDir(), isFile(), isReadable(), isWritable(), lastModified(), lastRead(), renameFile(), setFile(), setPermissions(), and toStdWString().
The documentation for this class was generated from the following files:
- src/Base/FileInfo.h
- src/Base/FileInfo.cpp