![]() |
Bsoft 2.1.4
Bernard's software package
|
Library functions for file checking. More...
#include "file_util.h"
#include "string_util.h"
#include "utilities.h"
#include <fstream>
#include <dirent.h>
Functions | |
Bstring | test_access (Bstring filename) |
string | test_access (string filename) |
Bstring | find_file (Bstring filename, Bstring path, int flag) |
Searches for a file within or without the given path. More... | |
string | find_file (string filename, string path, int flag) |
vector< string > | file_list (string path) |
Returns a list of files in the requested directory. More... | |
vector< string > | file_list (string path, string ext) |
Returns a list of files in the requested directory. More... | |
FileType | file_type (const char *filename) |
Checks the file type using the extension and contents. More... | |
FileType | file_type (Bstring &filename) |
int | fread_large (unsigned char *aptr, size_t pagesize, size_t offset, ifstream *fimg) |
Reads blocks of memeory no larger than 1Gb. More... | |
int | fread_large (unsigned char *aptr, size_t pagesize, size_t offset, ifstream &fimg) |
int | detect_and_fix_carriage_return (const char *filename) |
Detects carriage returns in text files and converts them to new-lines. More... | |
Variables | |
int | verbose |
Library functions for file checking.
int detect_and_fix_carriage_return | ( | const char * | filename | ) |
Detects carriage returns in text files and converts them to new-lines.
*filename | file name. |
The first line is read and if any carriage returns are found, the whole file is scanned and carriage returns converted to new-lines.
vector< string > file_list | ( | string | path | ) |
Returns a list of files in the requested directory.
&path | directory path. |
vector< string > file_list | ( | string | path, |
string | ext | ||
) |
Returns a list of files in the requested directory.
&path | directory path. |
&ext | file name extension. |
FileType file_type | ( | const char * | filename | ) |
Checks the file type using the extension and contents.
*filename | file name. |
The file extension is the main determinant of the file type. File formats with multiple types (such as the STAR and PDB formats) are distinguished based on content.
Searches for a file within or without the given path.
filename | file name to search for. |
path | path to search in. |
flag | if not found: bit 4 = warn; bit 5 = delete file name. |
The input filename is first tested for access. If not found, the filename without its original path is tested. If not found, the filename with the given path is tested. If not found, an error is reported and the original filename returned unless the delete flag is set.
string find_file | ( | string | filename, |
string | path, | ||
int | flag | ||
) |
int fread_large | ( | unsigned char * | aptr, |
size_t | pagesize, | ||
size_t | offset, | ||
ifstream & | fimg | ||
) |
int fread_large | ( | unsigned char * | aptr, |
size_t | pagesize, | ||
size_t | offset, | ||
ifstream * | fimg | ||
) |
Reads blocks of memeory no larger than 1Gb.
*aptr | pointer to pre-allocated memory. |
pagesize | size of pre-allocated memory. |
offset | offset in file. |
*fimg | file pointer. |
Each block is packed in sequence into the pre-allocated memory provided.
string test_access | ( | string | filename | ) |
|
extern |