-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecoFileMgr.cpp
More file actions
82 lines (70 loc) · 1.43 KB
/
RecoFileMgr.cpp
File metadata and controls
82 lines (70 loc) · 1.43 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "RecoFileMgr.h"
#include "RecoImage.h"
#include <iostream>
#include <sstream>
#include <direct.h>
#include <Windows.h>
CRecoFileMgr::CRecoFileMgr(void):
_hFind(INVALID_HANDLE_VALUE)
{
}
CRecoFileMgr::~CRecoFileMgr(void)
{
if(_hFind != INVALID_HANDLE_VALUE)
{
FindClose(_hFind);
_hFind = INVALID_HANDLE_VALUE;
}
}
bool CRecoFileMgr::Init(string strBasePath)
{
WIN32_FIND_DATA ffd;
ostringstream strPathBuffer;
ostringstream strDirPath;
//Build path for FindFirstFile
//Check for trailing "\"
if (strBasePath[strBasePath.length()-1] == '\\')
{
strDirPath << strBasePath;
}
else
{
strDirPath << "\\" << strBasePath;
}
strPathBuffer << strDirPath.str() << "*";
////
//Find first file in path
_hFind = FindFirstFile(strPathBuffer.str().c_str(), &ffd);
if(_hFind == INVALID_HANDLE_VALUE)
{
return false;
}
else
{
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
_ImgPaths.push_back(string(strDirPath.str() + ffd.cFileName)); //Add to List
}
}
//Iterate through all files in path
while(FindNextFile(_hFind, &ffd) != 0)
{
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
_ImgPaths.push_back(string(strDirPath.str() + ffd.cFileName)); //Add to List
}
}
return true;
}
unsigned int CRecoFileMgr::GetNumImages()
{
return (int) _ImgPaths.size();
}
string CRecoFileMgr::GetImagePath(unsigned int i)
{
if(i >= this->GetNumImages())
{
return "INVALID";
}
return _ImgPaths[i];
}