1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
/************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see <http://www.gnu.org/licenses/>.
************************************************************************************/
#include <string>
#include "Definitions.h"
#include "File.h"
using namespace std;
namespace ColPack
{
File::File()
{
path = "";
name = "";
fileExtension = "";
}
File::File(string fileName)
{
path = "";
name = "";
fileExtension = "";
Parse(fileName);
}
string File::GetPath() const {return path;}
string File::GetName() const {return name;}
string File::GetFileExtension() const {return fileExtension;}
string File::GetFullName() const {return name+"."+fileExtension;}
void File::SetPath(string newPath) {path = newPath;}
void File::SetName(string newName) {name = newName;}
void File::SetFileExtension(string newFileExtension) {fileExtension = newFileExtension;}
void File::Parse(string fileName) {
string::size_type result;
//1. see if the fileName is given in full path
result = fileName.rfind(DIR_SEPARATOR, fileName.size() - 1);
if(result != string::npos) {//found the path (file prefix)
//get the path, including the last DIR_SEPARATOR
path = fileName.substr(0,result+1);
//remove the path from the fileName
fileName = fileName.substr(result+1);
}
//2. see if the fileName has file extension. For example ".mtx"
result = fileName.rfind('.', fileName.size() - 1);
if(result != string::npos) {//found the fileExtension
//get the fileExtension excluding the '.'
fileExtension = fileName.substr(result+1);
//remove the fileExtension from the fileName
fileName = fileName.substr(0,result);
}
//3. get the name of the input file
name = fileName;
}
bool isMatrixMarketFormat(string s_fileExtension) {
if (s_fileExtension == "mtx")
return true;
return false;
}
bool isHarwellBoeingFormat(string s_fileExtension){
if (s_fileExtension == "hb" || (
s_fileExtension.size()==3 && (
// First Character of the Extension
s_fileExtension[0] == 'r' || // Real matrix
s_fileExtension[0] == 'c' || // Complex matrix
s_fileExtension[0] == 'p' // Pattern only (no numerical values supplied)
) && (
// Second Character of the Extension
s_fileExtension[1] == 's' || // Symmetric
s_fileExtension[1] == 'u' || // Unsymmetric
s_fileExtension[1] == 'h' || // Hermitian
s_fileExtension[1] == 'g' || // Skew symmetric
s_fileExtension[1] == 'r' // Rectangular
) && (
// Third Character of the Extension
s_fileExtension[2] == 'a' || // Assembled
s_fileExtension[2] == 'e' // Elemental matrices (unassembled)
))
)
return true;
return false;
}
bool isMeTiSFormat(string s_fileExtension){
if (s_fileExtension == "graph")
return true;
return false;
}
}
|