File: fgdlist.cc

package info (click to toggle)
ftpgrab 0.1.5-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 444 kB
  • ctags: 358
  • sloc: cpp: 2,906; makefile: 102
file content (51 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download | duplicates (5)
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
// fgdlist.cc

#include "fgdlist.h"

#ifndef _FGSTING_H
#include "fgstring.h"
#endif

FGDirListing::FGDirListing(const FGString& dirName)
: mDirName(dirName)
{
}

FGDirListing
FGDirListing::GetRHSOnlyFiles(const FGDirListing& lhs,
                              const FGDirListing& rhs)
{
  FGDirListing ret("NODIR");

  // Could be dealing with 100's or 1000's of files. Should really use
  // map (tree based) not hopeless vector iteration. Heard of O(n^2)? :-)

  std::vector<FGFileInfo>::const_iterator iRHSFiles;
  for (iRHSFiles = rhs.begin(); iRHSFiles != rhs.end(); iRHSFiles++) {
    if (iRHSFiles->IsRegularFile()) {
      ret.push_back(*iRHSFiles);
    }
  }

  std::vector<FGFileInfo>::const_iterator iLHSFiles;
  for (iLHSFiles = lhs.begin(); iLHSFiles != lhs.end(); iLHSFiles++) {
    // For each LHS files scan through current list for match
    // Ugh slow slow need a tree based thing see above comment
    std::vector<FGFileInfo>::iterator iCurFiles;
    for (iCurFiles = ret.begin(); iCurFiles != ret.end(); iCurFiles++) {
      if (*iLHSFiles == *iCurFiles) {
        // Match so waste it from return list
        ret.erase(iCurFiles);
        break;
      }
    }
  }

  return ret;
}

const FGString&
FGDirListing::GetDirName(void) const
{
  return mDirName;
}