Base::FileInfo Class Reference

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>

List of all members.

Public Member Functions

bool copyTo (const char *NewName) const
 Rename the file.
bool deleteFile (void) const
 Delete the file.
 FileInfo (const std::string &_FileName)
 FileInfo (const char *_FileName="")
 Constrction.
bool renameFile (const char *NewName)
 Rename the file.
void setFile (const std::string &name)
 Set a new file name.
void setFile (const char *name)
 Set a new file name.
Directory management



bool createDirectory (void) const
 Creates a directory. Returns TRUE if successful; otherwise returns FALSE.
bool deleteDirectory (void) const
 Delete an empty directory.
bool deleteDirectoryRecursive (void) const
 Delete a directory and all its content.
std::vector< Base::FileInfogetDirectoryContent (void) const
 Get a list of the directory content.
extraction of information



std::string dirPath () const
 Returns the dir path name (which may be absolute or relative).
std::string extension (bool complete=false) const
 Returns the file's extension name.
std::string fileName () const
 Returns the name of the file, excluding the path, including the extension.
std::string fileNamePure () const
 Returns the name of the file, excluding the path and the extension.
std::string filePath () const
 Returns the file name, including the path (which may be absolute or relative).
bool hasExtension (const char *Ext) const
 Checks for a special extension, NOT case sensetive.
std::wstring toStdWString () const
 Convert the path name into a UCS-2 encoded wide string format.
methods to test the status of the file or dir



bool exists () const
 Does the file exist?
bool isDir () const
 Checks if it is a directory (not a file).
bool isFile () const
 Checks if it is a file (not a direrctory).
bool isReadable () const
 Checks if the file exist and is readable.
bool isWritable () const
 Checks if the file exist and is writable.
TimeInfo lastModified () const
 Returns the time when the file was last modified.
TimeInfo lastRead () const
 Returns the time when the file was last read (accessed).
unsigned int size () const
 The size of the file.

Static Public Member Functions

Tools



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.
static const std::string & getTempPath (void)
 Get the path to the dir which is considered to temp files.

Protected Attributes

std::string FileName

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.

Definition at line 42 of file FileInfo.h.


Constructor & Destructor Documentation

FileInfo::FileInfo ( const char *  _FileName = ""  ) 

Constrction.

Definition at line 91 of file FileInfo.cpp.

References setFile().

Referenced by getDirectoryContent().

FileInfo::FileInfo ( const std::string &  _FileName  ) 

Definition at line 96 of file FileInfo.cpp.

References setFile().


Member Function Documentation

bool FileInfo::copyTo ( const char *  NewName  )  const

Rename the file.

Definition at line 432 of file FileInfo.cpp.

References draftlibs::dxfLibrary::copy, DrawingExample::file, FileName, and toStdWString().

Referenced by App::PropertyFileIncluded::setValue().

bool FileInfo::createDirectory ( void   )  const

Creates a directory. Returns TRUE if successful; otherwise returns FALSE.

Definition at line 450 of file FileInfo.cpp.

References FileName, and toStdWString().

Referenced by App::Document::Document().

bool FileInfo::deleteDirectory ( void   )  const

Delete an empty directory.

Definition at line 462 of file FileInfo.cpp.

References FileName, isDir(), and toStdWString().

Referenced by deleteDirectoryRecursive().

bool FileInfo::deleteDirectoryRecursive ( void   )  const

Delete a directory and all its content.

Definition at line 475 of file FileInfo.cpp.

References deleteDirectory(), getDirectoryContent(), and isDir().

bool FileInfo::deleteFile ( void   )  const
std::string FileInfo::dirPath (  )  const

Returns the dir path name (which may be absolute or relative).

Definition at line 215 of file FileInfo.cpp.

References FileName.

Referenced by App::PropertyFileIncluded::Copy(), App::PropertyFileIncluded::Paste(), MeshCore::MeshOutput::SaveAny(), and App::PropertyFileIncluded::setValue().

bool FileInfo::exists (  )  const
std::string FileInfo::extension ( bool  complete = false  )  const

Returns the file's extension name.

If complete is TRUE (the default), extension() returns the string of all characters in the file name after (but not including) the first '.' character. If complete is FALSE, extension() returns the string of all characters in the file name after (but not including) the last '.' character. Example:

  FileInfo fi( "/tmp/archive.tar.gz" );
  std::string ext = fi.extension(true);  // ext = "tar.gz"
  ext = fi.extension(false);   // ext = "gz"
  ext = fi.extension();   // ext = "gz"
     *

Definition at line 247 of file FileInfo.cpp.

References FileName, and RobotExample::pos.

Referenced by Gui::Application::exportTo(), Base::Writer::getUniqueFileName(), hasExtension(), Gui::Application::importFrom(), insert(), Points::PointsAlgos::Load(), Gui::Application::open(), open(), App::PropertyFileIncluded::setValue(), and Gui::SoFCOffscreenRenderer::writeToImageFile().

std::string FileInfo::fileName (  )  const

Returns the name of the file, excluding the path, including the extension.

Definition at line 210 of file FileInfo.cpp.

References FileName.

Referenced by App::PropertyFileIncluded::Copy(), Base::FileException::FileException(), fileNamePure(), and App::PropertyFileIncluded::setValue().

std::string FileInfo::fileNamePure (  )  const
std::string FileInfo::filePath (  )  const
std::vector< Base::FileInfo > FileInfo::getDirectoryContent ( void   )  const

Get a list of the directory content.

Definition at line 491 of file FileInfo.cpp.

References FileInfo(), FileName, and toStdWString().

Referenced by deleteDirectoryRecursive().

std::string FileInfo::getTempFileName ( const char *  FileName = 0,
const char *  path = 0 
) [static]
const std::string & FileInfo::getTempPath ( void   )  [static]

Get the path to the dir which is considered to temp files.

Definition at line 101 of file FileInfo.cpp.

References isDir().

Referenced by App::Document::Document(), getTempFileName(), and App::Document::Restore().

bool FileInfo::hasExtension ( const char *  Ext  )  const
bool FileInfo::isDir (  )  const

Checks if it is a directory (not a file).

Definition at line 321 of file FileInfo.cpp.

References exists(), FileName, and toStdWString().

Referenced by deleteDirectory(), deleteDirectoryRecursive(), and getTempPath().

bool FileInfo::isFile (  )  const

Checks if it is a file (not a direrctory).

Definition at line 296 of file FileInfo.cpp.

References exists(), FileName, and toStdWString().

Referenced by MeshCore::MeshInput::LoadAny().

bool FileInfo::isReadable (  )  const
bool FileInfo::isWritable (  )  const

Checks if the file exist and is writable.

Definition at line 286 of file FileInfo.cpp.

References FileName, and toStdWString().

Referenced by MeshCore::MeshOutput::SaveAny().

TimeInfo FileInfo::lastModified (  )  const

Returns the time when the file was last modified.

Definition at line 357 of file FileInfo.cpp.

References exists(), FileName, Base::TimeInfo::null(), Base::TimeInfo::setTime_t(), and toStdWString().

Referenced by App::Document::save().

TimeInfo FileInfo::lastRead (  )  const

Returns the time when the file was last read (accessed).

Definition at line 380 of file FileInfo.cpp.

References exists(), FileName, Base::TimeInfo::null(), Base::TimeInfo::setTime_t(), and toStdWString().

bool FileInfo::renameFile ( const char *  NewName  ) 
void Base::FileInfo::setFile ( const std::string &  name  )  [inline]

Set a new file name.

Definition at line 51 of file FileInfo.h.

References setFile().

Referenced by setFile().

void FileInfo::setFile ( const char *  name  ) 

Set a new file name.

Definition at line 185 of file FileInfo.cpp.

References FileName, and result.

Referenced by FileInfo(), Base::Writer::getUniqueFileName(), renameFile(), and App::PropertyFileIncluded::setValue().

unsigned int FileInfo::size (  )  const

The size of the file.

Definition at line 350 of file FileInfo.cpp.

std::wstring FileInfo::toStdWString (  )  const

Member Data Documentation

std::string Base::FileInfo::FileName [protected]

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

Generated on Wed Nov 23 19:01:46 2011 for FreeCAD by  doxygen 1.6.1