Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Sylvain Joubert
KWSys
Commits
0d591144
Commit
0d591144
authored
20 years ago
by
Andy Cedilnik
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add method to find file in parent directories if it exists
parent
30140c03
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SystemTools.cxx
+23
-0
23 additions, 0 deletions
SystemTools.cxx
SystemTools.hxx.in
+6
-0
6 additions, 0 deletions
SystemTools.hxx.in
with
29 additions
and
0 deletions
SystemTools.cxx
+
23
−
0
View file @
0d591144
...
...
@@ -2071,6 +2071,29 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
return
false
;
}
kwsys_stl
::
string
SystemTools
::
FileExistsInParentDirectories
(
const
char
*
fname
,
const
char
*
directory
,
const
char
*
toplevel
)
{
kwsys_stl
::
string
file
=
fname
;
SystemTools
::
ConvertToUnixSlashes
(
file
);
kwsys_stl
::
string
dir
=
directory
;
SystemTools
::
ConvertToUnixSlashes
(
dir
);
while
(
1
)
{
kwsys_stl
::
string
path
=
dir
+
"/"
+
file
;
if
(
SystemTools
::
FileExists
(
path
.
c_str
())
)
{
return
path
;
}
if
(
dir
.
size
()
<
strlen
(
toplevel
)
)
{
break
;
}
dir
=
SystemTools
::
GetParentDirectory
(
dir
.
c_str
());
}
return
""
;
}
// These must NOT be initialized. Default initialization to zero is
// necessary.
unsigned
int
SystemToolsManagerCount
;
...
...
This diff is collapsed.
Click to expand it.
SystemTools.hxx.in
+
6
−
0
View file @
0d591144
...
...
@@ -322,6 +322,12 @@ public:
/** Check if the given file or directory is in subdirectory of dir */
static bool IsSubDirectory(const char* fileOrDir, const char* dir);
/** Check if the given file exists in one of the parent directory of the
* given file or directory and if it does, return the name of the file.
* Toplevel specifies the top-most directory to where it will look.*/
static kwsys_stl::string FileExistsInParentDirectories(const char* fname,
const char* directory, const char* toplevel);
protected:
// these two functions can be called from ConvertToOutputPath
/**
...
...
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