Skip to content

Commit

Permalink
Removed a redundant method, and corrected some things.
Browse files Browse the repository at this point in the history
isAscii() was originally included as I copied LoadAscii v1 originally, and as it's not actually used internally i've removed it form v2. v1's isAscii is only used once (and by another class), and LoadAscii (the v1 class) is specifically used then, so it's safe to remove it from v2. In theory, that call to v1 should probably be using a file descriptor instead.

The spacers 2d array now has it's bounds corrected for both the new item, and reducing the second dimension as much wasn't used.

The Filename property has had an error in it's description corrected.

Refs #7732
  • Loading branch information
keithnbrown committed Oct 22, 2013
1 parent 2c48d3a commit 3bfa2fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
Expand Up @@ -60,8 +60,6 @@ namespace Mantid
/// Returns a confidence value that this algorithm can load a file
virtual int confidence(Kernel::FileDescriptor & descriptor) const;

static bool isAscii(FILE *file);

protected:
/// Read the data from the file
virtual API::Workspace_sptr readData(std::ifstream & file);
Expand Down
30 changes: 2 additions & 28 deletions Code/Mantid/Framework/DataHandling/src/LoadAscii2.cpp
Expand Up @@ -88,32 +88,6 @@ namespace Mantid
return confidence;
}

/**
* Check if a file is a text file
* @param file :: The file pointer
* @returns true if the file an ascii text file, false otherwise
*/
bool LoadAscii2::isAscii(FILE *file)
{
char data[256];
char *pend = &data[fread(data, 1, sizeof(data), file)];
fseek(file,0,SEEK_SET);
/*
* Call it a binary file if we find a non-ascii character in the
* first 256 bytes of the file.
*/
for( char *p = data; p < pend; ++p )
{
unsigned long ch = (unsigned long)*p;
if( !(ch <= 0x7F) )
{
return false;
}

}
return true;
}

//--------------------------------------------------------------------------
// Protected methods
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -481,11 +455,11 @@ namespace Mantid
exts.push_back("");

declareProperty(new FileProperty("Filename", "", FileProperty::Load, exts),
"The name of the text file to read, including its full or relative path. The file extension must be .tst, .dat, or .csv");
"The name of the text file to read, including its full or relative path. The file extension must be .txt, .dat, or .csv");
declareProperty(new WorkspaceProperty<Workspace>("OutputWorkspace",
"",Direction::Output), "The name of the workspace that will be created, filled with the read-in data and stored in the [[Analysis Data Service]].");

std::string spacers[6][6] = { {"Automatic", ",\t:; "}, {"CSV", ","},
std::string spacers[7][2] = { {"Automatic", ",\t:; "}, {"CSV", ","},
{"Tab", "\t"}, {"Space", " "}, {"Colon", ":"}, {"SemiColon", ";"}, {"UserDefined", "UserDefined"} };
// For the ListValidator
std::vector<std::string> sepOptions;
Expand Down

0 comments on commit 3bfa2fd

Please sign in to comment.