Skip to content

Commit

Permalink
Replace AS_UTL_fileExists() with pathExists(), fileExists() and direc…
Browse files Browse the repository at this point in the history
…toryExists().
  • Loading branch information
brianwalenz committed Jul 23, 2018
1 parent 1dbf1a2 commit d539a54
Show file tree
Hide file tree
Showing 46 changed files with 131 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/bogart/AS_BAT_OverlapCache.C
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ OverlapCache::load(void) {
size_t numRead;

snprintf(name, FILENAME_MAX, "%s.ovlCache", _prefix);
if (AS_UTL_fileExists(name, false, false) == false)
if (fileExists(name) == false)
return(false);

writeStatus("OverlapCache()-- Loading graph from '%s'.\n", name);
Expand Down
2 changes: 1 addition & 1 deletion src/bogart/addReadsToUnitigs.C
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ main(int argc, char **argv) {
fprintf(stderr, "invalid tigStore version (-t store version) '-t %s %s'.\n", argv[arg-1], argv[arg]), exit(1);

} else if (strcmp(argv[arg], "-m") == 0) {
while ((argv[arg+1] != NULL) && (AS_UTL_fileExists(argv[arg+1], false, false) == true))
while ((argv[arg+1] != NULL) && (fileExists(argv[arg+1]) == true))
alignMapNames.push_back(argv[++arg]);

} else if (strcmp(argv[arg], "-lookup") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/erateEstimate/erateEstimate.C
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ main(int argc, char **argv) {
ESToverlap *overlaps = NULL;
memoryMappedFile *overlapsMMF = NULL;

if (AS_UTL_fileExists(ovlCacheName, false, false)) {
if (fileExists(ovlCacheName)) {
fprintf(stderr, " cache '%s' detected, load averted\n", ovlCacheName);

overlapsMMF = new memoryMappedFile(ovlCacheName);
Expand Down
2 changes: 1 addition & 1 deletion src/merTrim/merTrim.C
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public:
char cacheName[FILENAME_MAX];
snprintf(cacheName, FILENAME_MAX, "%s.merTrimDB", merCountsFile);

if (AS_UTL_fileExists(cacheName, false, false)) {
if (fileExists(cacheName)) {
fprintf(stderr, "loading genome mer database from cache '%s'.\n", cacheName);
genomicDB = new existDB(cacheName);

Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/libkmer/existDB.C
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ existDB::existDB(char const *filename,
// meryl database.


if (AS_UTL_fileExists(filename))
if (fileExists(filename))
createFromFastA(filename, merSize, flags);
else
createFromMeryl(filename, merSize, lo, hi, flags);
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/libleaff/fastaFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void
fastaFile::loadIndex(char *indexname) {
struct stat fastastat;

if (AS_UTL_fileExists(indexname) == false)
if (fileExists(indexname) == false)
return;

errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/libleaff/fastqFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void
fastqFile::loadIndex(char *indexname) {
struct stat fastqstat;

if (AS_UTL_fileExists(indexname) == false)
if (fileExists(indexname) == false)
return;

errno = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/meryl-san/libleaff/sqStoreFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ sqStoreFile::openFile(const char *name) {
sprintf(infoName, "%s/info", name);
sprintf(readName, "%s/reads", name);

if ((AS_UTL_fileExists(name, true) == false) ||
(AS_UTL_fileExists(infoName) == false) ||
(AS_UTL_fileExists(readName) == false))
if ((directoryExists(name) == false) ||
(fileExists(infoName) == false) ||
(fileExists(readName) == false))
return(0L);

// Yup, probably a sqStore. If it isn't, the sqStore() constructor blows up.
Expand Down
6 changes: 3 additions & 3 deletions src/meryl-san/libmeryl-san.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ merylStreamReader::merylStreamReader(const char *fn_, uint32 ms_) {
// bitPackedFile will create a file if it doesn't exist, so we need to fail ahead
// of time.

bool idxexist = AS_UTL_fileExists(idxname);
bool datexist = AS_UTL_fileExists(datname);
bool posexist = AS_UTL_fileExists(posname);
bool idxexist = fileExists(idxname);
bool datexist = fileExists(datname);
bool posexist = fileExists(posname);

if ((idxexist == false) ||
(datexist == false)) {
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/maskMers.C
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public:
strncpy(_maskMersName, _merylName, FILENAME_MAX-1);
strcat(_maskMersName, ".maskMers");

if (AS_UTL_fileExists(_maskMersName))
if (fileExists(_maskMersName))
loadMasking(onlySeqIID_);
else
buildMasking();
Expand Down
6 changes: 3 additions & 3 deletions src/meryl-san/meryl-build.C
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ runSegment(merylArgs *args, uint64 segment) {

snprintf(filename, FILENAME_MAX, "%s.batch" F_U64 ".mcdat", args->outputFile, segment);

if (AS_UTL_fileExists(filename)) {
if (fileExists(filename)) {
if (args->beVerbose)
fprintf(stderr, "Found result for batch " F_U64 " in %s.\n", segment, filename);
return;
Expand Down Expand Up @@ -690,10 +690,10 @@ build(merylArgs *args) {

sprintf(N, "%s.existenceTest", args->outputFile);

if (AS_UTL_fileExists(args->outputFile, true) == true)
if (directoryExists(args->outputFile) == true)
fprintf(stderr, "ERROR: output prefix -o cannot be a directory.\n"), exit(1);

if (AS_UTL_fileExists(N) == false) {
if (fileExists(N) == false) {
errno = 0;
FILE *F = fopen(N, "w");
if (errno)
Expand Down
4 changes: 2 additions & 2 deletions src/meryl-san/meryl-san.C
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ main(int argc, char **argv) {

else if (arg == outputArg) writer = new merylStreamWriter(opt, merSize, 0, merSize/2, false);

else if (AS_UTL_fileExists(mcidx) &&
AS_UTL_fileExists(mcdat)) reader = new merylStreamReader(opt);
else if (fileExists(mcidx) &&
fileExists(mcdat)) reader = new merylStreamReader(opt);

else {
char *s = new char [1024];
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/positionDB.C
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ main(int argc, char **argv) {

// Exit quickly if the output file exists.
//
if (AS_UTL_fileExists(outputFile)) {
if (fileExists(outputFile)) {
fprintf(stderr, "Output file '%s' exists already!\n", outputFile);
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/simple-dump.C
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ main(int argc, char **argv) {

// Load existence mers from the saved existDB, or create a new existDB and maybe save to disk.

if ((existFile) && (AS_UTL_fileExists(existFile))) {
if ((existFile) && (fileExists(existFile))) {
E = new existDB(existFile);
}

Expand Down
2 changes: 1 addition & 1 deletion src/meryl-san/utility/bitPackedFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bitPackedFile::bitPackedFile(char const *name, uint64 offset, bool forceTruncate
if (errno)
fprintf(stderr, "bitPackedFile::bitPackedFile()-- failed to open and truncate '%s': %s\n",
_name, strerror(errno)), exit(1);
} else if (AS_UTL_fileExists(_name)) {
} else if (fileExists(_name)) {
errno = 0;
_file = open(_name,
O_RDONLY | O_LARGEFILE,
Expand Down
6 changes: 3 additions & 3 deletions src/meryl/meryl.C
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ main(int argc, char **argv) {
writer = new kmerCountFileWriter(inoutName); // output writer.

else if ((arg == printArg) && // This this _should_ have been an output name,
(AS_UTL_fileExists(inoutName, true))) { // but is instead a directory; user is asking for
(directoryExists(inoutName))) { // but is instead a directory; user is asking for
printer = stdout; // the database in the directory to be printed.
reader = new kmerCountFileReader(inoutName);
}
Expand All @@ -263,12 +263,12 @@ main(int argc, char **argv) {

else if ((opStack.size() > 0) && // If a command exists,
(opStack.top()->isCounting() == false) && // and it isn't for counting,
(AS_UTL_fileExists(indexName) == true)) // and the meryl index file exists,
(fileExists(indexName) == true)) // and the meryl index file exists,
reader = new kmerCountFileReader(inoutName); // add a kmerCountFile as input to the current command.

else if ((opStack.size() > 0) && // If a command exists,
(opStack.top()->isCounting() == true) && // and it IS for counting,
(AS_UTL_fileExists(inoutName) == true)) // and the file exists,
(fileExists(inoutName) == true)) // and the file exists,
sequence = new dnaSeqFile(inoutName); // add a sequence file as input to the current command.

else {
Expand Down
2 changes: 1 addition & 1 deletion src/mhap/mhapConvert.C
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-S") == 0) {
seqName = argv[++arg];

} else if (AS_UTL_fileExists(argv[arg])) {
} else if (fileExists(argv[arg])) {
files.push_back(argv[arg]);

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/minimap/mmapConvert.C
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-len") == 0) {
minOverlapLength = atoi(argv[++arg]);

} else if (AS_UTL_fileExists(argv[arg])) {
} else if (fileExists(argv[arg])) {
files.push_back(argv[arg]);

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/overlapBasedTrimming/clearRangeFile.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public:

strncpy(_fileName, fileName, FILENAME_MAX-1);

if (AS_UTL_fileExists(_fileName) == false) {
if (fileExists(_fileName) == false) {
_modified = true; // Always gets written, regardless of changes

_lastID = seq->sqStore_getNumReads();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ main(int argc, char **argv) {

sprintf(N, "%s/prefixEditDistance-matchLimit-%04d.bin", D, evalue);

if (AS_UTL_fileExists(N)) {
if (fileExists(N)) {
fprintf(stderr, "eValue %04d -- eRate %6.4f -- %7.4f%% error -- %8d values -- thread %2d - LOAD\n",
evalue, erate, erate * 100.0, MAX_ERRORS, omp_get_thread_num());

Expand Down
2 changes: 1 addition & 1 deletion src/overlapInCore/overlapConvert.C
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-unaligned") == 0) {
dt = ovOverlapAsUnaligned;

} else if (AS_UTL_fileExists(argv[arg])) {
} else if (fileExists(argv[arg])) {
files.push_back(argv[arg]);

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/overlapInCore/overlapImport.C
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ main(int argc, char **argv) {
}

else if ((strcmp(argv[arg], "-") == 0) ||
(AS_UTL_fileExists(argv[arg]))) {
(fileExists(argv[arg]))) {
files.push_back(argv[arg]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/overlapInCore/overlapPair.C
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ main(int argc, char **argv) {
ovFile *ovlFile = NULL;
ovFile *outFile = NULL;

if (AS_UTL_fileExists(ovlName, true)) {
if (directoryExists(ovlName)) {
fprintf(stderr, "Reading overlaps from store '%s' and writing to '%s'\n",
ovlName, outName);
ovlStore = new ovStore(ovlName, seqStore);
Expand Down
2 changes: 1 addition & 1 deletion src/sequence/sequence.C
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ main(int argc, char **argv) {

// INPUTS

else if (AS_UTL_fileExists(argv[arg]) == true) {
else if (fileExists(argv[arg]) == true) {
inputs.push_back(argv[arg]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/stores/loadCorrectedReads.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ main (int argc, char **argv) {
} else if (strcmp(argv[arg], "-qv") == 0) {
loadQVs = true;

} else if (AS_UTL_fileExists(argv[arg])) {
} else if (fileExists(argv[arg])) {
corInputs.push_back(argv[arg]);

} else {
Expand Down
4 changes: 2 additions & 2 deletions src/stores/loadErates.C
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ovStore::addEvalues(vector<char *> &fileList) {
_evalues = NULL;
}

if (AS_UTL_fileExists(evalueName) == true) {
if (fileExists(evalueName) == true) {
fprintf(stderr, "WARNING:\n");
fprintf(stderr, "WARNING: existing evalue file will be overwritten!\n");
fprintf(stderr, "WARNING:\n");
Expand Down Expand Up @@ -197,7 +197,7 @@ main(int argc, char **argv) {
AS_UTL_loadFileList(argv[++arg], fileList);

} else if (((argv[arg][0] == '-') && (argv[arg][1] == 0)) ||
(AS_UTL_fileExists(argv[arg]))) {
(fileExists(argv[arg]))) {
fileList.push_back(argv[arg]); // Assume it's an input file

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/ovStore.C
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ovStore::ovStore(const char *path, sqStore *seq) {

snprintf(name, FILENAME_MAX, "%s/evalues", _storePath);

if (AS_UTL_fileExists(name)) {
if (fileExists(name)) {
_evaluesMap = new memoryMappedFile(name, memoryMappedFile_readOnly);
_evalues = (uint16 *)_evaluesMap->get(0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/ovStoreBucketizer.C
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ main(int argc, char **argv) {
snprintf(sliceSName, FILENAME_MAX, "%s/create%04u/sliceSizes", ovlName, bucketNum); // sliceSizes name before rename.
snprintf(bucketName, FILENAME_MAX, "%s/bucket%04u", ovlName, bucketNum);

if (AS_UTL_fileExists(createName, true, false) == true) {
if (directoryExists(createName) == true) {
if (forceOverwrite) {
fprintf(stderr, "Overwriting incomplete result from presumed crashed job in directory '%s'.\n", createName);
} else {
Expand All @@ -182,7 +182,7 @@ main(int argc, char **argv) {
}
}

if (AS_UTL_fileExists(bucketName, false, false) == true) {
if (directoryExists(bucketName) == true) {
fprintf(stderr, "Job finished; file '%s' exists.\n", sliceSName);
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/ovStoreConfig.C
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ main(int argc, char **argv) {
writeSlices = strtouint32(argv[++arg]);

} else if (((argv[arg][0] == '-') && (argv[arg][1] == 0)) ||
(AS_UTL_fileExists(argv[arg]))) {
(fileExists(argv[arg]))) {
// Assume it's an input file
fileList.push_back(argv[arg]);

Expand Down
2 changes: 1 addition & 1 deletion src/stores/ovStoreFile.H
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public:
// should have sent in a NULL prefix!) used when constructing the store.
// Return with no counts allocated and trust that the user doesn't try to access them.

if (AS_UTL_fileExists(name) == false)
if (fileExists(name) == false)
return;

// Otherwise, counts exist, and we load them.
Expand Down
6 changes: 3 additions & 3 deletions src/stores/ovStoreHistogram.C
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ ovStoreHistogram::ovStoreHistogram(const char *path) {

createDataName(name, path);

if (AS_UTL_fileExists(name, false, false) == false) // If no data, nothing to
return; // load, so leave it empty.
if (fileExists(name) == false) // If no data, nothing to
return; // load, so leave it empty.

// Load!

Expand Down Expand Up @@ -154,7 +154,7 @@ ovStoreHistogram::ovStoreHistogram(const char *path) {
char *
ovStoreHistogram::createDataName(char *name, const char *prefix) {

if (AS_UTL_fileExists(prefix, true, false)) { // If name is a directory,
if (directoryExists(prefix)) { // If name is a directory,
snprintf(name, FILENAME_MAX, "%s/statistics", prefix); // return a file in the directory.
}

Expand Down
2 changes: 1 addition & 1 deletion src/stores/ovStoreSorter.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ checkSentinel(const char *ovlName, uint32 sliceNum, ovStoreConfig *config) {

snprintf(N, FILENAME_MAX, "%s/%04u.started", ovlName, sliceNum);

if (AS_UTL_fileExists(N, true, false) == true) {
if (fileExists(N) == true) {
fprintf(stderr, "Job (appears to be) in progress; sentinel file '%s' exists.\n", N);
exit(1);
}
Expand Down
10 changes: 5 additions & 5 deletions src/stores/ovStoreWriter.C
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ ovStoreSliceWriter::loadBucketSizes(uint64 *bucketSizes) {

// If no file, there are no overlaps, so nothing to load.

if (AS_UTL_fileExists(name, false, false) == false)
if (fileExists(name) == false)
continue;

// Load the slice sizes, and save the number of overlaps in this slice.
Expand Down Expand Up @@ -257,7 +257,7 @@ ovStoreSliceWriter::loadOverlapsFromBucket(uint32 bucket, uint64 expectedLen, ov

snprintf(name, FILENAME_MAX, "%s/bucket%04u/slice%04u", _storePath, bucket, _sliceNum);

if (AS_UTL_fileExists(name, false, false) == false)
if (fileExists(name) == false)
fprintf(stderr, "ERROR: " F_U64 " overlaps claim to exist in bucket '%s', but file not found.\n",
expectedLen, name), exit(1);

Expand Down Expand Up @@ -503,8 +503,8 @@ ovStoreSliceWriter::checkSortingIsComplete(void) {
snprintf(nameF, FILENAME_MAX, "%s/%04u.info", _storePath, i);
snprintf(nameI, FILENAME_MAX, "%s/%04u.index", _storePath, i);

bool existF = AS_UTL_fileExists(nameF, false, false);
bool existI = AS_UTL_fileExists(nameI, false, false);
bool existF = fileExists(nameF);
bool existI = fileExists(nameI);

if (existF && existI)
continue;
Expand Down Expand Up @@ -542,7 +542,7 @@ ovStoreSliceWriter::removeAllIntermediateFiles(void) {
ovFile::createDataName(name, _storePath, ss, pp);
ovStoreHistogram::createDataName(nomo, name);

if (AS_UTL_fileExists(nomo) == false)
if (fileExists(nomo) == false)
break;

AS_UTL_unlink(nomo);
Expand Down
Loading

0 comments on commit d539a54

Please sign in to comment.