Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feliks Kiszkurno
ogs-feliks
Commits
38e6af5f
Commit
38e6af5f
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Using logog logging within the class FileFinder.
parent
79d43af7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
BaseLib/FileFinder.h
+27
-16
27 additions, 16 deletions
BaseLib/FileFinder.h
with
27 additions
and
16 deletions
BaseLib/FileFinder.h
+
27
−
16
View file @
38e6af5f
...
@@ -15,12 +15,15 @@
...
@@ -15,12 +15,15 @@
#ifndef FILEFINDER_H
#ifndef FILEFINDER_H
#define FILEFINDER_H
#define FILEFINDER_H
#include
<iostream>
#include
<fstream>
#include
<fstream>
#include
<string>
#include
<string>
#include
<
list
>
#include
<
vector
>
namespace
BaseLib
{
// ThirdParty/logog
#include
"logog/include/logog.hpp"
namespace
BaseLib
{
/**
/**
* FileFinder stores a list of directories and will return the complete path
* FileFinder stores a list of directories and will return the complete path
* for a given filename if the corresponding file is found in any of these
* for a given filename if the corresponding file is found in any of these
...
@@ -30,40 +33,48 @@ class FileFinder
...
@@ -30,40 +33,48 @@ class FileFinder
{
{
public:
public:
/// Constructor
/// Constructor
FileFinder
()
{}
;
FileFinder
()
{}
/**
/**
* \brief Adds another directory to the search-space.
* \brief Adds another directory to the search-space.
* If the given directory does not end with a slash one will be appended.
* If the given directory does not end with a slash one will be appended.
*/
*/
void
addDirectory
(
std
::
string
dir
)
void
addDirectory
(
std
::
string
const
&
dir
)
{
{
if
(
dir
[
dir
.
size
()
-
1
]
!=
'/'
)
dir
.
append
(
"/"
);
if
(
dir
[
dir
.
size
()
-
1
]
!=
'/'
)
_directories
.
push_back
(
dir
);
_directories
.
push_back
(
std
::
string
(
dir
+
"/"
));
};
else
_directories
.
push_back
(
dir
);
}
/**
/**
* Given a filename, this method will return the complete path where this file can be found.
* Given a filename, this method will return the complete path where this file can be found.
* If the file is located in more than one of the directories in the search list, only the
* If the file is located in more than one of the directories in the search list, only the
* first location will be returned.
* first location will be returned.
*/
*/
std
::
string
getPath
(
std
::
string
filename
)
const
std
::
string
getPath
(
std
::
string
const
&
filename
)
const
{
{
if
(
_directories
.
empty
())
std
::
cout
<<
"Error: FileFinder::getPath() -- directory list is empty."
<<
std
::
endl
;
if
(
_directories
.
empty
())
for
(
std
::
list
<
std
::
string
>::
const_iterator
it
=
_directories
.
begin
();
it
!=
_directories
.
end
();
++
it
)
ERR
(
"FileFinder::getPath(): No directories set."
);
for
(
std
::
vector
<
std
::
string
>::
const_iterator
it
=
_directories
.
begin
();
it
!=
_directories
.
end
();
++
it
)
{
{
std
::
string
testDir
(
*
it
);
std
::
string
testDir
(
*
it
);
std
::
ifstream
is
(
testDir
.
append
(
filename
).
c_str
());
std
::
ifstream
is
(
testDir
.
append
(
filename
).
c_str
());
if
(
is
.
good
())
return
testDir
;
if
(
is
.
good
())
{
is
.
close
();
return
testDir
;
}
}
}
std
::
cout
<<
"Error:
FileFinder::getPath()
-- f
ile not found."
<<
std
::
endl
;
ERR
(
"
FileFinder::getPath()
: F
ile not found."
)
;
return
filename
;
return
filename
;
}
;
}
private
:
private
:
std
::
list
<
std
::
string
>
_directories
;
std
::
vector
<
std
::
string
>
_directories
;
};
};
}
// end namespace BaseLib
}
// end namespace BaseLib
#endif // FILEFINDER_H
#endif // FILEFINDER_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment