OPeNDAPFile.cc

Go to the documentation of this file.
00001 // OPeNDAPFile.cc
00002 
00003 #include "OPeNDAPFile.h"
00004 
00005 OPeNDAPFile::OPeNDAPFile(const string &fullPath)
00006         : _dirName(""),
00007         _fileName(""),
00008         _baseName(""),
00009         _extension("")
00010 {
00011     breakApart(fullPath) ;
00012 }
00013 
00014 OPeNDAPFile::OPeNDAPFile(const string &dirName, const string &fileName)
00015         : _dirName(dirName),
00016         _fileName(fileName),
00017         _baseName(""),
00018         _extension("")
00019 {
00020     breakExtension() ;
00021 }
00022 
00023 OPeNDAPFile::OPeNDAPFile(const OPeNDAPFile &copyFrom)
00024         : _dirName(copyFrom._dirName),
00025         _fileName(copyFrom._fileName),
00026         _baseName(copyFrom._baseName),
00027         _extension(copyFrom._extension)
00028 {}
00029 
00030 OPeNDAPFile::~OPeNDAPFile()
00031 {}
00032 
00033 string
00034 OPeNDAPFile::getDirName()
00035 {
00036     return _dirName ;
00037 }
00038 
00039 string
00040 OPeNDAPFile::getFileName()
00041 {
00042     return _fileName ;
00043 }
00044 
00045 string
00046 OPeNDAPFile::getBaseName()
00047 {
00048     return _baseName ;
00049 }
00050 
00051 string
00052 OPeNDAPFile::getExtension()
00053 {
00054     return _extension ;
00055 }
00056 
00057 string
00058 OPeNDAPFile::getFullPath()
00059 {
00060     return _dirName + "/" + _fileName ;
00061 }
00062 
00063 void
00064 OPeNDAPFile::breakApart(const string &fullPath)
00065 {
00066     string::size_type pos = fullPath.rfind("/") ;
00067     if (pos != string::npos) {
00068         _dirName = fullPath.substr(0, pos) ;
00069         _fileName = fullPath.substr(pos + 1, fullPath.length() - pos) ;
00070     }
00071     else {
00072         _dirName = "./" ;
00073         _fileName = fullPath ;
00074     }
00075 
00076     breakExtension() ;
00077 }
00078 
00079 void
00080 OPeNDAPFile::breakExtension()
00081 {
00082     string::size_type pos = _fileName.rfind(".") ;
00083     if (pos != string::npos) {
00084         _baseName = _fileName.substr(0, pos) ;
00085         _extension = _fileName.substr(pos + 1, _fileName.length() - pos) ;
00086     }
00087     else {
00088         _baseName = _fileName ;
00089     }
00090 }
00091 

Generated on Wed Jun 27 12:56:39 2007 for libdap++ by  doxygen 1.4.7