FileLister: don't assume that all files have nonzero size in test case
This commit is contained in:
parent
e22f69daf4
commit
b0ed595e24
|
@ -289,13 +289,11 @@ void FileLister::recursiveAddFiles2(std::vector<std::string> &relative,
|
||||||
relative.push_back(filename);
|
relative.push_back(filename);
|
||||||
absolute.push_back(fname);
|
absolute.push_back(fname);
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
off_t size = 0;
|
|
||||||
if (stat(fname, &sb) == 0)
|
if (stat(fname, &sb) == 0)
|
||||||
{
|
{
|
||||||
size = sb.st_size;
|
// Limitation: file sizes are assumed to fit in a 'long'
|
||||||
|
filesizes[filename] = static_cast<long>(sb.st_size);
|
||||||
}
|
}
|
||||||
// Limitation: file sizes are assumed to fit in a 'long'
|
|
||||||
filesizes[filename] = static_cast<long>(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
|
|
|
@ -55,11 +55,10 @@ private:
|
||||||
std::map<std::string, long> filesizes;
|
std::map<std::string, long> filesizes;
|
||||||
FileLister::recursiveAddFiles(filenames, filesizes, ".");
|
FileLister::recursiveAddFiles(filenames, filesizes, ".");
|
||||||
|
|
||||||
// Ensure a nonzero size is present for each listed file
|
// Ensure a size entry is present for each listed file
|
||||||
for (std::vector<std::string>::const_iterator i = filenames.begin(); i != filenames.end(); ++i)
|
for (std::vector<std::string>::const_iterator i = filenames.begin(); i != filenames.end(); ++i)
|
||||||
{
|
{
|
||||||
ASSERT(filesizes.find(*i) != filesizes.end());
|
ASSERT(filesizes.find(*i) != filesizes.end());
|
||||||
ASSERT(filesizes[*i] > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case there are leading "./"..
|
// In case there are leading "./"..
|
||||||
|
|
Loading…
Reference in New Issue